def test_close_objects_with_tqdm(self): pbar_1 = tqdm(range(5)) pbar_2 = tqdm(total=10, desc="hi", file=io.StringIO()) self.assertFalse(pbar_1.disable) self.assertFalse(pbar_2.disable) _close_objects(pbar_1, pbar_2) self.assertTrue(pbar_1.disable) self.assertTrue(pbar_2.disable)
def test_close_objects_with_tqdm(self): pbar_1 = tqdm(range(5)) pbar_2 = tqdm(total=10, desc="hi", file=io.StringIO()) self.assertFalse(pbar_1.disable) self.assertFalse(pbar_2.disable) _close_objects(pbar_1, pbar_2) self.assertTrue(pbar_1.disable) self.assertTrue(pbar_2.disable)
def test_close_objects_with_different_objects(self): file = open("to_delete_1", "w") pbar = tqdm(range(5)) num = 5 empty = None word = "hi" _close_objects(file, pbar, num, empty, word) self.assertTrue(pbar.disable) self.assertTrue(file.closed) os.remove("to_delete_1")
def test_close_objects_with_different_objects(self): file = open("to_delete_1", "w") pbar = tqdm(range(5)) num = 5 empty = None word = "hi" _close_objects(file, pbar, num, empty, word) self.assertTrue(pbar.disable) self.assertTrue(file.closed) os.remove("to_delete_1")
def test_close_objects_with_file_objs(self): f1 = open("to_delete_1", "w") f2 = open("to_delete_2", "w") f2.close() f2 = open("to_delete_2", "r") self.assertFalse(f1.closed) self.assertFalse(f2.closed) _close_objects(f1, f2) self.assertTrue(f1.closed) self.assertTrue(f2.closed) os.remove("to_delete_1") os.remove("to_delete_2")
def test_close_objects_with_file_objs(self): f1 = open('to_delete_1', 'w') f2 = open('to_delete_2', 'w') f2.close() f2 = open('to_delete_2', 'r') self.assertFalse(f1.closed) self.assertFalse(f2.closed) _close_objects(f1, f2) self.assertTrue(f1.closed) self.assertTrue(f2.closed) os.remove('to_delete_1') os.remove('to_delete_2')
def test_close_objects_with_file_objs(self): f1 = open("to_delete_1", "w") f2 = open("to_delete_2", "w") f2.close() f2 = open("to_delete_2", "r") self.assertFalse(f1.closed) self.assertFalse(f2.closed) _close_objects(f1, f2) self.assertTrue(f1.closed) self.assertTrue(f2.closed) os.remove("to_delete_1") os.remove("to_delete_2")
def test_close_objects_with_none(self): self.assertIsNone(_close_objects(None, None))
def test_close_objects_with_none(self): self.assertIsNone(_close_objects(None, None))