Skip to content

Move doctests into Makefile and run with test-py #9929

@scottbarnes

Description

@scottbarnes

Proposal

We could (1) have our unit tests in one spot and (2) run them only once if we run pytest with --doctest-modules in the Makefile's test-py section. This feature is much desired (see, e.g., #9797 (comment)).

Justification

No response

Breakdown

Requirements Checklist

  • Remove the ignores in scripts/run_doctest.sh that can be removed without causing errors. (Related files below)
  • For the remaining tests that don't pass if they run (hence them being commented out), update either the function or the docstring test so things are correct and --ignore isn't needed for that file.
  • Update test-py in Makefile to also run --doctest-modules.
  • Ensure docker compose run --rm web make test-py runs successfully.

Related files

  • scripts/run_doctests.sh
  • Makefile

To jump start things, here's a diff with files that it seems can have their ignore removed from run_doctests.sh:

diff --git a/scripts/run_doctests.sh b/scripts/run_doctests.sh
index 3a8434df8..e47f2b4e6 100755
--- a/scripts/run_doctests.sh
+++ b/scripts/run_doctests.sh
@@ -14,26 +14,13 @@ set -e
 
 pytest --doctest-modules \
         --ignore=infogami \
-        --ignore=openlibrary/catalog/marc/tests/test_get_subjects.py \
-        --ignore=openlibrary/catalog/marc/tests/test_parse.py \
-        --ignore=openlibrary/catalog/add_book/tests \
-        --ignore=openlibrary/core/ia.py \
-        --ignore=openlibrary/plugins/akismet/code.py \
-        --ignore=openlibrary/plugins/importapi/metaxml_to_json.py \
         --ignore=openlibrary/plugins/openlibrary/dev_instance.py \
-        --ignore=openlibrary/plugins/openlibrary/tests/test_home.py \
-        --ignore=openlibrary/plugins/search/code.py \
-        --ignore=openlibrary/plugins/search/collapse.py \
-        --ignore=openlibrary/plugins/search/solr_client.py \
         --ignore=openlibrary/plugins/upstream/addbook.py \
         --ignore=openlibrary/plugins/upstream/jsdef.py \
         --ignore=openlibrary/plugins/upstream/utils.py \
-        --ignore=openlibrary/records/tests/test_functions.py \
         --ignore=openlibrary/tests/catalog/test_get_ia.py \
         --ignore=openlibrary/utils/form.py \
         --ignore=openlibrary/utils/schema.py \
-        --ignore=openlibrary/utils/solr.py \
         --ignore=scripts \
-        --ignore=tests \
         --ignore=vendor \
         .

Stakeholders


Instructions for Contributors

Please run these commands to ensure your repository is up to date before creating a new branch to work on this issue and each time after pushing code to Github, because the pre-commit bot may add commits to your PRs upstream.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Lead: @scottbarnesIssues overseen by Scott (Community Imports)Priority: 2Important, as time permits. [managed]Theme: TestingInvolves work related to testing infrastructure, development, and ops. [managed]Type: Feature RequestIssue describes a feature or enhancement we'd like to implement. [managed]

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions