Skip to content

Commit

Permalink
Modify saving dir to avoid error.
Browse files Browse the repository at this point in the history
  • Loading branch information
DavdGao committed Feb 5, 2024
1 parent 7824172 commit 14881e5
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions tests/logger_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
""" Unit test for logger chat"""
import os
import shutil
import time
import unittest
Expand All @@ -14,10 +15,14 @@ class LoggerTest(unittest.TestCase):
Unit test for logger.
"""

def setUp(self):
"""Setup for unit test."""
self.run_dir = "./logger_runs/"

def test_logger_chat(self) -> None:
"""Logger chat."""

setup_logger("./runs/", level="INFO")
setup_logger(self.run_dir, level="INFO")

# str with "\n"
logger.chat("Test\nChat\n\nMessage\n\n")
Expand All @@ -40,7 +45,9 @@ def test_logger_chat(self) -> None:
# To avoid that logging is not finished before the file is read
time.sleep(3)

with open("./runs/logging.chat", "r", encoding="utf-8") as file:
with open(os.path.join(self.run_dir, "logging.chat"),
"r",
encoding="utf-8") as file:
lines = file.readlines()

ground_truth = [
Expand All @@ -55,7 +62,7 @@ def test_logger_chat(self) -> None:

def tearDown(self) -> None:
"""Tear down for LoggerTest."""
shutil.rmtree("./runs/")
shutil.rmtree(self.run_dir)


if __name__ == "__main__":
Expand Down

0 comments on commit 14881e5

Please sign in to comment.