File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -95,23 +95,15 @@ jobs:
9595 # we should add a CI step that runs the tests without optional dependencies too.
9696 # We don't have that right now, because we're not sure this pain point exists.
9797 uv-dependency-install-flags : " --all-extras --group tests"
98- - name : Show installed tree
99- run : |
100- ls .venv/lib/python3.11/site-packages/example_fgen_basic
10198 - name : Run tests
10299 run : |
100+ rm -r src/example_fgen_basic
101+ ln -s .venv/lib/python3.11/site-packages/example_fgen_basic src/example_fgen_basic
103102 uv run --no-sync pytest -r a -v tests src --doctest-modules --doctest-report ndiff --cov=src --cov-report=term-missing --cov-report=xml
104- # uv run --no-editable --reinstall-package example-fgen-basic python -c 'import example_fgen_basic;print(example_fgen_basic.__file__)'
105- # cd .venv/lib/python3.11/site-packages/example_fgen_basic
106- # ls
107- # ../../../../bin/python -c 'import exceptions; print("Found exceptions here")'
108- # ../../../../bin/python -c 'import _lib; print("Found _lib here")'
109- # cd ../../../../../
110- # ls
111- # .venv/bin/pytest -r a -v src tests --doctest-modules --cov=src --cov-report=term-missing --cov-report=xml
112- # uv run which pytest
113- # uv run --no-editable --reinstall-package example-fgen-basic pytest -r a -v src tests --doctest-modules --cov=src --cov-report=term-missing --cov-report=xml
114103 uv run --no-sync coverage report
104+ # Just in case, undo the changes to `src`
105+ rm -r src/example_fgen_basic
106+ git restore --staged . && git restore .
115107 - name : Upload coverage reports to Codecov with GitHub Action
116108 uses : codecov/codecov-action@v4.2.0
117109 env :
Original file line number Diff line number Diff line change @@ -40,6 +40,15 @@ ruff-fixes: ## fix the code using ruff
4040
4141.PHONY : test
4242test : # # run the tests (re-installs the package every time so you might want to run by hand if you're certain that step isn't needed)
43+ # Note: passing `src` to pytest causes the `src` directory to be imported
44+ # if the package has not already been installed.
45+ # This is a problem, as the package is not importable from `src` by itself because the extension module is not available.
46+ # As a result, you have to pass `pytest tests src` rather than `pytest src tests`
47+ # to ensure that the package is imported from the venv and not `src`.
48+ # The issue with this is that code coverage then doesn't work,
49+ # because it is looking for lines in `src` to be run,
50+ # but they're not because lines in `.venv` are run instead.
51+ # We don't have a solution to this yet.
4352 uv run --no-editable --reinstall-package example-fgen-basic pytest -r a -v -tests src -doctest-modules --doctest-report ndiff --cov=src
4453
4554# Note on code coverage and testing:
You can’t perform that action at this time.
0 commit comments