Skip to content

Commit

Permalink
Use temporary directories for save tests.
Browse files Browse the repository at this point in the history
Organize test saves a bit more.
  • Loading branch information
chennin committed Dec 23, 2023
1 parent cb6cabc commit 84349eb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions test/parser_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest
import pathlib
from rust_parser import rust_parser

import parser_test_cases
Expand All @@ -24,12 +25,21 @@ def test_deep_recursion_depth():
)
rust_parser.parse_save_from_string(test_input)


def test_real_save():
@pytest.mark.parametrize(
"save_dir",
[path for path in pathlib.Path(__file__).parent.glob(r"saves/*")],
ids=lambda path: path.stem,
)
def test_real_save(save_dir, tmp_path):
# Test a real save end to end
from stellarisdashboard import cli, config
from pathlib import Path
cli.f_parse_saves(save_path="test/saves")
output_db_dir = Path(f"{config.CONFIG.base_output_path}/db")
for db in list(output_db_dir.glob('*.db')):
db.unlink(missing_ok=True)
debug = config.CONFIG.debug_mode
base_path = config.CONFIG.base_output_path

config.CONFIG.debug_mode = True
config.CONFIG.base_output_path = tmp_path
try:
cli.f_parse_saves(save_path=save_dir)
finally:
config.CONFIG.debug_mode = debug
config.CONFIG.base_output_path = base_path

0 comments on commit 84349eb

Please sign in to comment.