@@ -0,0 +1,2447 @@
+import numpy as np%0Afrom numpy.testing import *%0A%0Aclass TestBuiltin(TestCase):%0A    def test_run(self):%0A        %22%22%22Only test hash runs at all.%22%22%22%0A        for t in %5Bnp.int, np.float, np.complex, np.int32, np.str, np.object,%0A                np.unicode%5D:%0A            dt = np.dtype(t)%0A            hash(dt)%0A%0Aclass TestRecord(TestCase):%0A    def test_equivalent_record(self):%0A        %22%22%22Test whether equivalent record dtypes hash the same.%22%22%22%0A        a = np.dtype(%5B('yo', np.int)%5D)%0A        b = np.dtype(%5B('yo', np.int)%5D)%0A        self.failUnless(hash(a) == hash(b), %0A                %22two equivalent types do not hash to the same value !%22)%0A%0A    def test_different_names(self):%0A        # In theory, they may hash the same (collision) ?%0A        a = np.dtype(%5B('yo', np.int)%5D)%0A        b = np.dtype(%5B('ye', np.int)%5D)%0A        self.failUnless(hash(a) != hash(b),%0A                %22%25s and %25s hash the same !%22 %25 (a, b))%0A%0A    def test_different_titles(self):%0A        # In theory, they may hash the same (collision) ?%0A        a = np.dtype(%7B'names': %5B'r','b'%5D, 'formats': %5B'u1', 'u1'%5D,%0A            'titles': %5B'Red pixel', 'Blue pixel'%5D%7D)%0A        b = np.dtype(%7B'names': %5B'r','b'%5D, 'formats': %5B'u1', 'u1'%5D,%0A            'titles': %5B'RRed pixel', 'Blue pixel'%5D%7D)%0A        self.failUnless(hash(a) != hash(b),%0A                %22%25s and %25s hash the same !%22 %25 (a, b))%0A%0Aclass TestSubarray(TestCase):%0A    def test_equivalent_record(self):%0A        %22%22%22Test whether equivalent subarray dtypes hash the same.%22%22%22%0A        a = np.dtype((np.int, (2, 3)))%0A        b = np.dtype((np.int, (2, 3)))%0A        self.failUnless(hash(a) == hash(b), %0A                %22two equivalent types do not hash to the same value !%22)%0A%0A    def test_nonequivalent_record(self):%0A        %22%22%22Test whether different subarray dtypes hash differently.%22%22%22%0A        a = np.dtype((np.int, (2, 3)))%0A        b = np.dtype((np.int, (3, 2)))%0A        self.failUnless(hash(a) != hash(b), %0A                %22%25s and %25s hash the same !%22 %25 (a, b))%0A%0A        a = np.dtype((np.int, (2, 3)))%0A        b = np.dtype((np.int, (2, 2)))%0A        self.failUnless(hash(a) != hash(b), %0A                %22%25s and %25s hash the same !%22 %25 (a, b))%0A%0A        a = np.dtype((np.int, (1, 2, 3)))%0A        b = np.dtype((np.int, (1, 2)))%0A        self.failUnless(hash(a) != hash(b), %0A                %22%25s and %25s hash the same !%22 %25 (a, b))%0A%0Aclass TestMonsterType(TestCase):%0A    %22%22%22Test deeply nested subtypes.%22%22%22%0A    pass%0A%0Aif __name__ == %22__main__%22:%0A    run_module_suite()%0A

Add some unit tests for the hashing protocol of dtype (fail currently).