You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To ease our minds a bit, perhaps we could add something about encouragement of implementing pytest in the codebase in a paragraph in the contributor guide, and then link out to some good tutorials or so on best practices around building unit tests with pytest? It seems beyond the scope of the contribution guide for alto2txt to include anything extremely long, but perhaps an example of how we've implemented pytest thus far could be included?
For example, an explanation of this (and how it's using both pytest and icecream?):
deftest_output_dir_args(tmp_path):
# Use the `tmp_path` fixture to ensure that the so-called "non-existant" dirs aren't# later inadvertently created within the repo.# Test that a non-existant `txt_out_dir` is created, including if it is a very deeply nested dir.# output_dir = tmp_path / "non-existant-output-dir"output_dirs_list= [
tmp_path/"non-existant-output-dir",
tmp_path/"a"/"b"/"c"/"d"/"very"/"deeply"/"nested"/"nonexistent"/"dir",
]
foroutput_dirinoutput_dirs_list:
assertnotoutput_dir.exists()
sys.argv[1:] = ["demo-files", str(output_dir)]
extract_publications_text.main()
assertoutput_dir.exists()
# Check that passing a existing file (rather than a dir) is caughtfile_not_dir=tmp_path/"output-file.txt"file_not_dir.touch()
withpytest.raises(AssertionError) asae:
sys.argv[1:] = ["demo-files", str(file_not_dir)]
extract_publications_text.main()
assertae.match("output-file.txt")
assertae.match("txt_out_dir.+not a directory")
Write out an example of running tests locally via
pytest
and encourage that for future contributors.The text was updated successfully, but these errors were encountered: