def test_inequality_masks_with_same_punched_pattern_are_equal_but_not_case_D( self): """case_D: if their Mask.generic_solid_repr was changed between instance creation""" Mask.generic_solid_repr = '*' mask_case_d__0_1_0 = Mask(size=3) mask_case_d__0_1_0._punch_mask([False, True, False]) self.assertTrue(self.mask1__0_1_0 != mask_case_d__0_1_0)
class TestMaskBase(unittest.TestCase): """Shared setUp() and tearDown() for Mask tests""" def setUp(self): self.blank_that_remains_blank = Mask(size=12) self.blank_ready_to_punch = Mask(size=12) self.mask1__0_1_0 = Mask(size=3) self.mask1__0_1_0._punch_mask([False, True, False]) self.mask2__0_1_0 = Mask(size=3) self.mask2__0_1_0._punch_mask([False, True, False]) # all instances of Mask created below, but within setUp() require # protected access to inject values and avoid using the methods # of Mask or the Mask factories to build self.all_punched_mask = Mask(size=12) self.all_punched_mask._mask = tuple(PUNCHED for _ in range(12)) # the two following instances are 'negative' of each other and # can be compared via the invert() method self.even_are_punched = Mask(size=12) self.even_are_punched._mask = tuple(SOLID if pos % 2 else PUNCHED for pos in range(12)) self.odd_are_punched = Mask(size=12) self.odd_are_punched._mask = tuple(PUNCHED if pos % 2 else SOLID for pos in range(12)) def tearDown(self): # a hacky fix for the changes of class variable values that create problems in tests: Mask.generic_punched_repr = _STANDARD_PUNCHED_REPR Mask.generic_solid_repr = _STANDARD_SOLID_REPR
def test_inequality_masks_with_same_punched_pattern_are_equal_in_case_F( self): """case_F: if Mask.generic_solid_repr was changed before the two instance compared are created""" Mask.generic_solid_repr = '*' mask_case_f1__0_1_0 = Mask(size=3) mask_case_f1__0_1_0._punch_mask([False, True, False]) mask_case_f2__0_1_0 = Mask(size=3) mask_case_f2__0_1_0._punch_mask([False, True, False]) self.assertFalse(mask_case_f1__0_1_0 != mask_case_f2__0_1_0)