Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pytest minor fixes #521

Merged
merged 2 commits into from
May 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions brownie/test/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@ def package_loader(project_id):

yield package_loader

for project in _open_projects.values():
project.close(raises=False)

@pytest.fixture
def no_call_coverage(self):
"""
Expand Down
5 changes: 4 additions & 1 deletion brownie/test/managers/master.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from xdist.scheduler import LoadFileScheduling

from brownie._config import CONFIG
from brownie.project import get_loaded_projects
from brownie.test import coverage

from .base import PytestBrownieBase
Expand Down Expand Up @@ -44,4 +45,6 @@ def pytest_sessionfinish(self, session):
json.dump(report, fp, indent=2, sort_keys=True, default=sorted)
coverage_eval = coverage.get_merged_coverage_eval(report["tx"])
self._sessionfinish_coverage(coverage_eval)
self.project.close()

for project in get_loaded_projects():
project.close(raises=False)
10 changes: 8 additions & 2 deletions brownie/test/managers/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@
from .base import PytestBrownieBase
from .utils import convert_outcome

SCOPE_ORDER = ("session", "package", "module", "class", "function")


def _make_fixture_execute_first(metafunc, name, scope):
fixtures = metafunc.fixturenames

scopes = SCOPE_ORDER[SCOPE_ORDER.index(scope) :]
if name in fixtures:
fixtures.remove(name)
defs = metafunc._arg2fixturedefs
idx = next(
(fixtures.index(i) for i in fixtures if i in defs and defs[i][0].scope == scope),
(fixtures.index(i) for i in fixtures if i in defs and defs[i][0].scope in scopes),
len(fixtures),
)
fixtures.insert(idx, name)
Expand Down Expand Up @@ -285,7 +289,9 @@ def _sessionfinish(self, path):
json.dump(report, fp, indent=2, sort_keys=True, default=sorted)
coverage_eval = coverage.get_merged_coverage_eval()
self._sessionfinish_coverage(coverage_eval)
self.project.close()

for project in brownie.project.get_loaded_projects():
project.close(raises=False)


class PytestBrownieXdistRunner(PytestBrownieRunner):
Expand Down