-
-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
move tests to tests folder #211
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #211 +/- ##
==========================================
+ Coverage 95.53% 95.60% +0.06%
==========================================
Files 17 13 -4
Lines 2085 1912 -173
==========================================
- Hits 1992 1828 -164
+ Misses 93 84 -9 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!! This looks good to me.
This now shows the changes I had made for removing depreciations and 1to2, which I don't think you saw when you commented. I'll open a PR for 1to2 now that can be merged before this. |
Did you consider moving the tests out of the package (just a top level I have occasionally found it useful to have tests in the main package so I can test the package with |
+1 on moving tests out of the source tree and into a top-level |
The CI scripts just do a plain |
@wshanks Ah, thanks, yes I see that now, and I completely agree. |
interesting that it keeps the approval after I make new commits I moved some functions that could be used by downstream libraries to uncertainties.testing |
I enabled dismissing approvals when new changes are pushed. I have found it to be annoying on other projects where the reviewer approves the spirit of the PR but then has to come back and approve a couple more times because of typos/linting. Here, it seems like we have a responsive enough group for it to be okay. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good. Besides my inline question, could we add this to pyproject.toml
:
[tool.pytest.ini_options]
testpaths = ["tests"]
I don't know that we need to add any additional options at this time.
tests/test_umath.py
Outdated
from . import test_uncertainties | ||
|
||
from uncertainties.testing import compare_derivatives, numbers_close | ||
from test_uncertainties import power_special_cases, power_all_cases, power_wrt_ref |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not seem right to import from one test_
file to another. These functions do seem too specialized for uncertainties.testing
though. Could we use one of the options in this StackOverflow question. Maybe the conftest.py
and fixture option, or the pythonpath
and helpers file option?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding testpaths = ["tests"]
is not required for tests to work right? It's just a convenience that makes pytest
discover tests more quickly? Is my understanding correct?
In the past I've put helper function needed for testing in an __init__.py
file in the tests
folder. These objects can then be imported within the test scripts. We could also have a tests/helper.py
module to accomplish the same result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, importing across test files does feel a bit odd. The helpers.py solution is nice and simple.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding testpaths = ["tests"] is not required for tests to work right? It's just a convenience that makes pytest discover tests more quickly? Is my understanding correct?
Yes, that seems to be all it does functionally. My conjecture was that it might also help IDE's figure out that the project uses pytest as the test runner because otherwise there is no configuration indicating that pytest should be run, but I haven't tried to confirm that.
I like the move to helpers.py. We might want to add
testpaths = ["tests"]
addopts = [
"--import-mode=importlib",
]
to pyproject.toml like the one StackOverflow answer suggests, but we could wait for that. Currently, pytest adds all the test directories to the Python path so you can do import helpers
but it has been trying to move away from that to just importing the test files with importlib
without modifying the Python path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for explaining, wouldn't have understood why otherwise
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is good. I had one suggestion about adding more pytest configuration but it's not mandatory.
This commit removes: - the 1to2 code and documentation, - the compatability code that handled obsolete function calls, - the deprecations in these calls, - the tests that tested obsolete behaviour
Also, should this fold in #210? Otherwise they will create merge conflicts with each other. |
Removed unused imports in tests. Co-authored-by: andrewgsavage <andrewgsavage@gmail.com>
…into andrewgsavage-tests
I tried doing this and it worked locally but I couldn't get it working with CI. I've reverted so this can be merged and we can do the importlib in another PR. Ready for merging now |
The merge-base changed after approval.
It looks good but it won't let me merge at the moment. The diff also doesn't look right in the GitHub web UI but looks right locally. I saw this in another repo recently as well. |
The merge-base changed after approval.
Can |
It could be, but @andrewgsavage described the contents above as "I moved some functions that could be used by downstream libraries to uncertainties.testing" |
hold up, looks like I'd deleted the contents of a file |
I see all the changes from #214 still in the web UI. Could you squash onto master and force push? Or does it show up correctly for others now? |
The
These functions are only used in the tests so I think it makes sense for them to be in the test helpers module. Is the idea that downstream users might want to use these functions? If so, then they should be part of public API and they need to be documented etc. And if they're meant to be part of the public API I think it is strange for them to be in a module named |
I am not ever going to be able to keep up with conversations at the pace here. I do not fully understand the added I am working slowly on the docs, but this will take some time -- given my work schedule, into next week. I deeply despise that codecov calls a PR unsuccessful if it loses a bit of coverage. Knowing the code coverage is fine. As a github check, codecov and its reports are warts. I will make a PR to copy the codecov config from lmfit. |
No description provided.