Skip to content
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

sage --pytest does not support out of Sage tree Sage doctests #34829

Open
dimpase opened this issue Dec 7, 2022 · 4 comments
Open

sage --pytest does not support out of Sage tree Sage doctests #34829

dimpase opened this issue Dec 7, 2022 · 4 comments

Comments

@dimpase
Copy link
Member

dimpase commented Dec 7, 2022

Running sage --pytest foo.py on an out of tree foo.py ignores sage:-prompted docstrings, and happily tests >>>-prompted docstrings. E.g. with

# foo.py
class tst:
    """
    sage: len(tst.__subclasses__()) >= 0
    True
    """
    pass

one has

$ ./sage --pytest src/sage/interfaces/foo.py 
===================================== test session starts ======================================
platform linux -- Python 3.9.2, pytest-7.1.3, pluggy-1.0.0
rootdir: /home/dimpase/work/software/sage/src, configfile: tox.ini
collected 1 item                                                                               

src/sage/interfaces/foo.py .                                                               [100%]

====================================== 1 passed in 0.04s =======================================

but

$ ./sage --pytest foo.py 
===================================== test session starts ======================================
platform linux -- Python 3.9.2, pytest-7.1.3, pluggy-1.0.0
rootdir: /home/dimpase/work/software/sage/src
collected 0 items                                                                              

==================================== no tests ran in 0.01s =====================================

So there is some magic happening here, with tox.ini used in the former case, but not in the latter case.

Component: doctest framework

Issue created by migration from https://trac.sagemath.org/ticket/34829

@dimpase dimpase added this to the sage-9.8 milestone Dec 7, 2022
@mkoeppe
Copy link
Contributor

mkoeppe commented Dec 7, 2022

comment:1

src/conftest.py has the magic

@mkoeppe
Copy link
Contributor

mkoeppe commented Dec 7, 2022

comment:2

It would probably be sufficient if we document how user projects should configure pytest by providing their own confest.py

@dimpase
Copy link
Member Author

dimpase commented Dec 7, 2022

comment:3

Replying to Matthias Köppe:

src/conftest.py has the magic

Thanks. Perhaps you also know where to monkey-patch warnings.showwarning - see
#33826 comment:8 -
so that pytest correctly processes deprecation warnings in doctests...

@dimpase
Copy link
Member Author

dimpase commented Dec 7, 2022

comment:4

Oh, it can be monkey-patched in src/conftest.py - it's in a diffrent format then, so that's something to look into...

@mkoeppe mkoeppe removed this from the sage-9.8 milestone Jan 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants