Splitting off fake_project_dir fixture from mock_protection, only mocking os.path.exist for setup.py in the mocked project directory
This commit is contained in:
@@ -6,7 +6,7 @@ from cibuildwheel.__main__ import main
|
||||
from cibuildwheel.environment import ParsedEnvironment
|
||||
from cibuildwheel.util import BuildSelector
|
||||
|
||||
from main_util_fixtures import mock_protection, platform, intercepted_build_args
|
||||
from main_util_fixtures import mock_protection, fake_project_dir, platform, intercepted_build_args
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import sys
|
||||
|
||||
from cibuildwheel.__main__ import main
|
||||
|
||||
from main_util_fixtures import MOCK_PROJECT_DIR, mock_protection, platform, intercepted_build_args
|
||||
from main_util_fixtures import MOCK_PROJECT_DIR, mock_protection, fake_project_dir, platform, intercepted_build_args
|
||||
|
||||
|
||||
def test_unknown_platform_non_ci(monkeypatch, capsys):
|
||||
|
||||
@@ -17,6 +17,11 @@ MOCK_PROJECT_DIR = 'some_project_dir'
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def mock_protection(monkeypatch):
|
||||
'''
|
||||
Ensure that a unit test will never actually run a cibuildwheel 'build'
|
||||
function, which shouldn't be run on a developer's machine
|
||||
'''
|
||||
|
||||
def fail_on_call(*args, **kwargs):
|
||||
raise RuntimeError("This should never be called")
|
||||
|
||||
@@ -25,7 +30,21 @@ def mock_protection(monkeypatch):
|
||||
monkeypatch.setattr(windows, 'build', fail_on_call)
|
||||
monkeypatch.setattr(linux, 'build', fail_on_call)
|
||||
monkeypatch.setattr(macos, 'build', fail_on_call)
|
||||
monkeypatch.setattr(os.path, 'exists', lambda x: True)
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def fake_project_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'):
|
||||
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])
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user