Skip to content

Commit f311a5f

Browse files
committed
Ignore invalid ContentType.__init__ params
We want to validate runtime behavior here. Signed-off-by: Stephen Finucane <stephen@that.guru>
1 parent ff0dcbf commit f311a5f

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

tests/test_content_type.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212
class TestContentType(TestCase):
1313
def test___init___None_errors(self):
1414
raises_value_error = Raises(MatchesException(ValueError))
15-
self.assertThat(lambda: ContentType(None, None), raises_value_error)
16-
self.assertThat(lambda: ContentType(None, "traceback"), raises_value_error)
17-
self.assertThat(lambda: ContentType("text", None), raises_value_error)
15+
# intentionally passing invalid values to test runtime behavior
16+
self.assertThat(lambda: ContentType(None, None), raises_value_error) # type: ignore[arg-type]
17+
self.assertThat(lambda: ContentType(None, "traceback"), raises_value_error) # type: ignore[arg-type]
18+
self.assertThat(lambda: ContentType("text", None), raises_value_error) # type: ignore[arg-type]
1819

1920
def test___init___sets_ivars(self):
2021
content_type = ContentType("foo", "bar")

testtools/content_type.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ class ContentType:
1212
content type.
1313
"""
1414

15+
type: str
16+
subtype: str
17+
parameters: dict[str, str]
18+
1519
def __init__(
1620
self, primary_type: str, sub_type: str, parameters: dict[str, str] | None = None
1721
) -> None:

0 commit comments

Comments
 (0)