def test_should_revert_state_after_pop(self): canvas = Canvas() set_state(canvas, STATE_1) canvas.push_state() set_state(canvas, STATE_2) canvas.pop_state() assert_same(self, STATE_1, get_state(canvas))
def test_should_apply_old_state_after_pop(self, mock_stroke_apply, mock_fill_apply): # given canvas = Canvas() set_state(canvas, STATE_1) canvas.push_state() set_state(canvas, STATE_2) # when canvas.pop_state() # then self.assertTrue(mock_stroke_apply.called) self.assertTrue(mock_fill_apply.called)
def test_should_make_deep_copies_on_push(self): canvas = Canvas() old_stroke = id(canvas.stroke) old_fill = id(canvas.fill) old_font = id(canvas.font) canvas.push_state() new_stroke = id(canvas.stroke) new_fill = id(canvas.fill) new_font = id(canvas.font) self.assertNotEqual(old_stroke, new_stroke) self.assertNotEqual(old_fill, new_fill) self.assertNotEqual(old_font, new_font)
def test_should_retain_same_state_after_push(self, mock_stroke_apply, mock_fill_apply): canvas = Canvas() canvas.push_state() self.assertTrue(mock_stroke_apply.called) self.assertTrue(mock_fill_apply.called)