コード例 #1
0
    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)
コード例 #2
0
    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)
コード例 #3
0
    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")
コード例 #4
0
    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")
コード例 #5
0
    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")
コード例 #6
0
    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')
コード例 #7
0
    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")
コード例 #8
0
 def test_close_objects_with_none(self):
     self.assertIsNone(_close_objects(None, None))
コード例 #9
0
 def test_close_objects_with_none(self):
     self.assertIsNone(_close_objects(None, None))