Skip to content

Commit

Permalink
Convert tests from dict of dicts to list of tuples to avoid key ove…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
jagerber48 authored Aug 9, 2024
1 parent f097015 commit ce16269
Show file tree
Hide file tree
Showing 2 changed files with 513 additions and 604 deletions.
Loading

0 comments on commit ce16269

Please sign in to comment.