def test_clean_files_single(self): """Tests utils.clean_files() with a singular filepath. This test relies on the openability of the file 'fsdfgh' located in 'test/functional/fake_dir'. """ path = os.path.join(os.path.dirname(__file__), "..", "functional", "fake_dir", "fsdfgh") gen = utils.clean_files(path) for tup in gen: assert hasattr(tup[0], 'read') assert tup[1] # Closing file after test assertions. tup[0].close()
def test_clean_files_single(self): """Tests utils.clean_files() with a singular filepath. This test relies on the openability of the file 'fsdfgh' located in 'test/functional/fake_dir'. """ path = os.path.join(os.path.dirname(__file__), "..", "functional", "fake_dir", "fsdfgh") gen = utils.clean_files(path) for tup in gen: self.assertEqual(hasattr(tup[0], 'read'), True) self.assertEqual(tup[1], True) # Closing file after test assertions. tup[0].close()
def test_clean_files_list(self): """Tests utils.clean_files() with a list of files/stringIO objects.""" path = os.path.join(os.path.dirname(__file__), "..", "functional", "fake_dir", "fsdfgh") string_io = io.StringIO(u'Mary had a little lamb') files = [path, string_io] gen = utils.clean_files(files) for i in range(0, 2): tup = next(gen) assert hasattr(tup[0], 'read') if i == 0: assert tup[1] else: assert not tup[1] # Closing files/stringIO objects after test assertions. tup[0].close()
def test_clean_files_list(self): """Tests utils.clean_files() with a list of files/stringIO objects.""" path = os.path.join(os.path.dirname(__file__), "..", "functional", "fake_dir", "fsdfgh") string_io = io.StringIO(u'Mary had a little lamb') files = [path, string_io] gen = utils.clean_files(files) for i in range(0, 2): tup = next(gen) self.assertEqual(hasattr(tup[0], 'read'), True) if i == 0: self.assertEqual(tup[1], True) else: self.assertEqual(tup[1], False) # Closing files/stringIO objects after test assertions. tup[0].close()