From 0ea10418cd7492f0ce4a79b74ea6be9db88d6df9 Mon Sep 17 00:00:00 2001 From: M Powers <1647084+roadfoodr@users.noreply.github.com> Date: Wed, 19 Jun 2019 09:41:33 -0400 Subject: [PATCH] Anagram: relax test requirement for ordered elements (#1828) * Anagram: relax test requirement for ordered elements * Anagram: update tests to v1.4.1 --- exercises/anagram/anagram_test.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/exercises/anagram/anagram_test.py b/exercises/anagram/anagram_test.py index 2e6a0260b7..806545f4e8 100644 --- a/exercises/anagram/anagram_test.py +++ b/exercises/anagram/anagram_test.py @@ -2,8 +2,12 @@ from anagram import find_anagrams +# Python 2/3 compatibility +if not hasattr(unittest.TestCase, 'assertCountEqual'): + unittest.TestCase.assertCountEqual = unittest.TestCase.assertItemsEqual -# Tests adapted from `problem-specifications//canonical-data.json` @ v1.4.0 + +# Tests adapted from `problem-specifications//canonical-data.json` @ v1.4.1 class AnagramTest(unittest.TestCase): def test_no_matches(self): @@ -12,7 +16,7 @@ def test_no_matches(self): def test_detects_two_anagrams(self): candidates = ["stream", "pigeon", "maters"] - self.assertEqual( + self.assertCountEqual( find_anagrams("master", candidates), ["stream", "maters"]) def test_does_not_detect_anagram_subsets(self): @@ -26,7 +30,7 @@ def test_detects_three_anagrams(self): candidates = [ "gallery", "ballerina", "regally", "clergy", "largely", "leading" ] - self.assertEqual( + self.assertCountEqual( find_anagrams("allergy", candidates), ["gallery", "regally", "largely"]) @@ -48,7 +52,7 @@ def test_detects_anagrams_using_case_insensitive_possible_matches(self): self.assertEqual( find_anagrams("orchestra", candidates), ["Carthorse"]) - def test_does_not_detect_a_anagram_if_the_original_word_is_repeated(self): + def test_does_not_detect_an_anagram_if_the_original_word_is_repeated(self): self.assertEqual(find_anagrams("go", ["go Go GO"]), []) def test_anagrams_must_use_all_letters_exactly_once(self):