Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anagram: relax test requirement for ordered elements #1828

Merged
merged 4 commits into from
Jun 19, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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