(self)
| 827 | self.assertNotEqual(Point(1, 3), C(1, 3)) |
| 828 | |
| 829 | def test_not_other_dataclass(self): |
| 830 | # Test that some of the problems with namedtuple don't happen |
| 831 | # here. |
| 832 | @dataclass |
| 833 | class Point3D: |
| 834 | x: int |
| 835 | y: int |
| 836 | z: int |
| 837 | |
| 838 | @dataclass |
| 839 | class Date: |
| 840 | year: int |
| 841 | month: int |
| 842 | day: int |
| 843 | |
| 844 | self.assertNotEqual(Point3D(2017, 6, 3), Date(2017, 6, 3)) |
| 845 | self.assertNotEqual(Point3D(1, 2, 3), (1, 2, 3)) |
| 846 | |
| 847 | # Make sure we can't unpack. |
| 848 | with self.assertRaisesRegex(TypeError, 'unpack'): |
| 849 | x, y, z = Point3D(4, 5, 6) |
| 850 | |
| 851 | # Make sure another class with the same field names isn't |
| 852 | # equal. |
| 853 | @dataclass |
| 854 | class Point3Dv1: |
| 855 | x: int = 0 |
| 856 | y: int = 0 |
| 857 | z: int = 0 |
| 858 | self.assertNotEqual(Point3D(0, 0, 0), Point3Dv1()) |
| 859 | |
| 860 | def test_function_annotations(self): |
| 861 | # Some dummy class and instance to use as a default. |
nothing calls this directly
no test coverage detected