summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_dataclasses.py
diff options
context:
space:
mode:
authorNikita Sobolev <mail@sobolevn.me>2022-10-04 16:53:28 (GMT)
committerGitHub <noreply@github.com>2022-10-04 16:53:28 (GMT)
commit4f380db1a539bf7ae157d1e0791b5ac3fecfcf01 (patch)
treed4487b0655da08981e897e9fe1e4d904c5eb0c58 /Lib/test/test_dataclasses.py
parent53503ff60e9a4727af0d9a1096418675e72a0fae (diff)
downloadcpython-4f380db1a539bf7ae157d1e0791b5ac3fecfcf01.zip
cpython-4f380db1a539bf7ae157d1e0791b5ac3fecfcf01.tar.gz
cpython-4f380db1a539bf7ae157d1e0791b5ac3fecfcf01.tar.bz2
gh-96142: add missing params to `dataclass._DataclassParams` (gh-96382)
Diffstat (limited to 'Lib/test/test_dataclasses.py')
-rw-r--r--Lib/test/test_dataclasses.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/Lib/test/test_dataclasses.py b/Lib/test/test_dataclasses.py
index e2eab69..328dcdc 100644
--- a/Lib/test/test_dataclasses.py
+++ b/Lib/test/test_dataclasses.py
@@ -68,6 +68,32 @@ class TestCase(unittest.TestCase):
self.assertEqual(repr_output, expected_output)
+ def test_dataclass_params_repr(self):
+ # Even though this is testing an internal implementation detail,
+ # it's testing a feature we want to make sure is correctly implemented
+ # for the sake of dataclasses itself
+ @dataclass(slots=True, frozen=True)
+ class Some: pass
+
+ repr_output = repr(Some.__dataclass_params__)
+ expected_output = "_DataclassParams(init=True,repr=True," \
+ "eq=True,order=False,unsafe_hash=False,frozen=True," \
+ "match_args=True,kw_only=False," \
+ "slots=True,weakref_slot=False)"
+ self.assertEqual(repr_output, expected_output)
+
+ def test_dataclass_params_signature(self):
+ # Even though this is testing an internal implementation detail,
+ # it's testing a feature we want to make sure is correctly implemented
+ # for the sake of dataclasses itself
+ @dataclass
+ class Some: pass
+
+ for param in inspect.signature(dataclass).parameters:
+ if param == 'cls':
+ continue
+ self.assertTrue(hasattr(Some.__dataclass_params__, param), msg=param)
+
def test_named_init_params(self):
@dataclass
class C: