def test_validate(self): import anagrams for test_input1, test_input2, test_output in TestAnagrams.test_cases: with self.subTest(i=(test_input1, test_input2)): self.assertEqual(anagrams.is_anagram(test_input1, test_input2), test_output) self.assertEqual(anagrams.is_anagram(test_input2, test_input1), test_output)
def test(self): self.assertEqual(is_anagram(self.test1[0], self.test1[1]), self.test1[2]) self.assertEqual(is_anagram(self.test2[0], self.test2[1]), self.test2[2]) self.assertEqual(is_anagram(self.test3[0], self.test3[1]), self.test3[2]) self.assertEqual(is_anagram(self.test4[0], self.test4[1]), self.test4[2]) self.assertEqual(is_anagram(self.test5[0], self.test5[1]), self.test5[2])
def test_is_anagram_false(): eq_(anagrams.is_anagram("a", "b"), False)
def test_is_anagram(): eq_(anagrams.is_anagram("abc", "cba"), True)
def test_is_anagram_multiple_letter_the_same(): eq_(anagrams.is_anagram("aa", "aaa"), False)
def test_is_anagram_false_different_capitalization(): eq_(anagrams.is_anagram("A", "a"), False)
def test_different_lengths(self): self.assertFalse(is_anagram("tea", "treat"))
def test_is_anagram(self): self.assertEqual(is_anagram(self.s1, self.s2), True)
def test_punctuation_ignored(self): phrase1 = "A diet" phrase2 = "I'd eat" self.assertTrue(is_anagram(phrase1, phrase2))
def test_spaces_ignored(self): phrase1 = "William Shakespeare" phrase2 = "I am a weakish speller" self.assertTrue(is_anagram(phrase1, phrase2)) self.assertTrue(is_anagram("a b c", "a b d"))
def test_different_capitalization(self): self.assertTrue(is_anagram("Trey", "Yert")) self.assertTrue(is_anagram("Listen", "silent"))
def test_same_letters_different_lengths(self): self.assertFalse(is_anagram("sinks", "skin"))
def test_sink_skin(self): self.assertTrue(is_anagram("sink", "skin"))
def test_is_anagram(self): self.assertEqual(anagrams.is_anagram("listen", "silent"), True) self.assertEqual(anagrams.is_anagram("aabcd", "dabac"), True) self.assertEqual(anagrams.is_anagram("cat", "dog"), False) self.assertEqual(anagrams.is_anagram(115, 115), False) self.assertEqual(anagrams.is_anagram("lol115", "lol115"), False)
def test_short_anagram(self): self.assertTrue(is_anagram("tea", "eat"))
def test_is_anagram(): bool = is_anagram('python', 'thynop') assert bool == True