Brownie includes custom fixtures <pytest-fixtures-docs>
and markers<pytest-markers-docs>
that can be used when testing your project.
These fixtures provide quick access to Brownie objects that are frequently used during testing. If you are unfamiliar with these objects, you may wish to read the documentation listed under "Core Functionality" in the table of contents.
Brownie creates dynamically named fixtures to access each ContractContainer <brownie.network.contract.ContractContainer>
object within a project. Fixtures are generated for all deployable contracts and libraries.
For example - if your project contains a contract named Token
, there will be a Token
fixture available.
def test_token_deploys(Token, accounts): token = accounts[0].deploy(Token, "Test Token", "TST", 18, 1e24) assert token.name() == "Test Token"
Isolation fixtures are used to ensure a clean test environment when running tests, and to prevent the results of a test from affecting subsequent tests. See pytest-fixtures-isolation
for information on how to use these fixtures.
Brownie provides the following markers<pytest-markers-docs>
for use within your tests: