Closed gnott closed 3 years ago
May also consider to use OrderedDict
as a replacement for all remaining plain old {}
dict in the parser. We use OrderedDict
regularly when generating some output, and it will probably have little negative speed or usability impacts. @giorgiosironi maybe you have some comments about switching to OrderedDict
for older function calls?
In PR https://github.com/elifesciences/elife-tools/pull/356, new test scenarios no longer use the old JSON files, and generate_test_fixtures.py
is now removed completely. Test cases and test fixtures are managed in the newer style. This issue can be closed now.
There are JSON file test fixtures in the project, currently in the
elifetools/tests/JSON/
folder. There's a scriptelifetools/tests/generate_expected_json.py
which can be used to help re-generate the fixtures.Running the generate script (after some modifications) does still generate
.json
file output, except since the contents of the JSON files are mostly simpledict
data, the inconsistent order of the dict keys causes the git diff of the files to vary more than they should to be useful test fixtures. At the very least, the keys of the dict can be sorted alphabetically before saving them as.json
files. Alternatively, output as anOrderedDict
may help with comparisons.Comparisons with the file fixtures can compare sorted dicts, or use the
assert equal dict
-style assertions.Another couple potential improvements are to move the
generate_test_fixtures.py
to the root folder of the project, and move theelifetools/tests
directory totests
instead.In summary, some proposed tests refactoring:
elifetools/tests
directory totests
generate_test_fixtures.py
to ~the root folder of the project~ thetests/
foldergenerate_test_fixtures.py
to make it Python 3 compatiblegenerate_test_fixtures.py
to output json with alpha sorted keys, and/or employOrderedDict
in some wayOrderedDict
more extensively in the parser itself (so far tests do still pass regardless of the json file dict key order)