-
Notifications
You must be signed in to change notification settings - Fork 283
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
Adopt py.test #3835
Comments
@SciTools/iris-devs Thoughts? |
I would have said yes for this reason alone. Everything else makes me scared to not switch! |
All that is about the test runner, really, which is about the "total test suite definition", and the needs of CI. For basic developer needs, I think you missed the really obvious:
For sure we should migrate to using pytest as the engine, but the format of our tests has never depended on nose, it is all pure unittest, which pytest also supports quite happily. So I don't think we need a wholesale rewrite. We can adopt pytest-specific methods as they seem useful, I do also have a couple of lingering doubts about becoming pytest-specific, though :
|
@pp-mo Yeah, I wasn't intending to enumerate every possible way to run all the tests, it was just a means to justify my motivation and more importantly get some kinda rough gauge of what everyone else thinks.
This is kinda (3) really, but let's not split hairs 😉
Yup, if you wanna run those isolated tests, and all shades of grey of running individual test classes within those, or test class tasks etc |
@pp-mo That a really good point. But at the end of the day I guess we can evolve those This is a BIG change, and if we're serious about doing it (and I think we should be), how we go about it e.g., blitz it all in a focused sprint, do it piece-meal etc? |
With I think that the BIGGEST headache in migration from I think that it would be wise to get a rough ideal of common approaches we want to adopt for migrating particular testing patterns, otherwise we'll end up with a multitude of different approaches to doing the same thing... and that, I suspect, will be a maintenance headache and increase the bar on developer testing effort |
I think we have test examples that would look much cleaner using pytest parametrization, e.g. here two tests that are very similar and the class is subclassed for each of the four arithmetic operations. Or here where each test is looping through the operations. I assume we wouldn’t want to write anything like the latter now, as if your first operation failed the others won’t get tested. Aside - was there an intention to move/replace all the old modules in the top level tests directory when the unit/integration subdirectories were introduced? |
@rcomer I think that the home of certain tests requires some serious rationalisation and consideration, and for me this would all come under this work. So 👍 on that. From what I recall (and this is going back some time, perhaps @pp-mo can help clarify) those are legacy tests... and it's a fine line between those tests and integration tests, and system test etc. In fact, the unit tests came later, and those have a little bit more rigour... so IMHO it all needs a bit of a rethink to restructure it in a consistent and coherent way - plus there is most likely a lot of duplicated dead wood to purge/revisit, so we should take the opportunity to do that too. |
I'd also advocate that #3416 is also dealt with as part of this testing re-haul. |
Since @bjlittle asked me directly, yes we intended to retire + replace the "legacy" tests gradually over time. |
A further benefit of |
In ants, we long ago ditched nose in favour of just plane unittests. I can fish out the commit which removed nose from the setup.py if that would help in some way? Just a perspective I thought I would share - perhaps there is a good enough reason for writing pytest tests for iris, I don't know. I have always favoured using the standard library myself without strong reason to do otherwise. |
To run pytest -n num_cpus [other args] I had a quick search for how to parallelise with |
I believe it basically can't. |
Here's another potential benefit |
I'm delighted to see we are now using |
Awesome job @lbdreyer ! |
⚙ Feature Request
There are currently a few approaches to running the
iris
tests as a developer:iris.tests.runner
e.g.,python -m iris.tests.runner --default-tests
test
command fromsetuptools
e.g.,python setup.py test
unittest
e.g.,python -m unittest discover iris
These are all perfectly functional approaches, for now, to take to run the
iris
tests. However, there are a few problems with each approach, namely:iris.tests.runner
mechanism is bespoke and heavily relies onnose
, which has been in maintenance mode for several years now i.e., it's dead-end technology 💣. Also using this mechanism is causing issues for automatically collating testing coverage statistics.test
command insetuptools
was deprecated in version41.5.0
, (latest50.3.0
) and will be withdrawn in a future version i.e., the future is closer than you thinkunittest
isn'tpytest
, not even close 😉Motivation
It's high time that
iris
adoped a modern, robust, sustainable, actively supported and scalable approach to testing through pytest and pytest-xdist... before it's too late, and this becomes a much bigger issue than it needs to be i.e., let's agree to plan to avoid this crisis... before it's a crisis.The text was updated successfully, but these errors were encountered: