From a409bdb0c31d658fab633784fcb73308127042c7 Mon Sep 17 00:00:00 2001 From: dnnanuti Date: Thu, 29 Feb 2024 17:41:58 +0000 Subject: [PATCH] Updated arg check and test --- s3torchconnector/src/s3torchconnector/_user_agent.py | 2 +- s3torchconnector/tst/unit/test_user_agent.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) 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)