diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 20d07d9c..36c8ab9d 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -1,6 +1,6 @@ name: unitary -on: ["push", "pull_request"] +on: [ "push", "pull_request" ] env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.10", "3.11"] + python-version: [ "3.10", "3.11" ] name: "unit tests: python ${{ matrix.python-version }}" @@ -29,7 +29,20 @@ jobs: pip install . - name: Run Unit Tests - run: pytest -n auto tests/unitary/ + env: + PYTHONPATH: ${{ github.workspace }} + # pass internals to pytest-cov, since we are testing a pytest plugin. + # See https://github.com/pytest-dev/pytest-cov/blob/2c9f2170/docs/plugins.rst + COV_CORE_SOURCE: boa + COV_CORE_CONFIG: .coveragerc + COV_CORE_DATAFILE: .coverage.eager + run: >- + pytest + --cov=boa + --cov-append + --cov-report term-missing:skip-covered + --cov-fail-under=70 + tests/unitary/ integration: name: "integration tests (forked and networked modes)" diff --git a/.gitignore b/.gitignore index a9e99892..49357d74 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ venv/ *.env .coverage +.coverage.* diff --git a/boa/integrations/jupyter/utils.py b/boa/integrations/jupyter/utils.py index 7180006b..c14622a3 100644 --- a/boa/integrations/jupyter/utils.py +++ b/boa/integrations/jupyter/utils.py @@ -1,7 +1,7 @@ from os.path import dirname, join, realpath import requests -from IPython.core.display import Javascript, display +from IPython.display import Javascript, display from boa.integrations.jupyter.constants import ETHERS_JS_URL diff --git a/dev-requirements.txt b/dev-requirements.txt index c7f1c4c2..f3cf704d 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -10,4 +10,5 @@ mypy pre-commit pytest pytest-xdist +pytest-cov sphinx-rtd-theme diff --git a/pyproject.toml b/pyproject.toml index 178d4059..f09f7cd0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,6 +22,7 @@ dependencies = [ "eth-typing", "hypothesis", "pytest", + "pytest-cov", "rich", # required for forking: @@ -41,7 +42,11 @@ requires = ["setuptools", "wheel"] include = ["boa*"] [tool.pytest.ini_options] -markers = ["ignore_isolation: Do not preserve state during tests"] +markers = [ + "ignore_isolation: Do not preserve state during tests", + "gas_profile: Enable gas profiling.", + "ignore_profiling: Disable gas profiling.", +] [tool.setuptools.package-data] boa = ["integrations/**/*.js"] diff --git a/tests/unitary/stateful/test_state_machine_isolation.py b/tests/unitary/stateful/test_state_machine_isolation.py index d2d0dbf6..c79ce06a 100644 --- a/tests/unitary/stateful/test_state_machine_isolation.py +++ b/tests/unitary/stateful/test_state_machine_isolation.py @@ -52,6 +52,6 @@ def test_state_machine_isolation(boa_contract): StateMachine.contract = boa_contract StateMachine.settings = { "stateful_step_count": NUM_STEPS, - "suppress_health_check": HealthCheck.all(), + "suppress_health_check": list(HealthCheck), } run_state_machine_as_test(StateMachine)