Fix paths in unit tests

This commit is contained in:
Yannick Jadoul
2020-06-18 00:23:25 +02:00
parent a7f73f1593
commit 46a39b06cb
2 changed files with 14 additions and 12 deletions
+8 -7
View File
@@ -1,6 +1,7 @@
import os
import subprocess
import sys
from pathlib import Path
import pytest
@@ -18,7 +19,7 @@ class ArgsInterceptor:
self.kwargs = kwargs
MOCK_PACKAGE_DIR = 'some_package_dir'
MOCK_PACKAGE_DIR = Path('some_package_dir')
@pytest.fixture(autouse=True)
@@ -43,16 +44,16 @@ def fake_package_dir(monkeypatch):
'''
Monkey-patch enough for the main() function to run
'''
real_os_path_exists = os.path.exists
real_path_exists = Path.exists
def mock_os_path_exists(path):
if path == os.path.join(MOCK_PACKAGE_DIR, 'setup.py'):
def mock_path_exists(path):
if path == MOCK_PACKAGE_DIR / 'setup.py':
return True
else:
return real_os_path_exists(path)
return real_path_exists(path)
monkeypatch.setattr(os.path, 'exists', mock_os_path_exists)
monkeypatch.setattr(sys, 'argv', ['cibuildwheel', MOCK_PACKAGE_DIR])
monkeypatch.setattr(Path, 'exists', mock_path_exists)
monkeypatch.setattr(sys, 'argv', ['cibuildwheel', str(MOCK_PACKAGE_DIR)])
@pytest.fixture(params=['linux', 'macos', 'windows'])