diff --git a/s3torchconnector/src/s3torchconnector/_user_agent.py b/s3torchconnector/src/s3torchconnector/_user_agent.py index 31088422..ddceaa6e 100644 --- a/s3torchconnector/src/s3torchconnector/_user_agent.py +++ b/s3torchconnector/src/s3torchconnector/_user_agent.py @@ -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 [] diff --git a/s3torchconnector/tst/unit/test_user_agent.py b/s3torchconnector/tst/unit/test_user_agent.py index 890b265a..7ecf0c7d 100644 --- a/s3torchconnector/tst/unit/test_user_agent.py +++ b/s3torchconnector/tst/unit/test_user_agent.py @@ -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)