def test_clean_file_opened(self): """Tests utils.clean_file() with a stringIO object.""" string_io = io.StringIO(u'Mary had a little lamb') f, opened = utils.clean_file(string_io) assert hasattr(f, 'read') assert not opened # Closing stringIO after test assertions. f.close()
def test_clean_file_opened(self): """Tests utils.clean_file() with a stringIO object.""" string_io = io.StringIO(u'Mary had a little lamb') f, opened = utils.clean_file(string_io) self.assertEqual(hasattr(f, 'read'), True) self.assertEqual(opened, False) # Closing stringIO after test assertions. f.close()
def test_clean_file_opened(self): """Tests utils.clean_file() with a stringIO object.""" string_io = io.StringIO(u'Mary had a little lamb') f, opened = utils.clean_file(string_io) self.assertEqual(hasattr(f, 'read'), True) self.assertEqual(opened, False) # Closing stringIO after test assertions. f.close()
def test_clean_file_unopened(self): """Tests utils.clean_file() with a 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") f, opened = utils.clean_file(path) assert hasattr(f, 'read') assert opened # Closing file after test assertions. f.close()
def test_clean_file_unopened(self): """Tests utils.clean_file() with a 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") f, opened = utils.clean_file(path) self.assertEqual(hasattr(f, 'read'), True) self.assertEqual(opened, True) # Closing file after test assertions. f.close()