Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
SAKURA-CAT committed Sep 20, 2024
1 parent f5d0c79 commit 187af23
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions test/unit/data/run/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ def test_log_text_ok(self):
# list
ll3 = run.log({"a": [Text("abc"), Text("def")]})
assert ll3["a"].data == ["abc", "def"]
data = {"a": [Text("abc")] * 109}
ll4 = run.log(data, step=4)
assert ll4["a"].data == ["abc"] * 108

# ---------------------------------- 解析log Audio ----------------------------------

Expand Down
12 changes: 12 additions & 0 deletions test/unit/log/test_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,18 @@ def test_write_to_file(self):
assert content[-2] == a + "\n"
assert content[-1] == b + "\n"

def test_write_to_file_long_test(self):
console_dir = self.create_console_dir()
swanlog.install(console_dir)
# 加一行防止其他问题
print("\ntest write to file")
a = generate(size=201)
print(a)
files = os.listdir(console_dir)
with open(os.path.join(console_dir, files[0]), "r") as f:
content = f.readlines()
assert content[-1] == a[:200] + "\n"

def test_write_logging_to_file(self):
console_dir = self.create_console_dir()
swanlog.install(console_dir, log_level="debug")
Expand Down

0 comments on commit 187af23

Please sign in to comment.