def test_pow_magic_method(self): d = {0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0} self.dct_wrapper_2 = DictWrapper(d, name='test_wrapper') self.assertEqual((self.dct_wrapper**self.dct_wrapper_2), DictWrapper({ 0: 1.0, 1: 1.0, 2: 1.0, 3: 1.0 }))
def test_add_magic_method(self): d = {0: 0.0, 1: -1.0, 2: -2.0, 3: -4.0} self.dct_wrapper_2 = DictWrapper(d, name='test_wrapper') self.assertEqual((self.dct_wrapper + self.dct_wrapper_2), DictWrapper({ 0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0 }))
def test_mod_magic_method(self): d = {0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0} self.dct_wrapper_2 = DictWrapper(d, name='test_wrapper') self.assertEqual((self.dct_wrapper_2 % self.dct_wrapper), DictWrapper({ 0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0 }))
def test_cmp_equal_magic_method(self): self.assertEqual( cmp(self.dct_wrapper, DictWrapper({ 0: 0.0, 1: 1.0, 2: 2.0, 3: 4.0 })), 0)
def test_is_subset(self): self.assertEqual( self.dct_wrapper.is_subset( DictWrapper({ 0: 0.0, 1: 1.0, 2: 2.0, 3: 4.0 })), True)
def test_gt_magic_method(self): d = {0: 0.0, 1: 1.0, 2: 2.0, 3: 3.0} self.dct_wrapper_2 = DictWrapper(d, name='test_wrapper') self.assertEqual((self.dct_wrapper > self.dct_wrapper_2), True)
def test_iter_magic_method(self): d = {} for k, y in self.dct_wrapper: d[k] = y self.assertEqual(self.dct_wrapper, DictWrapper(d))
def setUp(self): d = {0: 0.0, 1: 1.0, 2: 2.0, 3: 4.0} self.dct_wrapper = DictWrapper(d, name='test_wrapper')
class DictWrapperTest(unittest.TestCase): def setUp(self): d = {0: 0.0, 1: 1.0, 2: 2.0, 3: 4.0} self.dct_wrapper = DictWrapper(d, name='test_wrapper') def tearDown(self): pass def test_delete_magic_method(self): del self.dct_wrapper[0] self.assertEqual(self.dct_wrapper.get(0), None) def test_getitem_magic_method(self): self.assertEqual(self.dct_wrapper[1], 1.0) def test_contains_magic_method(self): outcome = False if 1 in self.dct_wrapper: outcome = True self.assertEqual(outcome, True) def test_len_magic_method(self): self.assertEqual(len(self.dct_wrapper), 4) def test_iter_magic_method(self): d = {} for k, y in self.dct_wrapper: d[k] = y self.assertEqual(self.dct_wrapper, DictWrapper(d)) def test_str_magic_method(self): self.assertEqual(str(self.dct_wrapper), "{0: 0.0, 1: 1.0, 2: 2.0, 3: 4.0}") def test_cmp_less_magic_method(self): self.assertEqual( cmp(self.dct_wrapper, DictWrapper({ 0: 0.0, 1: 1.0, 2: 2.0, 3: 5.0 })), -1) def test_cmp_more_magic_method(self): self.assertEqual( cmp(self.dct_wrapper, DictWrapper({ 0: 0.0, 1: 1.0, 2: 2.0, 3: 3.0 })), 1) def test_cmp_equal_magic_method(self): self.assertEqual( cmp(self.dct_wrapper, DictWrapper({ 0: 0.0, 1: 1.0, 2: 2.0, 3: 4.0 })), 0) def test_equal_magic_method(self): d = {0: 0.0, 1: 1.0, 2: 2.0, 3: 4.0} self.dct_wrapper_2 = DictWrapper(d, name='test_wrapper') self.assertEqual((self.dct_wrapper == self.dct_wrapper_2), True) def test_ne_magic_method(self): d = {0: 0.0, 1: 1.0, 2: 2.0, 3: 6.0} self.dct_wrapper_2 = DictWrapper(d, name='test_wrapper') self.assertEqual((self.dct_wrapper != self.dct_wrapper_2), True) def test_lt_magic_method(self): d = {0: 0.0, 1: 1.0, 2: 2.0, 3: 6.0} self.dct_wrapper_2 = DictWrapper(d, name='test_wrapper') self.assertEqual((self.dct_wrapper < self.dct_wrapper_2), True) def test_gt_magic_method(self): d = {0: 0.0, 1: 1.0, 2: 2.0, 3: 3.0} self.dct_wrapper_2 = DictWrapper(d, name='test_wrapper') self.assertEqual((self.dct_wrapper > self.dct_wrapper_2), True) def test_le_magic_method(self): d = {0: 0.0, 1: 1.0, 2: 2.0, 3: 4.0} self.dct_wrapper_2 = DictWrapper(d, name='test_wrapper') self.assertEqual((self.dct_wrapper <= self.dct_wrapper_2), True) def test_ge_magic_method(self): d = {0: 0.0, 1: 1.0, 2: 2.0, 3: 4.0} self.dct_wrapper_2 = DictWrapper(d, name='test_wrapper') self.assertEqual((self.dct_wrapper <= self.dct_wrapper_2), True) def test_pos_magic_method(self): d = {0: 0.0, 1: 1.0, 2: 2.0, 3: 4.0} self.dct_wrapper_2 = DictWrapper(d, name='test_wrapper') self.assertEqual((+self.dct_wrapper == self.dct_wrapper_2), True) def test_neg_magic_method(self): d = {0: -0.0, 1: -1.0, 2: -2.0, 3: -4.0} self.dct_wrapper_2 = DictWrapper(d, name='test_wrapper') self.assertEqual((-self.dct_wrapper == self.dct_wrapper_2), True) def test_sub_magic_method(self): d = {0: 0.0, 1: 1.0, 2: 2.0, 3: 4.0} self.dct_wrapper_2 = DictWrapper(d, name='test_wrapper') self.assertEqual((self.dct_wrapper - self.dct_wrapper_2), DictWrapper({ 0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0 })) def test_add_magic_method(self): d = {0: 0.0, 1: -1.0, 2: -2.0, 3: -4.0} self.dct_wrapper_2 = DictWrapper(d, name='test_wrapper') self.assertEqual((self.dct_wrapper + self.dct_wrapper_2), DictWrapper({ 0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0 })) def test_mul_magic_method(self): d = {0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0} self.dct_wrapper_2 = DictWrapper(d, name='test_wrapper') self.assertEqual((self.dct_wrapper * self.dct_wrapper_2), DictWrapper({ 0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0 })) def test_div_magic_method(self): d = {0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0} self.dct_wrapper_2 = DictWrapper(d, name='test_wrapper') self.assertEqual((self.dct_wrapper_2 / self.dct_wrapper), DictWrapper({ 0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0 })) def test_mod_magic_method(self): d = {0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0} self.dct_wrapper_2 = DictWrapper(d, name='test_wrapper') self.assertEqual((self.dct_wrapper_2 % self.dct_wrapper), DictWrapper({ 0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0 })) def test_pow_magic_method(self): d = {0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0} self.dct_wrapper_2 = DictWrapper(d, name='test_wrapper') self.assertEqual((self.dct_wrapper**self.dct_wrapper_2), DictWrapper({ 0: 1.0, 1: 1.0, 2: 1.0, 3: 1.0 })) def test_copy_magic_method(self): self.assertEqual(copy.copy(self.dct_wrapper), self.dct_wrapper) def test_deepcopy_magic_method(self): self.assertEqual(copy.deepcopy(self.dct_wrapper), self.dct_wrapper) def test_items(self): self.assertEqual(self.dct_wrapper.items(), [(0, 0.0), (1, 1.0), (2, 2.0), (3, 4.0)]) def test_sort(self): self.assertEqual(self.dct_wrapper.sort(), [(0, 0.0), (1, 1.0), (2, 2.0), (3, 4.0)]) def test_sort_zip(self): self.assertEqual(self.dct_wrapper.sort_zip(), [(0, 1, 2, 3), (0.0, 1.0, 2.0, 4.0)]) def test_set(self): self.dct_wrapper[100] = 100 self.assertEqual(self.dct_wrapper[100], 100) self.dct_wrapper.set(100, 1000) self.assertEqual(self.dct_wrapper[100], 1000) def test_get(self): self.assertEqual(self.dct_wrapper[0], 0.0) self.assertEqual(self.dct_wrapper.get(0), 0.0) self.assertEqual(self.dct_wrapper.get(10000, None), None) def test_increment(self): self.assertEqual(self.dct_wrapper.increment(0), 1.0) def test_multiply(self): self.assertEqual(self.dct_wrapper.multiply(0, 1), 0.0) def test_divide(self): self.assertEqual(self.dct_wrapper.divide(0, 1), 0.0) def test_mod(self): self.assertEqual(self.dct_wrapper.mod(0, 1), 0.0) def test_is_subset(self): self.assertEqual( self.dct_wrapper.is_subset( DictWrapper({ 0: 0.0, 1: 1.0, 2: 2.0, 3: 4.0 })), True) def test_get_dict(self): self.assertEqual(self.dct_wrapper.get_dict(), { 0: 0.0, 1: 1.0, 2: 2.0, 3: 4.0 }) def test_get_values(self): self.assertEqual(self.dct_wrapper.get_keys(), [0, 1, 2, 3]) def test_get_total_entries(self): self.assertEqual(self.dct_wrapper.get_total_entries(), 7) def test_get_max_entry(self): self.assertEqual(self.dct_wrapper.get_max_entry(), 4.0) def test_get_min_entry(self): self.assertEqual(self.dct_wrapper.get_min_entry(), 0.0)
def test_neg_magic_method(self): d = {0: -0.0, 1: -1.0, 2: -2.0, 3: -4.0} self.dct_wrapper_2 = DictWrapper(d, name='test_wrapper') self.assertEqual((-self.dct_wrapper == self.dct_wrapper_2), True)
def setUp(self): d = {0:0.0,1:1.0,2:2.0,3:4.0} self.dct_wrapper = DictWrapper(d, name='test_wrapper')
class DictWrapperTest(unittest.TestCase): def setUp(self): d = {0:0.0,1:1.0,2:2.0,3:4.0} self.dct_wrapper = DictWrapper(d, name='test_wrapper') def tearDown(self): pass def test_delete_magic_method(self): del self.dct_wrapper[0] self.assertEqual(self.dct_wrapper.get(0), None) def test_getitem_magic_method(self): self.assertEqual(self.dct_wrapper[1], 1.0) def test_contains_magic_method(self): outcome = False if 1 in self.dct_wrapper: outcome = True self.assertEqual(outcome, True) def test_len_magic_method(self): self.assertEqual(len(self.dct_wrapper),4) def test_iter_magic_method(self): d = {} for k, y in self.dct_wrapper: d[k] = y self.assertEqual(self.dct_wrapper, DictWrapper(d)) def test_str_magic_method(self): self.assertEqual(str(self.dct_wrapper), "{0: 0.0, 1: 1.0, 2: 2.0, 3: 4.0}") def test_cmp_less_magic_method(self): self.assertEqual(cmp(self.dct_wrapper, DictWrapper({0:0.0,1:1.0,2:2.0,3:5.0})), -1) def test_cmp_more_magic_method(self): self.assertEqual(cmp(self.dct_wrapper, DictWrapper({0:0.0,1:1.0,2:2.0,3:3.0})), 1) def test_cmp_equal_magic_method(self): self.assertEqual(cmp(self.dct_wrapper, DictWrapper({0:0.0,1:1.0,2:2.0,3:4.0})), 0) def test_equal_magic_method(self): d = {0:0.0,1:1.0,2:2.0,3:4.0} self.dct_wrapper_2 = DictWrapper(d, name='test_wrapper') self.assertEqual((self.dct_wrapper == self.dct_wrapper_2), True) def test_ne_magic_method(self): d = {0:0.0,1:1.0,2:2.0,3:6.0} self.dct_wrapper_2 = DictWrapper(d, name='test_wrapper') self.assertEqual((self.dct_wrapper != self.dct_wrapper_2), True) def test_lt_magic_method(self): d = {0:0.0,1:1.0,2:2.0,3:6.0} self.dct_wrapper_2 = DictWrapper(d, name='test_wrapper') self.assertEqual((self.dct_wrapper < self.dct_wrapper_2), True) def test_gt_magic_method(self): d = {0:0.0,1:1.0,2:2.0,3:3.0} self.dct_wrapper_2 = DictWrapper(d, name='test_wrapper') self.assertEqual((self.dct_wrapper > self.dct_wrapper_2), True) def test_le_magic_method(self): d = {0:0.0,1:1.0,2:2.0,3:4.0} self.dct_wrapper_2 = DictWrapper(d, name='test_wrapper') self.assertEqual((self.dct_wrapper <= self.dct_wrapper_2), True) def test_ge_magic_method(self): d = {0:0.0,1:1.0,2:2.0,3:4.0} self.dct_wrapper_2 = DictWrapper(d, name='test_wrapper') self.assertEqual((self.dct_wrapper <= self.dct_wrapper_2), True) def test_pos_magic_method(self): d = {0:0.0,1:1.0,2:2.0,3:4.0} self.dct_wrapper_2 = DictWrapper(d, name='test_wrapper') self.assertEqual((+self.dct_wrapper == self.dct_wrapper_2), True) def test_neg_magic_method(self): d = {0:-0.0,1:-1.0,2:-2.0,3:-4.0} self.dct_wrapper_2 = DictWrapper(d, name='test_wrapper') self.assertEqual((-self.dct_wrapper == self.dct_wrapper_2), True) def test_sub_magic_method(self): d = {0:0.0,1:1.0,2:2.0,3:4.0} self.dct_wrapper_2 = DictWrapper(d, name='test_wrapper') self.assertEqual((self.dct_wrapper - self.dct_wrapper_2), DictWrapper({0:0.0,1:0.0,2:0.0,3:0.0})) def test_add_magic_method(self): d = {0:0.0,1:-1.0,2:-2.0,3:-4.0} self.dct_wrapper_2 = DictWrapper(d, name='test_wrapper') self.assertEqual((self.dct_wrapper + self.dct_wrapper_2), DictWrapper({0:0.0,1:0.0,2:0.0,3:0.0})) def test_mul_magic_method(self): d = {0:0.0,1:0.0,2:0.0,3:0.0} self.dct_wrapper_2 = DictWrapper(d, name='test_wrapper') self.assertEqual((self.dct_wrapper*self.dct_wrapper_2), DictWrapper({0:0.0,1:0.0,2:0.0,3:0.0})) def test_div_magic_method(self): d = {0:0.0,1:0.0,2:0.0,3:0.0} self.dct_wrapper_2 = DictWrapper(d, name='test_wrapper') self.assertEqual((self.dct_wrapper_2/self.dct_wrapper), DictWrapper({0:0.0,1:0.0,2:0.0,3:0.0})) def test_mod_magic_method(self): d = {0:0.0,1:0.0,2:0.0,3:0.0} self.dct_wrapper_2 = DictWrapper(d, name='test_wrapper') self.assertEqual((self.dct_wrapper_2%self.dct_wrapper), DictWrapper({0:0.0,1:0.0,2:0.0,3:0.0})) def test_pow_magic_method(self): d = {0:0.0,1:0.0,2:0.0,3:0.0} self.dct_wrapper_2 = DictWrapper(d, name='test_wrapper') self.assertEqual((self.dct_wrapper**self.dct_wrapper_2), DictWrapper({0:1.0,1:1.0,2:1.0,3:1.0})) def test_copy_magic_method(self): self.assertEqual(copy.copy(self.dct_wrapper), self.dct_wrapper) def test_deepcopy_magic_method(self): self.assertEqual(copy.deepcopy(self.dct_wrapper), self.dct_wrapper) def test_items(self): self.assertEqual(self.dct_wrapper.items(), [(0, 0.0), (1, 1.0), (2, 2.0), (3, 4.0)]) def test_sort(self): self.assertEqual(self.dct_wrapper.sort(), [(0, 0.0), (1, 1.0), (2, 2.0), (3, 4.0)]) def test_sort_zip(self): self.assertEqual(self.dct_wrapper.sort_zip(), [(0, 1, 2, 3), (0.0, 1.0, 2.0, 4.0)]) def test_set(self): self.dct_wrapper[100] = 100 self.assertEqual(self.dct_wrapper[100], 100) self.dct_wrapper.set(100, 1000) self.assertEqual(self.dct_wrapper[100], 1000) def test_get(self): self.assertEqual(self.dct_wrapper[0], 0.0) self.assertEqual(self.dct_wrapper.get(0), 0.0) self.assertEqual(self.dct_wrapper.get(10000, None), None) def test_increment(self): self.assertEqual(self.dct_wrapper.increment(0), 1.0) def test_multiply(self): self.assertEqual(self.dct_wrapper.multiply(0,1), 0.0) def test_divide(self): self.assertEqual(self.dct_wrapper.divide(0,1), 0.0) def test_mod(self): self.assertEqual(self.dct_wrapper.mod(0,1), 0.0) def test_is_subset(self): self.assertEqual(self.dct_wrapper.is_subset(DictWrapper({0:0.0,1:1.0,2:2.0,3:4.0})), True) def test_get_dict(self): self.assertEqual(self.dct_wrapper.get_dict(), {0:0.0,1:1.0,2:2.0,3:4.0}) def test_get_values(self): self.assertEqual(self.dct_wrapper.get_keys(), [0,1,2,3]) def test_get_total_entries(self): self.assertEqual(self.dct_wrapper.get_total_entries(), 7) def test_get_max_entry(self): self.assertEqual(self.dct_wrapper.get_max_entry(),4.0) def test_get_min_entry(self): self.assertEqual(self.dct_wrapper.get_min_entry(),0.0)