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

Allow importing contracts inside test suites #719

Closed
fubuloubu opened this issue Aug 18, 2020 · 1 comment · Fixed by #720
Closed

Allow importing contracts inside test suites #719

fubuloubu opened this issue Aug 18, 2020 · 1 comment · Fixed by #720
Labels
bug Something isn't working

Comments

@fubuloubu
Copy link
Contributor

Overview

Brownie provides contract types as fixtures, however it would be helpful to also allow importing them via from brownie import ContractType, then you could do useful stuff like this:

import pytest
from brownie import ProtocolV1, ProtocolV2

@pytest.fixture(params=[ProtocolV1, ProtocolV2])
def protocol(accounts, request):
    yield accounts[0].deploy(request.param)

This would parametrize the fixture such that it would run any tests it touches twice, once with ProtocolV1, and once with ProtocolV2.

@iamdefinitelyahuman
Copy link
Member

This does work in tests, but not in conftest.py apparently. Shouldn't be a hard fix, just need to ensure the project is loaded before plugin collection happens.

@iamdefinitelyahuman iamdefinitelyahuman added the bug Something isn't working label Aug 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants