def test_param_dupe(self): params1 = { # 'from_files': {}, 'tags': [], u'testvalue': False, u'testvalue2': True, # 'when': [] } params2 = { # 'from_files': {}, 'tags': [], u'testvalue': True, u'testvalue2': False, # 'when': [] } res1 = hash_params(params1) res2 = hash_params(params2) self.assertNotEqual(hash(res1), hash(res2)) self.assertNotEqual(res1, res2) foo = {} foo[res1] = 'params1' foo[res2] = 'params2' self.assertEqual(len(foo), 2) del foo[res2] self.assertEqual(len(foo), 1) for key in foo: self.assertTrue(key in foo) self.assertIn(key, foo)
def test_param_dict_dupe_values(self): params1 = {'foo': False} params2 = {'bar': False} res1 = hash_params(params1) res2 = hash_params(params2) hash1 = hash(res1) hash2 = hash(res2) self.assertNotEqual(res1, res2) self.assertNotEqual(hash1, hash2)
def test_generator(self): def my_generator(): for i in ['a', 1, None, {}]: yield i params = my_generator() res = hash_params(params) self._assert_hashable(res)
def test_dict_tuple(self): params = { 'foo': ( 1, 'bar', ) } res = hash_params(params) self._assert_set(res)
def test_empty_set(self): params = set([]) res = hash_params(params) self._assert_hashable(res) self._assert_set(res)
def test_dict_with_list_value(self): params = {'foo': [1, 4, 'bar']} res = hash_params(params) self._assert_set(res) self._assert_hashable(res)
def test_list(self): params = ['foo', 'bar', 1, 37, None] res = hash_params(params) self._assert_set(res) self._assert_hashable(res)
def test_tuple_dict(self): params = ({'foo': 'bar'}, 37) res = hash_params(params) self._assert_hashable(res)
def test_tuple(self): params = (1, None, 'foo') res = hash_params(params) self._assert_hashable(res)
def test(self): params = {'foo': 'bar'} res = hash_params(params) self._assert_set(res) self._assert_hashable(res)