Fix tests

This commit is contained in:
Filip Š
2020-03-28 16:25:57 +01:00
parent bbb77aa488
commit ed50cfd20a
2 changed files with 7 additions and 7 deletions
+4 -4
View File
@@ -18,7 +18,7 @@ class ArgsInterceptor:
self.kwargs = kwargs
MOCK_PROJECT_DIR = 'some_project_dir'
MOCK_PACKAGE_DIR = 'some_package_dir'
@pytest.fixture(autouse=True)
@@ -39,20 +39,20 @@ def mock_protection(monkeypatch):
@pytest.fixture(autouse=True)
def fake_project_dir(monkeypatch):
def fake_package_dir(monkeypatch):
'''
Monkey-patch enough for the main() function to run
'''
real_os_path_exists = os.path.exists
def mock_os_path_exists(path):
if path == os.path.join(MOCK_PROJECT_DIR, 'setup.py'):
if path == os.path.join(MOCK_PACKAGE_DIR, 'setup.py'):
return True
else:
return real_os_path_exists(path)
monkeypatch.setattr(os.path, 'exists', mock_os_path_exists)
monkeypatch.setattr(sys, 'argv', ['cibuildwheel', MOCK_PROJECT_DIR])
monkeypatch.setattr(sys, 'argv', ['cibuildwheel', MOCK_PACKAGE_DIR])
@pytest.fixture(params=['linux', 'macos', 'windows'])
+3 -3
View File
@@ -4,7 +4,7 @@ import pytest
from cibuildwheel.__main__ import main
from conftest import MOCK_PROJECT_DIR # noqa: I100
from conftest import MOCK_PACKAGE_DIR # noqa: I100
def test_unknown_platform_non_ci(monkeypatch, capsys):
@@ -51,10 +51,10 @@ def test_platform_argument(platform, intercepted_build_args, monkeypatch):
main()
assert intercepted_build_args.kwargs['project_dir'] == MOCK_PROJECT_DIR
assert intercepted_build_args.kwargs['package_dir'] == MOCK_PACKAGE_DIR
def test_platform_environment(platform, intercepted_build_args, monkeypatch):
main()
assert intercepted_build_args.kwargs['project_dir'] == MOCK_PROJECT_DIR
assert intercepted_build_args.kwargs['package_dir'] == MOCK_PACKAGE_DIR