Example #1
0
 def testReadNotEmptyFile(self):
     uniq = Uniq(FILE_INPUT_NAME, FILE_OUTPUT_NAME)
     with open(uniq.input_path, "w+") as input_file:
         input_file.write('A\n')
         input_file.write("A\n")
         input_file.write("A")
     self.assertEqual(["A", "A", "A"], uniq._getlines())
Example #2
0
 def testCountWithRepeatUnique(self):
     uniq = Uniq(FILE_INPUT_NAME, FILE_OUTPUT_NAME)
     self.assertEqual(['1 A'], uniq._filter({'A': 1, 'a': 2}, count=True, unique=True))
Example #3
0
 def testCountWithoutArgs(self):
     uniq = Uniq(FILE_INPUT_NAME, FILE_OUTPUT_NAME)
     self.assertEqual(['A', 'a'], uniq._filter({'A': 1, 'a': 2}))
Example #4
0
 def testCountWithIgnoreAndUPletter(self):
     uniq = Uniq(FILE_INPUT_NAME, FILE_OUTPUT_NAME)
     self.assertEqual({'a': 3}, uniq._countWords(['A', 'a', 'a'], True))
Example #5
0
 def testCountWithoutIgnoreAndUPletter(self):
     uniq = Uniq(FILE_INPUT_NAME, FILE_OUTPUT_NAME)
     self.assertEqual({'A': 1, 'a': 2}, uniq._countWords(['A', 'a', 'a']))
Example #6
0
 def testCountWithOneStringWithoutIgnore(self):
     uniq = Uniq(FILE_INPUT_NAME, FILE_OUTPUT_NAME)
     self.assertEqual({'a': 3}, uniq._countWords(['a', 'a', 'a']))
Example #7
0
 def testPrintNotEmtyString(self):
     uniq = Uniq(FILE_INPUT_NAME, FILE_OUTPUT_NAME)
     uniq._printWords(['a', 'b', 'c'])
     with open(FILE_OUTPUT_NAME, "r") as input_file:
         words = input_file.read().split('\n')
     self.assertEqual(['a', 'b', 'c'], words)