(self)
| 346 | self.assertEqual(getattr(c, name), name) |
| 347 | |
| 348 | def test_0_field_compare(self): |
| 349 | # Ensure that order=False is the default. |
| 350 | @dataclass |
| 351 | class C0: |
| 352 | pass |
| 353 | |
| 354 | @dataclass(order=False) |
| 355 | class C1: |
| 356 | pass |
| 357 | |
| 358 | for cls in [C0, C1]: |
| 359 | with self.subTest(cls=cls): |
| 360 | self.assertEqual(cls(), cls()) |
| 361 | for idx, fn in enumerate([lambda a, b: a < b, |
| 362 | lambda a, b: a <= b, |
| 363 | lambda a, b: a > b, |
| 364 | lambda a, b: a >= b]): |
| 365 | with self.subTest(idx=idx): |
| 366 | with self.assertRaisesRegex(TypeError, |
| 367 | f"not supported between instances of '{cls.__name__}' and '{cls.__name__}'"): |
| 368 | fn(cls(), cls()) |
| 369 | |
| 370 | @dataclass(order=True) |
| 371 | class C: |
| 372 | pass |
| 373 | self.assertLessEqual(C(), C()) |
| 374 | self.assertGreaterEqual(C(), C()) |
| 375 | |
| 376 | def test_1_field_compare(self): |
| 377 | # Ensure that order=False is the default. |
nothing calls this directly
no test coverage detected