Renamed tests.
@@ -74,7 +74,7 @@ class TestDeclarativeSyntax(TestCase):
self.assertEqual(x.b, 0)
self.assertEqual(x.c, 2)
- def test_init_missing_1_required_positional_arg(self):
+ def test_raises_when_init_missing_1_required_positional_arg(self):
@aggregate
class MyAgg:
def __init__(self, value):
@@ -87,7 +87,7 @@ class TestDeclarativeSyntax(TestCase):
"__init__() missing 1 required positional argument: 'value'",
)
- def test_init_missing_1_required_keyword_only_arg(self):
+ def test_raises_when_init_missing_1_required_keyword_only_arg(self):
@aggregate
class MyAgg:
def __init__(self, *, value):
@@ -100,7 +100,7 @@ class TestDeclarativeSyntax(TestCase):
"__init__() missing 1 required keyword-only argument: 'value'",
)
- def test_init_with_missing_required_positional_and_keyword_only_arg(self):
+ def test_raises_when_init_missing_required_positional_and_keyword_only_arg(self):
@aggregate
class MyAgg:
def __init__(self, a, *, b):
@@ -113,32 +113,31 @@ class TestDeclarativeSyntax(TestCase):
"__init__() missing 1 required positional argument: 'a'",
)
- def test_init_missing_2_required_positional_args(self):
@aggregate
class MyAgg:
- def __init__(self, a, b, *, c):
- pass
+ def __init__(self, a, b=0, *, c):
+ self.a = a
+ self.b = b
+ self.c = c
with self.assertRaises(TypeError) as cm:
- MyAgg()
+ MyAgg(c=2)
self.assertEqual(
cm.exception.args[0],
- "__init__() missing 2 required positional arguments: 'a' and 'b'",
+ "__init__() missing 1 required positional argument: 'a'",
)
- def test_init_with_default_keyword_arg_missing_positional_and_keyword_only(self):
+ def test_raises_when_init_missing_2_required_positional_args(self):
@aggregate
class MyAgg:
- def __init__(self, a, b=0, *, c):
- self.a = a
- self.b = b
- self.c = c
+ def __init__(self, a, b, *, c):
+ pass
with self.assertRaises(TypeError) as cm:
- MyAgg(c=2)
+ MyAgg()
self.assertEqual(
cm.exception.args[0],
- "__init__() missing 1 required positional argument: 'a'",
+ "__init__() missing 2 required positional arguments: 'a' and 'b'",
)
def test_dataclass_aggregate_no_defaults(self):
