import unittest
import os

from main import generate_files, generate_output, get_sub_sequences

class FileGenerationTest(unittest.TestCase):
    def setUp(self):
        # Make sure the expected files don't exist yet
        for fname in ["test_sequences", "test_words"]:
            if os.path.exists(fname):
                os.remove(fname)

    def test_files_created(self):
        """
        Tests that output files are generated.
        """
        # For simplicity this will be the only I/O based test.
        # For other tests we can use output generation functions.

        self.assertFalse(os.path.exists("test_sequences"))
        self.assertFalse(os.path.exists("test_words"))
        generate_files([], sequences_fname="test_sequences", words_fname="test_words")
        self.assertTrue(os.path.exists("test_sequences"))
        self.assertTrue(os.path.exists("test_words"))

    def tearDown(self):
        # So as not to leave a mess
        for fname in ["test_sequences", "test_words"]:
            if os.path.exists(fname):
                os.remove(fname)

class OutputGenerationHelperTest(unittest.TestCase):

    def test_get_sub_sequences_empty(self):
        self.assertEqual(list(get_sub_sequences("")), [])

    def test_get_sub_sequences_short(self):
        self.assertEqual(list(get_sub_sequences("hi")), [])

    def test_get_sub_sequences_single(self):
        self.assertEqual(list(get_sub_sequences("cows")), ["cows"])

    def test_get_sub_sequences_multiple(self):
        # Tests decapitalization of letters, and non-skipping of repeat sequences
        expected_output = ["miss", "issi", "ssis", "siss", "issi", "ssip", "sipp", "ippi"]
        self.assertEqual(list(get_sub_sequences("Mississippi")), expected_output)

class OutputGenerationTest(unittest.TestCase):
    def test_empty_input(self):
        self.assertEqual(generate_output([]), set([]))

    def test_single_word(self):
        # Tests decapitalization of letters, and non-skipping of repeat sequences
        self.assertEqual(generate_output(["Mississippi"]), {
            ("ippi", "Mississippi"),
            ("issi", "Mississippi"),
            ("miss", "Mississippi"),
            ("sipp", "Mississippi"),
            ("siss", "Mississippi"),
            ("ssip", "Mississippi"),
            ("ssis", "Mississippi"),
        })

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

@@ -1496,33 +1496,43 @@
 (self):%0A        
-#
+%22%22%22%0A       
  Tests decapital
@@ -1580,32 +1580,45 @@
 epeat sequences%0A
+        %22%22%22%0A%0A
         expected
@@ -1950,17 +1950,27 @@
         
-#
+%22%22%22%0A       
  Tests d
@@ -2001,32 +2001,33 @@
 rs, and non-
-skipping
+exclusion
  of repeat s
@@ -2016,32 +2016,40 @@
 lusion of repeat
+%0A       
  sequences%0A     
@@ -2034,32 +2034,60 @@
        sequences
+ within one word%0A        %22%22%22
 %0A        self.as

Test docstrings