def test_closing(self): from bobtools.io import JSONL filename = "test_tmpfile" if os.path.exists(filename): os.remove(filename) jsonl = JSONL(filename) self.assertTrue(os.path.exists(filename)) self.assertEqual(jsonl.closed(), False) jsonl.close() self.assertEqual(jsonl.closed(), True) os.remove(filename)
def test_print_on_exit(self): from bobtools.io import JSONL filename = "test_tmpfile" if os.path.exists(filename): os.remove(filename) JSONL.__repr__ = unittest.mock.Mock(return_value="repr_test") jsonl = JSONL(filename, print_on_exit=True) with jsonl: pass self.assertTrue(jsonl.closed())