Skip to content

Commit

Permalink
Anagram: relax test requirement for ordered elements (#1828)
Browse files Browse the repository at this point in the history
* Anagram: relax test requirement for ordered elements

* Anagram: update tests to v1.4.1
  • Loading branch information
roadfoodr authored and cmccandless committed Jun 19, 2019
1 parent 88cd48b commit 0ea1041
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions exercises/anagram/anagram_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand All @@ -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"])

Expand All @@ -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):
Expand Down

0 comments on commit 0ea1041

Please sign in to comment.