-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Fix handling of warnings in the test runner #19247
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
Conversation
When running tests/doctests with sympy's own test runners a warning filter is used to turn DeprecationWarning/SymPyDeprecationWarning into an error. The filter was only set one at the start of running the tests. This means that if the filter is modified by one test then it will still be modified when subsequent tests run. This commit adds a raise_on_deprecated context manager in runtests.py and uses it to set the warning filter in the test runners. The filter is set immediately around running the test and is reset before each individual test. This has picked up on a couple of failures that will need to be fixed in subsequent commits.
The Basic.has method is changed from using sympify to _sympify so that string input is no longer accepted and so that functions are no longer parsed as strings. A line in solveset needed to be fixed because it was erroneously calling expr.as_independent([x, y]) rather than expr.as_independent(x, y). BREAKING CHANGE Basic.has no longer accepts strings so e.g. Symbol('x').has('x') will raise an exception.
The tableform doctest relied on implicit sympification of strings into symbols. This commit calls Symbol explicitly to remove the warning from sympify.
✅ Hi, I am the SymPy bot (v158). I'm here to help you write a release notes entry. Please read the guide on how to write release notes.
Note: This comment will be updated with the latest check if you edit the pull request. You need to reload the page to see it. Click here to see the pull request description that was parsed.
|
The Dict doctest relied on auto-sympification of strings in calling D.has('one'). This commit uses Symbol explicitly because has no longer accepts string input after 9c57fd0 BREAKING CHANGE: Using D.has('x') where D is a SymPy Dict will raise an exception. Use D.has(Symbol('x')) instead.
Codecov Report
@@ Coverage Diff @@
## master #19247 +/- ##
=============================================
- Coverage 75.674% 75.665% -0.009%
=============================================
Files 651 651
Lines 169486 169487 +1
Branches 40021 40021
=============================================
- Hits 128257 128244 -13
- Misses 35625 35626 +1
- Partials 5604 5617 +13 |
It would be great to have a speedy review on this. I can't bump the version on the 1.6 release branch without it but the fix here involves a breaking change that |
This looks good to me. I'm not sure that I quite understand what the nested context manager does but it seems to work. |
Thanks @jksuom. |
References to other Issues or PRs
See #19193 and #19242
Finishes unfinished work from #19006 which implements part of #18066.
Brief description of what is fixed or changed
The PR #19006 deprecates the string fallback in sympify which parses functions via str. Because the test runner did not always fail when warnings were raised some tests were still using the deprecated code path. This PR fixes the test runner so that deprecation warnings will always fail the bulid on Travis in both normal tests and doctests by setting/resetting the warning filter before/after each individual test.
Fixing the test runner lead to other failures for example a doctest that does
Here the sympify function (used in
has
) converts the sqrt function a string and tries to parse it leading to the deprecation warning. I've changed has to use_sympify
instead ofsympify
.Changing
Basic.has
lead to failures insolveset
which turned out to be due to a line erroneously callingexpr.as_independent([x, y])
rather thanexpr.as_independent(x, y)
. I've fixed that.There was also a doctest in printing that depended on automatic parsing of strings which I've changed to use Symbol explicitly.
Other comments
This is a PR against master so it can be reviewed. If this is merged in to master I will reopen it for the 1.6 branch (it is needed before updating the version in that branch). I will add the release note there:
Release Notes
NO ENTRY