-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a bit of infrastructure for testing transforms
- Loading branch information
1 parent
a145912
commit 0e4a00d
Showing
8 changed files
with
65 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[pytest] | ||
trio_mode = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
pytest-trio>=0.8.0 | ||
pytest>>7.0.0 | ||
pytest-datadir>=1.3.1 | ||
pytest-regressions>=2.2.0 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import importlib | ||
import sys | ||
from pathlib import Path | ||
from typing import Awaitable, Callable | ||
|
||
import pytest | ||
|
||
from hammeraddons.bsp_transform import Context, TransFunc, TRANSFORMS | ||
from srctools.bsp import BSP | ||
from srctools.filesys import VirtualFileSystem | ||
from srctools.game import Game | ||
from srctools.packlist import PackList | ||
|
||
|
||
@pytest.fixture | ||
def blank_ctx(shared_datadir: Path) -> Context: | ||
"""Build a blank context.""" | ||
bsp = BSP(shared_datadir / 'blank.bsp') | ||
game = Game(shared_datadir) | ||
fsys = VirtualFileSystem({}) | ||
return Context( | ||
fsys, | ||
bsp.ents, | ||
PackList(fsys), | ||
bsp, | ||
game, | ||
) | ||
|
||
|
||
def get_transform_func(module_name: str, transform: str) -> Callable[[Context], Awaitable[None]]: | ||
"""Import the builtin transforms, then fetch this context.""" | ||
folder = str(Path(__file__, '..', '..', '..', 'transforms').resolve()) | ||
print(f'Adding "{folder}" to path.') | ||
|
||
sys.path.append(folder) | ||
try: | ||
importlib.import_module(module_name) | ||
return TRANSFORMS[transform] | ||
finally: | ||
sys.path.remove(folder) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
"GameInfo" | ||
{ | ||
game "HALF-LIFE 2" | ||
title "HALF-LIFE'" | ||
type singleplayer_only | ||
|
||
FileSystem | ||
{ | ||
SteamAppId 220 | ||
SearchPaths | ||
{ | ||
} | ||
} | ||
} |