Skip to content

Commit

Permalink
Use tempfile for temporary directory in tests. (#708)
Browse files Browse the repository at this point in the history
  • Loading branch information
tjni committed Jul 16, 2023
1 parent a7013c3 commit c015fea
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tests/test_summary_writer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from tensorboardX import SummaryWriter
import tempfile
import unittest


Expand All @@ -9,9 +10,10 @@ def test_summary_writer_ctx(self):
writer.add_scalar('test', 1)
assert writer.file_writer is None

def test_summary_writer_backcomapt(self):
with SummaryWriter(log_dir='/tmp/tbxtest') as writer:
writer.add_scalar('test', 1)
def test_summary_writer_backcompat(self):
with tempfile.TemporaryDirectory() as tmp_dir:
with SummaryWriter(log_dir=tmp_dir) as writer:
writer.add_scalar('test', 1)

def test_summary_writer_close(self):
# Opening and closing SummaryWriter a lot should not run into
Expand Down

0 comments on commit c015fea

Please sign in to comment.