Skip to content

Commit

Permalink
Speed up tests execution
Browse files Browse the repository at this point in the history
  • Loading branch information
atugushev committed Aug 10, 2023
1 parent 81ecd9b commit 0abb50f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ disallow_untyped_defs = false
addopts = [
# `pytest-xdist`:
"--numprocesses=auto",
"--dist=worksteal",

# Show 20 slowest invocations:
"--durations=20",
Expand Down
18 changes: 9 additions & 9 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,8 @@ def pip_with_index_conf(make_pip_conf):
)


@pytest.fixture
def make_package(tmp_path):
@pytest.fixture(scope="session")
def make_package(tmp_path_factory):
"""
Make a package from a given name, version and list of required packages.
"""
Expand All @@ -303,7 +303,7 @@ def _make_package(name, version="0.1", install_requires=None, extras_require=Non
",".join(f"{package!r}" for package in install_requires)
)

package_dir = tmp_path / "packages" / name / version
package_dir = tmp_path_factory.mktemp("packages") / name / version
package_dir.mkdir(parents=True)

with (package_dir / "setup.py").open("w") as fp:
Expand Down Expand Up @@ -332,7 +332,7 @@ def _make_package(name, version="0.1", install_requires=None, extras_require=Non
return _make_package


@pytest.fixture
@pytest.fixture(scope="session")
def run_setup_file():
"""
Run a setup.py file from a given package dir.
Expand All @@ -350,7 +350,7 @@ def _run_setup_file(package_dir_path, *args):
return _run_setup_file


@pytest.fixture
@pytest.fixture(scope="session")
def make_wheel(run_setup_file):
"""
Make a wheel distribution from a given package dir.
Expand Down Expand Up @@ -408,12 +408,12 @@ def _make_module(fname, content):
return _make_module


@pytest.fixture
def fake_dists(tmpdir, make_package, make_wheel):
@pytest.fixture(scope="session")
def fake_dists(tmp_path_factory, make_package, make_wheel):
"""
Generate distribution packages `small-fake-{a..f}`
Generate distribution packages `small-fake-*`
"""
dists_path = os.path.join(tmpdir, "dists")
dists_path = tmp_path_factory.mktemp("dists")
pkgs = [
make_package("small-fake-a", version="0.1"),
make_package("small-fake-b", version="0.2"),
Expand Down
1 change: 1 addition & 0 deletions tests/test_cli_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2948,6 +2948,7 @@ def test_compile_recursive_extras(runner, tmp_path, current_resolver):
out = runner.invoke(
cli,
[
"--no-build-isolation",
"--no-header",
"--no-annotate",
"--no-emit-options",
Expand Down

0 comments on commit 0abb50f

Please sign in to comment.