File size: 683 Bytes
a9a0ec2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import os
import tempfile
import unittest

from detectron2.utils.events import TensorboardXWriter


# TODO Fix up capitalization
class TestTensorboardXWriter(unittest.TestCase):
    def test_no_files_created(self) -> None:
        with tempfile.TemporaryDirectory() as tmp_dir:
            writer = TensorboardXWriter(tmp_dir)
            writer.close()

            self.assertFalse(os.listdir(tmp_dir))

    def test_single_write(self) -> None:
        with tempfile.TemporaryDirectory() as tmp_dir:
            writer = TensorboardXWriter(tmp_dir)
            writer._writer.add_scalar("testing", 1, 1)
            writer.close()

            self.assertTrue(os.listdir(tmp_dir))