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())
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))
def testCountWithoutArgs(self): uniq = Uniq(FILE_INPUT_NAME, FILE_OUTPUT_NAME) self.assertEqual(['A', 'a'], uniq._filter({'A': 1, 'a': 2}))
def testCountWithIgnoreAndUPletter(self): uniq = Uniq(FILE_INPUT_NAME, FILE_OUTPUT_NAME) self.assertEqual({'a': 3}, uniq._countWords(['A', 'a', 'a'], True))
def testCountWithoutIgnoreAndUPletter(self): uniq = Uniq(FILE_INPUT_NAME, FILE_OUTPUT_NAME) self.assertEqual({'A': 1, 'a': 2}, uniq._countWords(['A', 'a', 'a']))
def testCountWithOneStringWithoutIgnore(self): uniq = Uniq(FILE_INPUT_NAME, FILE_OUTPUT_NAME) self.assertEqual({'a': 3}, uniq._countWords(['a', 'a', 'a']))
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)