add a __repr__ for JobsArgument

This commit is contained in:
Anthony Sottile 2021-11-14 14:42:48 -08:00
parent b454674b27
commit 0698366a20
2 changed files with 10 additions and 0 deletions

View file

@ -80,6 +80,10 @@ class JobsArgument:
f"{arg!r} must be 'auto' or an integer.",
)
def __repr__(self) -> str:
"""Representation for debugging."""
return f"{type(self).__name__}({str(self)!r})"
def __str__(self):
"""Format our JobsArgument class."""
return "auto" if self.is_auto else str(self.n_jobs)

View file

@ -387,3 +387,9 @@ def test_jobs_argument_str():
"""Test that JobsArgument has a correct __str__."""
assert str(JobsArgument("auto")) == "auto"
assert str(JobsArgument("123")) == "123"
def test_jobs_argument_repr():
"""Test that JobsArgument has a correct __repr__."""
assert repr(JobsArgument("auto")) == "JobsArgument('auto')"
assert repr(JobsArgument("123")) == "JobsArgument('123')"