class TokenDeepCopyTests(TokenBaseTests): def setUp(self): super().setUp() self.history_copy = list(self.history) self.words_copy = list(self.words) self.token = Token(self.score, self.history_copy, self.words_copy ) def modify_token_content(self, token): token.history.append(40) token.words.append(3) def did_not_changed(self): self.assertEqual(self.history, self.history_copy) self.assertEqual(self.words, self.words_copy) def test_update_score_create_deep_copy(self): token = self.token.update_score(10) self.modify_token_content(token) self.did_not_changed() def test_update_history_create_deep_copy(self): token = self.token.update_history(10) self.modify_token_content(token) self.did_not_changed() def test_update_words_create_deep_copy(self): token = self.token.update_words(10) self.modify_token_content(token) self.did_not_changed()
def test_update_score(self): token = Token(self.score, self.history) res = token.update_score(5) self.assertEqual(Token(self.score + 5, self.history), res) self.assertEqual(Token(self.score, self.history), token)