29 lines
894 B
Python
29 lines
894 B
Python
|
|
import doomcc.doom_base
|
||
|
|
import os
|
||
|
|
import pathlib
|
||
|
|
import pytest
|
||
|
|
import tempfile
|
||
|
|
|
||
|
|
class Workbench:
|
||
|
|
pass
|
||
|
|
|
||
|
|
def test_demo_in_path():
|
||
|
|
w = Workbench()
|
||
|
|
w.demo_in_path = lambda: doomcc.doom_base.WadMap.demo_in_path(w)
|
||
|
|
w._file_base = lambda path: doomcc.doom_base.WadMap._file_base(w, path)
|
||
|
|
w.wad = pathlib.Path("scythe")
|
||
|
|
w.map = "01"
|
||
|
|
w.name_string = "_index"
|
||
|
|
w._name = "index"
|
||
|
|
with tempfile.TemporaryDirectory() as td:
|
||
|
|
w.demos = pathlib.Path(td)
|
||
|
|
with pytest.raises(Exception):
|
||
|
|
w.demo_in_path()
|
||
|
|
|
||
|
|
dp = pathlib.Path(td).joinpath("scythe")
|
||
|
|
os.mkdir(dp)
|
||
|
|
dp.joinpath("scythe_map01_index.lmp").touch()
|
||
|
|
assert w.demo_in_path() == dp.joinpath("scythe_map01_index.lmp")
|
||
|
|
dp.joinpath("scythe_map01_index-00028.lmp").touch()
|
||
|
|
assert w.demo_in_path() == dp.joinpath("scythe_map01_index-00028.lmp")
|