Skip to content

Commit

Permalink
Updated arg check and test
Browse files Browse the repository at this point in the history
  • Loading branch information
dnnanuti committed Feb 29, 2024
1 parent 64ab8ae commit a409bdb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion s3torchconnector/src/s3torchconnector/_user_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class UserAgent:
def __init__(self, comments: List[str] = None):
if comments and not isinstance(comments, list):
if comments is not None and not isinstance(comments, list):
raise ValueError("Argument comments must be a List[str]")
self._user_agent_prefix = f"{__package__}/{__version__}"
self._comments = comments or []
Expand Down
5 changes: 3 additions & 2 deletions s3torchconnector/tst/unit/test_user_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def test_default_user_agent_creation():
assert user_agent.prefix == DEFAULT_PREFIX


def test_invalid_comments_argument():
@pytest.mark.parametrize("invalid_comment", [0, "string"])
def test_invalid_comments_argument(invalid_comment):
with pytest.raises(ValueError, match="Argument comments must be a List\[str\]"):
UserAgent("string")
UserAgent(invalid_comment)

0 comments on commit a409bdb

Please sign in to comment.