def test_cursor_reset(self): """Test that opening a file object if it's already open resets the cursor to 0.""" real_file_obj = open(__file__) self.assertEqual(real_file_obj.tell(), 0) f = open_file(real_file_obj) # shouldn't raise self.assertEqual(f.tell(), 0) f2 = open_file(f) # also shouldn't raise on previously-read file self.assertEqual(f2.tell(), 0)
def test_open_file_obj(self): real_file_obj = open(__file__) f = open_file(real_file_obj) # shouldn't raise f2 = open_file(f) # also shouldn't raise on previously-read file
def test_open_file_str(self): not_a_file = "file" self.assertRaises(FileNotFoundError, open_file, not_a_file) real_file = __file__ f = open_file(real_file) # shouldn't raise