Skip to content

Latest commit

 

History

History
194 lines (121 loc) · 6.57 KB

tests-pytest-fixtures.rst

File metadata and controls

194 lines (121 loc) · 6.57 KB

Fixture and Marker Reference

Brownie includes custom fixtures <pytest-fixtures-docs> and markers<pytest-markers-docs> that can be used when testing your project.

Session Fixtures

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.

Contract Fixtures

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

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.

Markers

Brownie provides the following markers<pytest-markers-docs> for use within your tests: