-
-
Notifications
You must be signed in to change notification settings - Fork 75
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
Bug: repeated dict keys in formatting testing results in some keys going untested. #162
Comments
See PR: #167 I made a PR to convert the dict of dicts of test cases into a list of tuples of test cases and expected results. After making this change some test cases were "uncovered". Some of these failed at an initial test. I went through and modified the unit tests until they all pass. Most or all of the test cases that were failing look like oversights in the construction of the unit tests but I'm not sure. Here's a summary of the changes needed to pass:
I can't tell if my updated expected values are in line with what is actually expected according to the documentation within the package documentation and within the code. I think most of the cases are benign just having to do with what default settings are for things like precision or the presence of parentheses when nothing is specified. Lines 1598 and 1640 are the most alarming to me since the first one had a big change from what was originally expected and the 1640 line has to do with a thorny edge case about decimals after integers. |
…rwrites (#167) This PR - Moves formatting code into a `test_formatting.py` module - Refactors `test_format` to use `pytest.mark.parametrize`. This solves #162 since cases are no longer stored as dict keys (which were accidentally repeated). Now each case is a 4-tuple. Previously test cases with the same value/uncertainty had the option to be grouped together within a dict under that value/uncertainty tuple. That option is lost since I don't really know how to do that in `pytest`. I've done this using `unittest.subTest` in the past, I think there might be a `pytest` extension that does something like this. - Removes checks and switch case for jython. Let me know if these need to be added back in. - Correction to some tests that were previously not running, but which are now failing <<add more detail here>> There is a lot of cruft in comments and possibly tests about subtleties between old versions of python. Hopefully this can be removed soon. ____ OLD DESCRIPTION: See #162. `tests` object containing test cases for ufloat string formatting is currently a dict where keys are tuples of value/uncertainty pairs and values are dicts of format string/expected output pairs. Similar tests are chunked together under the same value/uncertainty pair. However, the same value/uncertainty pair appears multiple times in the top level dict. In this case only one grouping of tests is captured in the dict, and all others are overwritten. To avoid this overwriting we can convert the dict of dicts into a list of tuples. In this case elements of the list are tuples whose first element is a value/uncertainty pair tuple and whose second element is a dict of format string/expected output pairs.
See for example
https://github.com/lebigot/uncertainties/blob/804adccf3401aeacbcbae0d669f92131fcd02c03/uncertainties/test_uncertainties.py#L1596-L1607
These are two ufloat value entries in test_format. Since the two dict entries have the same keys the latter overwrites the former and the cases in the former do not get tested.
Immediate solutions I see:
Not the most elegant probably but would at least fix this issue.
There are likely other possibilities.
The text was updated successfully, but these errors were encountered: