vyper icon indicating copy to clipboard operation
vyper copied to clipboard

chore: refactor test contracts to fixtures

Open tserg opened this issue 2 years ago • 3 comments

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

Put a link to a cute animal picture inside the parenthesis-->

tserg avatar Feb 24 '22 02:02 tserg

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.

codecov-commenter avatar Feb 24 '22 03:02 codecov-commenter

note: to compare timings between https://github.com/vyperlang/vyper/actions/runs/2042620929 vs https://github.com/vyperlang/vyper/actions/runs/2044843484

charles-cooper avatar Mar 26 '22 15:03 charles-cooper

looks like each test comes down by an average of 15 seconds

charles-cooper avatar Mar 26 '22 16:03 charles-cooper

closing on account of the merge conflicts. we can return to this on a case-by-case basis later

charles-cooper avatar Nov 07 '23 21:11 charles-cooper