Skip to content

Commit

Permalink
Merge pull request #720 from fubuloubu/patch-1
Browse files Browse the repository at this point in the history
Load project before conftest
  • Loading branch information
iamdefinitelyahuman authored Aug 18, 2020
2 parents e1c4b32 + 6217b7c commit 84cf4e8
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ This changelog format is based on [Keep a Changelog](https://keepachangelog.com/
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased](https://github.com/eth-brownie/brownie)
### Fixed
- Allow using contract types in conftest ([#719](https://github.com/eth-brownie/brownie/pull/719))

## [1.10.5](https://github.com/eth-brownie/brownie/tree/v1.10.5) - 2020-08-07
### Changed
- Container repr outside of console ([#707](https://github.com/eth-brownie/brownie/pull/707))
Expand Down
8 changes: 6 additions & 2 deletions brownie/test/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,8 @@ def pytest_addoption(parser):
)


def pytest_configure(config):
def pytest_load_initial_conftests():
if project.check_for_project("."):

try:
active_project = project.load()
active_project.load_config()
Expand All @@ -68,6 +67,10 @@ def pytest_configure(config):
print(f"{color.format_tb(e)}\n")
raise pytest.UsageError("Unable to load project")


def pytest_configure(config):
if project.check_for_project("."):

if not config.getoption("showinternal"):
# do not include brownie internals in tracebacks
base_path = Path(sys.modules["brownie"].__file__).parent.as_posix()
Expand Down Expand Up @@ -104,6 +107,7 @@ def pytest_configure(config):
{"phases": {"explicit": True, "generate": True, "target": True}}, "brownie-failfast"
)

active_project = project.get_loaded_projects()[0]
session = Plugin(config, active_project)
config.pluginmanager.register(session, "brownie-core")

Expand Down
26 changes: 26 additions & 0 deletions tests/test/plugin/test_conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/python3


def test_load_contract_type(plugintester):
plugintester.makeconftest(
"""
import pytest
from brownie import BrownieTester
@pytest.fixture(params=[BrownieTester, BrownieTester])
def brownie_tester(request):
yield request.param"""
)

plugintester.makepyfile(
"""
def test_call_and_transact(brownie_tester, accounts, web3, fn_isolation):
c = accounts[0].deploy(brownie_tester, True)
c.setNum(12, {'from': accounts[0]})
assert web3.eth.blockNumber == 2
c.getTuple(accounts[0])
assert web3.eth.blockNumber == 2"""
)

result = plugintester.runpytest("-n 2")
result.assert_outcomes(passed=2)

0 comments on commit 84cf4e8

Please sign in to comment.