diff options
author | Donald Stufft <donald@stufft.io> | 2014-12-15 07:41:02 -0500 |
---|---|---|
committer | Donald Stufft <donald@stufft.io> | 2014-12-15 07:41:02 -0500 |
commit | 7b51ccd8478211858b5cec76a7925c21e256c0fa (patch) | |
tree | 3ee280b4bc428082b6803adfe83330da01d20e91 /setuptools/tests/test_resources.py | |
parent | 788894a458744f7b19b9c686afb20e7bc85344fd (diff) | |
download | python-setuptools-bitbucket-7b51ccd8478211858b5cec76a7925c21e256c0fa.tar.gz |
Define a __hash__ on the packaging.version.Version subclasses
In Python 3.x a subclass will not inherent the __hash__ method from
the parent classes if the subclass defines a __eq__ method. This
means that without defining our own __hash__ the SetuptoolsVersion
classes are unhashable.
Diffstat (limited to 'setuptools/tests/test_resources.py')
-rw-r--r-- | setuptools/tests/test_resources.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/setuptools/tests/test_resources.py b/setuptools/tests/test_resources.py index 13f80aa4..1902fb2c 100644 --- a/setuptools/tests/test_resources.py +++ b/setuptools/tests/test_resources.py @@ -528,6 +528,16 @@ class ParseTests(TestCase): self.assertTrue(parse_version("3.0") != tuple(parse_version("2.0"))) self.assertFalse(parse_version("3.0") != tuple(parse_version("3.0"))) + def testVersionHashable(self): + """ + Ensure that our versions stay hashable even though we've subclassed + them and added some shim code to them. + """ + self.assertEqual( + hash(parse_version("1.0")), + hash(parse_version("1.0")), + ) + class ScriptHeaderTests(TestCase): non_ascii_exe = '/Users/José/bin/python' |