Merge pull request #1459 from asottile/jobs-repr

add a __repr__ for JobsArgument
This commit is contained in:
Anthony Sottile 2021-11-14 17:51:05 -05:00 committed by GitHub
commit d582affb2c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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')"