Monkeypatch sys.argv instead of using an argument to main()

Just a style thing... didn't want to complicate the main func
for the sake of a couple tests
This commit is contained in:
Joe Rickerby
2021-10-17 21:24:03 +01:00
parent 08a694485d
commit 4f53583801
2 changed files with 12 additions and 6 deletions
+9 -3
View File
@@ -1,5 +1,6 @@
import platform as platform_module
import subprocess
import sys
from contextlib import contextmanager
from pathlib import Path
from typing import cast
@@ -40,9 +41,11 @@ def mock_build_docker(monkeypatch):
monkeypatch.setattr("cibuildwheel.util.print_new_wheels", ignore_context_call)
def test_build_default_launches(mock_build_docker, fake_package_dir):
def test_build_default_launches(mock_build_docker, fake_package_dir, monkeypatch):
monkeypatch.setattr(sys, "argv", ["cibuildwheel", "--platform=linux"])
main()
main(["--platform=linux"])
build_on_docker = cast(mock.Mock, linux.build_on_docker)
assert build_on_docker.call_count == 4
@@ -106,7 +109,10 @@ before-all = "true"
)
monkeypatch.chdir(pkg_dir)
main(["--platform=linux"])
monkeypatch.setattr(sys, "argv", ["cibuildwheel", "--platform=linux"])
main()
build_on_docker = cast(mock.Mock, linux.build_on_docker)
assert build_on_docker.call_count == 6