vyper
vyper copied to clipboard
chore: refactor test contracts to fixtures
What I did
Convert the following types of test contracts in the test suite to fixtures:
- does not take in parametrized values and are compiled without any changes for each parametrized value in the test function;
@pytest.mark.parametrize(...)
def test_foo():
code = """
...
"""
c = get_contract(code) # <-- gets run N times
# do something with c
- takes in parametrized values, but the parametrized values are not also used in the test function, and the test function contains other parametrized values
@pytest.mark.parametrize(a, [...])
@pytest.mark.parametrize(b, [...])
def test_foo():
code = f"""
...{a}
"""
c = get_contract(code) # <-- gets run N times
# do something with c and b, but not a
How I did it
Extract the test contract as a fixture, and pass the fixture instead to the test function.
How to verify it
Run tests.
Description for the changelog
Refactor test contracts to fixtures
Cute Animal Picture
Codecov Report
Merging #2682 (279b374) into master (ea4eaee) will not change coverage. The diff coverage is
n/a
.
@@ Coverage Diff @@
## master #2682 +/- ##
=======================================
Coverage 87.27% 87.27%
=======================================
Files 92 92
Lines 9895 9895
Branches 2479 2479
=======================================
Hits 8636 8636
Misses 774 774
Partials 485 485
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update ea4eaee...279b374. Read the comment docs.
note: to compare timings between https://github.com/vyperlang/vyper/actions/runs/2042620929 vs https://github.com/vyperlang/vyper/actions/runs/2044843484
looks like each test comes down by an average of 15 seconds
closing on account of the merge conflicts. we can return to this on a case-by-case basis later