-
-
Notifications
You must be signed in to change notification settings - Fork 5
pytester
plugin messes up scipy imports in tests
#184
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
Comments
I think that this bug was meant to be about It looks like 1.15.2 was released on 2025-02-16, so it might be possible to proceed with this. I’m not able to reproduce issues with |
#187 is still red. Not sure what the reason is, and indeed I run with scipy==1.5.2 locally with no problem. So at a guess it's something about the CI setup. Did not have time to figure it out. If you've ideas, they're greatly appreciated. |
It’s an odd issue, indeed. scipy/scipy#22257 (comment) seems suspiciously similar, and I asked the reporter if they have any more information. I am able to reproduce it on
I started with Python 3.11 because that’s what the CI was trying when it failed, but I can reproduce it with 3.12 and 3.13, too. |
https://github.com/scipy/scipy/blob/main/scipy/optimize/_highspy/meson.build#L65-L72 generates the apparently problematic module |
It’s not quite the same issue as the original report scipy/scipy#22257, but there is still something messy going on with global state. Simply running |
Perhaps we can make the error go away by tweaking Pytest assertion rewriting? That's my most recent memory of a bug only reproducible via pytest |
scipy <= 1.4.1
after scipy 1.5.2 is out.scipy <= 1.14.1
after scipy 1.15.2 is out.
Okay, I can now repro under python 3.13. Am pretty sure it did not error under self-built scipy ( To make it more bizzare:
When it fails, dropping a breakpoint shows something really weird:
|
Re assertion rewrites: #166 did have to work around it. Running
shows the same error. |
how bizarre!
I feel like this warrants a pytest issue, no? Not that a MRE will likely be easy |
More breadcrumbs: $ git diff
diff --git a/scipy_doctest/frontend.py b/scipy_doctest/frontend.py
index 165d5d4..fbe4b19 100644
--- a/scipy_doctest/frontend.py
+++ b/scipy_doctest/frontend.py
diff --git a/scipy_doctest/tests/test_testmod.py b/scipy_doctest/tests/test_testmod.py
index 250b2e9..783570a 100644
--- a/scipy_doctest/tests/test_testmod.py
+++ b/scipy_doctest/tests/test_testmod.py
@@ -19,6 +19,8 @@ try:
except Exception:
HAVE_SCIPY = False
+from scipy.stats import levene
+
from . import (module_cases as module,
stopwords_cases as stopwords,
finder_cases, makes the error go away. |
Trying it without scipy-doctest or with it but outside of the test suite: all seems good.
So the error is somewhere in how the test suite is organized. I think the key is to understand the difference between what we do locally and what goes on the scipy CI: https://github.com/scipy/scipy/blob/75452588839d75a562c77c014ac027c3a7ed4ee7/.circleci/config.yml#L187 |
Now, this reminds me of #131 (comment) So I added the workaround to #187. Will try bisecting as a last ditch attempt at figuring if it's scipy-doctest. If that does not find anything, yeah, probably an upstream issue is called for. |
No dice: going all the way down to |
Well, I'm not really sure what to report 😅 I doubt they will be very amenable to just "here's our whole test suite, why does it pass with this command but fail with this other one" |
Okay, so
I asked the best I could distill at hopefully the right forum: pytest-dev/pytest#13353 On a bright side @musicinmybrain , the problem is definitely within the scipy-doctest testing machinery. It might take a while to sort out, but whatever the fix, it should not block your packaging work, I'd think. |
Thanks. I’ll monitor this issue, and if Fedora’s scipy package is updated to 1.15.x before you find a proper resolution, the workaround in #187 should suffice as a patch. |
Reopen to keep track of an upstream issue, pytest-dev/pytest#13353 |
scipy <= 1.14.1
after scipy 1.15.2 is out.pytester
plugin messes up scipy imports in tests
Had to add in #183 for otherwise
scipy==1.5.1
was failing tofrom scipy.stats import levene
.The error was somewhere in scipy internals, it was failing to import something about
highspy
. So hopefully it'll resolve itself once 1.5.2 is available.The text was updated successfully, but these errors were encountered: