Skip to content

Commit

Permalink
tests: add from_isolated_env constructor test
Browse files Browse the repository at this point in the history
  • Loading branch information
layday committed Oct 29, 2021
1 parent e5e80d0 commit 1d5b149
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/test_projectbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import pytest

import build
import build._helpers
import build.env


if sys.version_info >= (3, 8): # pragma: no cover
Expand Down Expand Up @@ -190,6 +192,32 @@ def test_init(mocker, package_test_flit, package_legacy, test_no_permission, pac
build.ProjectBuilder(package_test_bad_syntax)


@pytest.mark.isolated
def test_init_from_isolated_env(mocker, package_test_flit):
mocker.patch('build.ProjectBuilder.__init__')
build.ProjectBuilder.__init__.return_value = None

# default subprocess runner
with build.env.IsolatedEnvManager() as env:
build.ProjectBuilder.from_isolated_env(env, package_test_flit)
build.ProjectBuilder.__init__.assert_called_with(
package_test_flit,
python_executable=env.python_executable,
runner=(build.default_subprocess_runner, env.prepare_environ()),
)
build.ProjectBuilder.__init__.reset_mock()

# custom subprocess runner
with build.env.IsolatedEnvManager() as env:
build.ProjectBuilder.from_isolated_env(env, package_test_flit, build._helpers.quiet_subprocess_runner)
build.ProjectBuilder.__init__.assert_called_with(
package_test_flit,
python_executable=env.python_executable,
runner=(build._helpers.quiet_subprocess_runner, env.prepare_environ()),
)
build.ProjectBuilder.__init__.reset_mock()


@pytest.mark.parametrize('distribution', ['wheel', 'sdist'])
def test_get_requires_for_build_missing_backend(packages_path, distribution):
bad_backend_path = os.path.join(packages_path, 'test-bad-backend')
Expand Down

0 comments on commit 1d5b149

Please sign in to comment.