openscm / scmdata

Handling of Simple Climate Model data
https://scmdata.readthedocs.io
BSD 3-Clause "New" or "Revised" License
8 stars 5 forks source link

Doctests #274

Closed znicholls closed 1 year ago

znicholls commented 1 year ago

Pull request

Please confirm that this pull request has done the following:

znicholls commented 1 year ago

I'm going to use this fix to avoid the terminal width issue https://github.com/pytest-dev/pytest/issues/4030#issuecomment-428705472

znicholls commented 1 year ago

Adding the doctests breaks the code coverage. I think there is a fix for this, but I don't know what it is (maybe a non-editable install) and I'm giving up for the day.

codecov[bot] commented 1 year ago

Codecov Report

All modified lines are covered by tests :white_check_mark:

Comparison is base (bf80b14) 95.15% compared to head (657eab8) 95.15%. Report is 2 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #274 +/- ## ======================================= Coverage 95.15% 95.15% ======================================= Files 24 24 Lines 2190 2190 Branches 404 404 ======================================= Hits 2084 2084 Misses 86 86 Partials 20 20 ``` | [Files](https://app.codecov.io/gh/openscm/scmdata/pull/274?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=openscm) | Coverage Δ | | |---|---|---| | [src/scmdata/groupby.py](https://app.codecov.io/gh/openscm/scmdata/pull/274?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=openscm#diff-c3JjL3NjbWRhdGEvZ3JvdXBieS5weQ==) | `78.40% <ø> (ø)` | | | [src/scmdata/ops.py](https://app.codecov.io/gh/openscm/scmdata/pull/274?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=openscm#diff-c3JjL3NjbWRhdGEvb3BzLnB5) | `99.50% <ø> (ø)` | | | [src/scmdata/run.py](https://app.codecov.io/gh/openscm/scmdata/pull/274?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=openscm#diff-c3JjL3NjbWRhdGEvcnVuLnB5) | `95.00% <ø> (ø)` | |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

znicholls commented 1 year ago

Adding the doctests breaks the code coverage. I think there is a fix for this, but I don't know what it is (maybe a non-editable install) and I'm giving up for the day.

This discussion is incredibly helpful for debugging these kind of issues.

tl-dr; something like COVERAGE_DEBUG=trace poetry run pytest src --doctest-modules --cov=scmdata -s or COVERAGE_DEBUG=trace COVERAGE_DEBUG_FILE=/Users/znicholls/Desktop/dbg.out poetry run pytest src --doctest-modules --cov=scmdata is super helpful because you can see what isn't being traced.

For whatever reason, coverage thinks that the modules that have the doctests in them aren't in the source scope for some reason unless we specify --cov=src. I was getting output like the below

Not tracing '/Users/znicholls/Documents/repos-agcec/scmdata/src/scmdata/groupby.py': module 'src.scmdata.groupby' falls outside the --source spec

I have no idea why this happens, something to do with these lines