Example #1
0
 def test_read_file_lines(self):
     """
     Test the function read_file_lines
     """
     test_tools_file = os.path.abspath(__file__)
     test_directory = os.path.dirname(test_tools_file)
     non_existing_file = os.path.join(test_directory, "nonExistingFile")
     self.assertIsNotNone(tools.read_file_lines(test_tools_file))
     self.assertIsNone(tools.read_file_lines(non_existing_file))
Example #2
0
 def test_read_file_lines(self):
     """
     Test the function read_file_lines
     """
     test_tools_file = os.path.abspath(__file__)
     test_directory = os.path.dirname(test_tools_file)
     non_existing_file = os.path.join(test_directory, "nonExistingFile")
     self.assertIsNotNone(tools.read_file_lines(test_tools_file))
     self.assertIsNone(tools.read_file_lines(non_existing_file))
Example #3
0
    def test_read_file_lines(self):
        """
        Test the function read_file_lines
        """
        test_tools_file = os.path.abspath(__file__)
        test_directory = os.path.dirname(test_tools_file)
        non_existing_file = os.path.join(test_directory, "nonExistingFile")

        output = tools.read_file_lines(test_tools_file)
        self.assertIsInstance(output, list)
        self.assertGreaterEqual(len(output), 1)
        self.assertIsInstance(output[0], str)
        self.assertIsNone(tools.read_file_lines(non_existing_file))

        with NamedTemporaryFile('wt') as tmp:
            tmp.write('foo\nbar')
            tmp.flush()
            self.assertIsInstance(tools.read_file_lines(tmp.name), list)
            self.assertListEqual(tools.read_file_lines(tmp.name), ['foo', 'bar'])

        tmp_gz = NamedTemporaryFile().name
        with gzip.open(tmp_gz + '.gz', 'wt') as f:
            f.write('foo\nbar')
            f.flush()
        self.assertIsInstance(tools.read_file_lines(tmp_gz), list)
        self.assertEqual(tools.read_file_lines(tmp_gz), ['foo', 'bar'])
        os.remove(tmp_gz+ '.gz')