Skip to content

Commit 8a8bb3b

Browse files
committed
Mock pyvda in GH test runners
Windows server doesn't support virtual desktops and pyvda throws up errors in GH actions.
1 parent 997766d commit 8a8bb3b

File tree

1 file changed

+3
-23
lines changed

1 file changed

+3
-23
lines changed

test/conftest.py

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,43 +12,23 @@
1212
The generic lists (`DISPLAYS`, `RULES`, etc...) simply combine all groups into
1313
a single list
1414
"""
15-
import importlib.util
1615
import os
17-
import shutil
1816
import sys
1917
from copy import deepcopy
2018
from pathlib import Path
2119

2220
import pytest
2321

24-
__pyvda_utils = Path(importlib.util.find_spec('pyvda').origin).parent / 'utils.py'
22+
if os.getenv('GITHUB_ACTIONS') == 'true':
23+
# mock pyvda since it's not supported in windows server/GH actions runners
24+
sys.modules['pyvda'] = type(os)('pyvda')
2525

2626
sys.path.insert(0, str((Path(__file__).parent / '../').resolve()))
2727
# allow internal imports like win32_extras
2828
sys.path.insert(0, str((Path(__file__).parent / '../src').resolve()))
2929
from src import common # noqa:E402
3030

3131

32-
if os.getenv('GITHUB_ACTIONS') == 'true':
33-
34-
def pytest_sessionstart():
35-
shutil.copyfile(__pyvda_utils, __pyvda_utils.parent / 'utils-old.py')
36-
37-
with open(__pyvda_utils, 'r') as f:
38-
contents = f.read().replace(
39-
'def get_vd_manager_internal2():',
40-
'def get_vd_manager_internal2():\n return get_vd_manager_internal()',
41-
)
42-
43-
with open(__pyvda_utils, 'w') as f:
44-
f.write(contents)
45-
46-
def pytest_sessionfinish():
47-
utils_old = __pyvda_utils.parent / 'utils-old.py'
48-
shutil.copyfile(utils_old, __pyvda_utils)
49-
os.remove(utils_old)
50-
51-
5232
DISPLAYS1 = [
5333
{
5434
'uid': 'UID11111',

0 commit comments

Comments
 (0)