-
-
Notifications
You must be signed in to change notification settings - Fork 480
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
Preparse sage files before passing them to pytest #33550
Comments
see #27074 |
comment:2
Replying to @mkoeppe:
Thanks for the pointer. The code of this ticket could indeed be helpful for #27074. What would be a good place to put the added importlib loader so that the can easily be reused in #27074? |
comment:3
@kiwifb How did you manage to keep the temporary |
This comment has been minimized.
This comment has been minimized.
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:6
I went through the steps to produce it manually from a sage session. And then printed its name to have a look at it. |
comment:7
Replying to @tobiasdiez:
For #27074, the thought was that this should work globally so that users can use it with their local scripts. But last time I was looking into #27074, I came across an old discussion that Python does NOT support this (and wontfix) - installing such a global handler. Sorry, can't find it right now. |
This comment has been minimized.
This comment has been minimized.
comment:9
Replying to @kiwifb:
Okay thanks, that worked! |
comment:10
Replying to @mkoeppe:
Okay, then I would propose to keep the changes localized in conftest and if someone is working on #27074 it can be easily extracted. |
comment:11
This actually looks very nice and perhaps the classes The actual activation ( |
comment:12
Replying to @mkoeppe:
That would also work, but as long as they are only used for pytests I think it would make sense to leave them in conftest.py |
comment:13
No, the idea would be that we would not want to activate it by just loading the Sage library; but we may want to advertise it to sufficiently adventurous users. |
comment:14
Replying to @mkoeppe:
Don't you think that goes way beyond the scope of this ticket and would need proper documentation and more testing? |
comment:15
Good point, but note that we don't actually have any What you are trying to solve is a failure from testing the behavior of the Sage doctester on user files. And for this the metapath manipulation seems to be an overkill. |
comment:16
What would be an easier solution to register the sage file loader then? |
comment:17
Just skipping .sage files because there is no existing practice of having pytest tests in them. |
comment:19
Sure, it's fine. |
Branch pushed to git repo; I updated commit sha1. Last 10 new commits:
|
Branch has merge conflicts |
We fix
As analyzed in #33531 comment:9, this is due to pytest running on the temporary file
my_script.sage
and failing withIn other words, pytest doesn't know how to analyze
.sage
files. We fix this by letting pytest know that.sage
files are essentially normal python files after they run through the preparser (this is accomplished by implementing an importlib.Loader for.sage
files, which is then used by pytest).Sadly, this doesn't completely fix the issue and the above test in cmdline still fails. However, the error is now
which comes from some issues of pytesting files outside of the sage source directory. In fact, running
sage -t
on a copy of the offending file somewhere in/src
works.CC: @mkoeppe @tornaria @kiwifb
Component: doctest framework
Author: Tobias Diez
Branch/Commit: public/tests/pytest_sage_files @
24a0b17
Issue created by migration from https://trac.sagemath.org/ticket/33550
The text was updated successfully, but these errors were encountered: