Sha256: df463182f32c3954d991f6e4d80bd8a4c9e962fbe97822af6bcd4648cd8212fe

Contents?: true

Size: 1.84 KB

Versions: 112

Compression:

Stored size: 1.84 KB

Contents

import unittest

from anagram import detect_anagrams


class AnagramTests(unittest.TestCase):
    def test_no_matches(self):
        self.assertEqual(
            [],
            detect_anagrams('diaper', 'hello world zombies pants'.split())
        )

    def test_detect_simple_anagram(self):
        self.assertEqual(
            ['tan'],
            detect_anagrams('ant', 'tan stand at'.split())
        )

    def test_detect_multiple_anagrams(self):
        self.assertEqual(
            ['stream', 'maters'],
            detect_anagrams('master', 'stream pigeon maters'.split())
        )

    def test_does_not_confuse_different_duplicates(self):
        self.assertEqual(
            [],
            detect_anagrams('galea', ['eagle'])
        )

    def test_eliminate_anagram_subsets(self):
        self.assertEqual(
            [],
            detect_anagrams('good', 'dog goody'.split())
        )

    def test_detect_anagram(self):
        self.assertEqual(
            ['inlets'],
            detect_anagrams('listen', 'enlists google inlets banana'.split())
        )

    def test_multiple_anagrams(self):
        self.assertEqual(
            'gallery regally largely'.split(),
            detect_anagrams(
                'allergy',
                'gallery ballerina regally clergy largely leading'.split()
            )
        )

    def test_anagrams_are_case_insensitive(self):
        self.assertEqual(
            ['Carthorse'],
            detect_anagrams('Orchestra',
                            'cashregister Carthorse radishes'.split())
        )

    def test_same_word_isnt_anagram(self):
        self.assertEqual(
            [],
            detect_anagrams('banana', ['banana'])
        )

        self.assertEqual(
            [],
            detect_anagrams('go', 'go Go GO'.split())
        )


if __name__ == '__main__':
    unittest.main()

Version data entries

112 entries across 112 versions & 1 rubygems

Version Path
trackler-2.0.8.38 tracks/python/exercises/anagram/anagram_test.py
trackler-2.0.8.37 tracks/python/exercises/anagram/anagram_test.py
trackler-2.0.8.36 tracks/python/exercises/anagram/anagram_test.py
trackler-2.0.8.35 tracks/python/exercises/anagram/anagram_test.py
trackler-2.0.8.34 tracks/python/exercises/anagram/anagram_test.py
trackler-2.0.8.33 tracks/python/exercises/anagram/anagram_test.py
trackler-2.0.8.32 tracks/python/exercises/anagram/anagram_test.py
trackler-2.0.8.31 tracks/python/exercises/anagram/anagram_test.py
trackler-2.0.8.30 tracks/python/exercises/anagram/anagram_test.py
trackler-2.0.8.29 tracks/python/exercises/anagram/anagram_test.py
trackler-2.0.8.28 tracks/python/exercises/anagram/anagram_test.py
trackler-2.0.8.27 tracks/python/exercises/anagram/anagram_test.py
trackler-2.0.8.26 tracks/python/exercises/anagram/anagram_test.py
trackler-2.0.8.24 tracks/python/exercises/anagram/anagram_test.py
trackler-2.0.8.23 tracks/python/exercises/anagram/anagram_test.py
trackler-2.0.8.22 tracks/python/exercises/anagram/anagram_test.py
trackler-2.0.8.21 tracks/python/exercises/anagram/anagram_test.py
trackler-2.0.8.20 tracks/python/exercises/anagram/anagram_test.py
trackler-2.0.8.19 tracks/python/exercises/anagram/anagram_test.py
trackler-2.0.8.18 tracks/python/exercises/anagram/anagram_test.py