-
-
Notifications
You must be signed in to change notification settings - Fork 481
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
pytest - fix scope in which doctests are run #33826
Comments
Commit: |
Dependencies: #33825 |
Branch pushed to git repo; I updated commit sha1. Last 10 new commits:
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:7
the issue with deprecation warnings is due to Trying to disable this via --- a/src/tox.ini
+++ b/src/tox.ini
@@ -232,7 +232,7 @@ exclude =
[pytest]
python_files = *_test.py
norecursedirs = local prefix venv build pkgs .git src/doc src/bin
-addopts = --import-mode importlib
+addopts = --import-mode importlib -p no:warnings
doctest_optionflags = NORMALIZE_WHITESPACE ELLIPSIS
[coverage:run]
gives a bit more info:
Note Perhaps the problem is in the way warning level is set in |
comment:8
With vanilla python pytest still needs a bit of monkey-patching of the warning system, namely, # c.py
import warnings
dowarn = warnings.showwarning
def showwarn(message, category, filename, lineno, file=None, line=None):
import sys
dowarn(message, category, filename, lineno, sys.stdout, line)
warnings.showwarning = showwarn # use stdout instead of stderr
class tst:
"""
>>> len(tst.__subclasses__()) >= 0
True
>>> import warnings
>>> warnings.warn("foo")
<doctest ...: UserWarning: foo
warnings.warn("foo")
"""
pass at least the above works:
It's still not clear how to fix Sage's pytesting: I tried a similar hack with |
comment:9
I've opened pytest-dev/pytest#10565 to check whether there is a better way than monkey-patching |
This comment has been minimized.
This comment has been minimized.
comment:11
Rebased over latest 9.8.beta4. The last addition, |
Author: Dima Pasechnik, ... |
Changed author from Dima Pasechnik, ... to Dima Pasechnik, Tobias Diez |
comment:16
https://github.com/sagemath/sagetrac-mirror/actions/runs/3643485912/jobs/6151758539 |
comment:17
Replying to Matthias Köppe:
not caused by the latest commit: without it, or with it, the same problem:
|
comment:18
Google finds a numeber of complaints about this error with matplotlib, and the answer appears to be to follow https://matplotlib.org/stable/devel/development_setup.html indeed, we apparently don't install |
comment:19
Why do we even try to run tests of matplotlib? Can they be suppressed? |
comment:20
Replying to Dima Pasechnik:
It's definitely not intended, it's supposed to run tests out of |
comment:21
Replying to Matthias Köppe:
well, it's late here, and is quite a long read... |
comment:22
Replying to Matthias Köppe:
some kind of trouble while discovering namespace packages to test.
but
there is quite a bit on this in pytest github: |
comment:23
Also note that
but
|
comment:24
And bad news from pytest-dev/pytest#1567 (comment) :
|
comment:25
Indeed, this is very bad. |
comment:26
The problem with PEP 420 implicit namespace packages for pytest and similar source discovery is that there is no clear way to find the root of a source tree. In Sage, there is a solution for that -- we have marker files So a sage-specific solution could be to monkey-patch https://github.com/pytest-dev/pytest/blob/main/src/_pytest/_py/path.py so that it understands the Sage source layout. For upstream pytest, perhaps an intermediate goal could be to have a documented hook that makes this monkey-patching easier. |
comment:27
Replying to Matthias Köppe:
please see the reply to pytest-dev/pytest#10569 (comment), basically, upstream says monkey-patching this will break, soon. On pytest-dev/pytest#10569 let us further discuss with the upstream how we can go forward here. |
comment:28
By the way, it's not just our doctests that are not run by pytest any more because of the PEP 420 issue. Also the pytest files |
comment:29
Replying to Matthias Köppe:
A more relevant place seems to be https://github.com/pytest-dev/pytest/blob/9fbd67dd4b1baa6889dbb2073c17b85da39f80d9/src/_pytest/python.py#L747 (Package.collect) |
comment:30
Anyway, should we move to |
comment:31
Yes, I think so |
(from #33546)
When running doctests via
sage --pytest
(added in #33546), there are many failed tests due to some issues with assumptions and/or symbolic variables and/or deprecation warnings.To see examples of these failures, run pytest on
UPDATE - deprecation warnings are OK, thanks to
92bbf1d
in comment:10CC: @tobiasdiez
Component: doctest framework
Author: Dima Pasechnik, Tobias Diez
Branch/Commit: public/build/pytest-github-action @
92bbf1d
Issue created by migration from https://trac.sagemath.org/ticket/33826
The text was updated successfully, but these errors were encountered: