-
Notifications
You must be signed in to change notification settings - Fork 5
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
Refactor/new docstrings styling #169
Conversation
This commit implements the necessary logic to use a pytest-powered alternative to the Sagemath doctests `#long time` mark that allows to skip some doctests dinamically with CLI parameters.
I made one change to the name of the flag from ### Previous
### >>> if not long_doctests:
### ... pytest.skip()
### New
>>> if skip_long_doctests:
... pytest.skip() And the testing process looks now like this
It would be great if this PR could have at least three approvals as it redefines a new standard for the library. Please let me know if there are any objections. |
- Refactoring of the `make docker-test` and `make docker-testfast` commands in the Makefile, so we are able to disable the Sage doctest execution in whole directories. This allows us to made the transition to python doctests in a safe way, because every doctest will be executed either by Sage with the `docker-test` command or by Python with the new `docker-pytest` command. - Deprecation of the previous `docker-pytest` as it wasn't used by our CI, doesn't use pure python, and wasn't well-defined in its scopes (involving sage testings, for example). - Introduction of the new `docker-pytest` command to run pytest with pure python, in the directories that are progressively disabled in the `docker-test` command.
- Introduced a new GH Action step, running the new make command `docker-pytest` to preserve testing across the docstring migration
As shown in ad0b9d1, a problem emerges with the CI when changing the docstring style. The problem: Sage collects not only doctests with the Sage format, but also doctests with the Python format. Because the new format uses a feature that we only want to execute (and can provide) with Pytest and pure Python (the The solution idea: We need to be able to:
This way, we will make a safe testing transition in each PR, as in any state of the repo, every doctest will be evaluated by either Sage or Python, but not both. Solution implementation:
Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks very good.
Cool approach for splitting the tests for sage
and python
.
Quality Gate passedIssues Measures |
Applied changes discussed at #169 to SDEstimator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
Applied changes discussed at #169 to SDFq estimator.
Applied changes discussed at #169 to MQEstimator.
Description
After three weeks researching about alternatives to run doctests dinamically, I finally found how to put the pieces together. The result is this PR where we have:
I made the changes in just one file so we can discuss any aspect, before go all-in.
How this changes work
At
conftest.py
pytest
CLI execution, as well as a new pytest CLI option called--long-doctests
, that defaults to False but changes to True when provided.long_doctests
variable that is later passed to the "context" of our doctests viadoctest_namespaces
fixturesAt
sd_estimator.py
We now have to collect all the tests that could take a long time to run, and put them at the end of the
Tests:
section. This way, we can use thelong_doctests
flag comming from the pytest context, and with the conditionalEnsure that every test block after that will be run only if the flag
long_doctests
is True (i.e., if we made thepytest
call with the--long-doctests
option).Pros and drawbacks
Pros
#long time
functionality of Sage markers is, essentially, preserved.Drawbacks
Tests
section.--long-doctests
option is not provided to thepytest
call, all the tests containing long test are reported as skipped instead of passed. While this shouldn't have any technical implication, because short failing tests still produces a pytest error, I think it's worth to mention it.Review process
pytest --doctest-modules cryptographic_estimators/SDEstimator/sd_estimator.py
in the shell. It will work, and the pytest return will be1 skipped
.Examples:
section of the docstring, and save the file. Run the same command again and, as expected, pytest will return1 failed
.pytest --long-doctests --doctest-modules cryptographic_estimators/SDEstimator/sd_estimator.py
. Long tests defined after the previousd conditional, will be executed and the pytest call will return1 passed
.Pre-approval checklist