-
Notifications
You must be signed in to change notification settings - Fork 224
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
Guidance on types of tests to write for plotting functions #771
Comments
Yeah, we do need to spell this out. I would think of testing as a spectrum from:
Now you'll probably realize that we fall somewhere in the middle, for practical reasons. Not everyone knows how to write tests, hence the range of style. If I could mention 2 things about testing in PyGMT:
Above all, remember the golden rule of testing, which is to not delete or change tests unless absolutely necessary. These tests may be sacredly guarding some obscure logic and we want to ensure things work years into the future. That said, this is just one perspective, and not a fixed rule. I appreciate this being brought up, but you'll realize that there's no hard and fast rules, only guidelines. |
Yes, I believe we should at least document these two rules! |
@weiji14 Thanks for the explanation; I'm pretty new to testing anything that isn't a simple return of a string/integer/float. In addition to the Python specific stuff, I think all of the aliases should be tested (as I mentioned in #769), and my thought is there should be a single test function that makes sure all of the aliases work; if any of them are mutually exclusive with another alias (no examples comes to mind for this, but I haven't dove too deep into the more advanced PyGMT functions) there should be a separate test that only changes the arguments in question. I don't think there should be advanced inputs, but just valid arguments to make sure that the Python wrapper plays nicely with the GMT API. |
In an ideal world yes, with a team of a hundred developers and unlimited Continuous Integration resources. In reality, time could be spent on more productive things. Aliases are not the weakest point in PyGMT, so we don't have to test all of them unless there's a bug caused by some very complex combination of parameters (which needs to be handled in a very specific way in Python). That said, you're welcome to write new tests for PyGMT for learning purposes, I know I certainly did! But in terms of a formal guideline, I don't think we should enforce such a strict set of rules. |
@weiji14 Good to know; thanks! |
Another point is that alias works for most cases unless there are typos, because adding a new alias is pretty easy (see #661 for an example PR, which adds the |
We should mention that we recommend using SI units in the documentation. |
The testing section on the contributing guide does a good job of explaining how to write tests, but doesn't really explain what should and should not be tested with the plotting functions. Looking through the tests (specifically the ones testing functions in
base_plotting.py
) there doesn't appear to be a standard for testing functions that pass arguments to the GMT API. My limited understanding makes me think the most important thing to test is the function's ability to take arguments for its aliases and pass them to GMT. There are some tests (such astest_basemap_winkel_tripel()
andtest_basemap_power_axis()
intest_basemap.py
and many of the tests intest_colorbar.py
) that test passing different arguments to the same parameters. While I understand the importance of testing that these will return functions, any errors seem like they would be upstream issues with GMT and not an issue with PyGMT itself. In an effort to standardize writing tests and reducing the amount of time spent testing, could there be some community consensus (and formal guidance) on how each wrapped GMT function should be tested?I'm happy to implement/change tests once a standard has been decided.
The text was updated successfully, but these errors were encountered: