-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Copy py.code code to py.test #1199
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
Copy py.code code to py.test #1199
Conversation
We should strongly investigate trimming that api down before making it public under pytest There should not be a pylib 2.0 we should consider pylib eol |
Bruno, thanks for tackling this! i think it's a good idea to first move to pytest.code without changing much. I would, however, not document or expose pytest.code -- maybe it's even better to name it pytest._code therefore. I'd also not remove py.code -- this breaks too much code as you already noted. IOW i think we can just copy py.code to pytest._code and treat it under new ownership there, with us feeling free to remove, streamline things as we go. this way, pytest-2.9 will "just work" and nothing will break which, given the huge installation numbers, is a better plan than conciously breaking things. If possible, removing some unused things from pytest._code after the initial merge is also a good idea so we don't start with too much cruft. Also deleting code is great :) We could of course still decide that we offer some public pytest.code at some point later. |
does anyone have any idea why pypy fails? |
I didn't have a chance to look it up yet. The failing test is from |
I will only have time to look it up next week though, I think. |
283dc43
to
7847ae2
Compare
Took another dab at this. 😅
ExceptionInfoOne thing I realized is that because of def test_foo():
with pytest.raises(RuntimeError) as exc_info:
foo()
assert isinstance(exc_info, py.code.ExceptionInfo) # <- works in 2.8, will break in 2.9 And the worst part is that the user would have to explicitly now import from Since py.code slipping unnoticed and wrecking havocSince we are not dropping I give it some thought I think we can solve that by writing a small flakes8 extension that checks for code accessing Another idea I had was to block py.code # lazy creation
del py.code
del sys.modules['py.code'] This seems to work well, but I fear that by the time the code executes other pytest modules have already been imported, and might already been holding references to functions or methods in What do you guys think? |
7847ae2
to
1e1e62c
Compare
I tested |
since we don't have a travis for pylib i suspect the bug has been there since a while, wrt selftesting, maybe we should as a long term goal ensure, that no import in pytest at the module level triggers a import of pylib, so we can kill the reliance on py.path and pathlib and we might want a local selftest python script, which does the sys.path mangleing before importing and running pytest.main |
Marked the
I like this idea, but unfortunately it does not work, there are other parts in I created a simple script with: if __name__ == '__main__':
# disable py.code from being importable
import sys
import py.code
del py.code
del sys.modules['py.code']
import pytest
raise SystemExit(pytest.main()) But using it to run the test suite I get errors like:
I think static checking might be the only option to enforce |
I wonder if the only problem source is py.path |
According to my Edit: |
Just to be clear, in my fork I deleted At this point I wonder if it is worth the trouble trying to do the |
Let's make that a part of review, new code that adds py.code usage should get extra scrutiny |
Seems reasonable. We can always introduce static checking later if we deem necessary. About where ExeptionInfo is implemented, we can keep it an implementation detail, that's how it looks now. Any other comments? @hpk42? |
Hi guys, anything else should work here? I would like to continue work on any pending tasks for this issue, if we still have any. |
we should ensure that the exposed api for this shows a pending deprecation warning various places, so we can work at replacing the exceptioninfo objects alltogther |
while migrating this code it was noticed that this test was failing even on the original py repository, so it was decided to xfail it and investigate later
706b496
to
7891dc0
Compare
Hey @RonnyPfannschmidt and @hpk42, Just rebased this into the |
i think it needs a more visible note about the move all in all well done, thanks :) |
It's in |
we do have some object exposure points that are unfortunate (raises and traceback cutting/report information) |
7891dc0
to
4825678
Compare
I increased the importance of the node like @RonnyPfannschmidt asked and moved it to the top to gain more visibility. |
For your convenience, you can see it rendered here. |
Copy py.code code to py.test
Well done, thanks for the hard work |
@hpk42 @RonnyPfannschmidt, few things to discuss still:
py.code
has a lot of public members which are well documented. To move the documentation over to pytest we should also make those classes public IMO. Should they live in thepytest
namespace, or some other namespace likepytest.code
?py
from my repository, withpy.code
removed; all tests forpy
are passing on that repository, I will open a PR forpy
later once we agree on how the docs should be moved.py
should be bumped to2.0
. Unfortunately all pytest versions out there have the specpy>=1.4.29
(or something), which would cause them to try to use2.0
when installing an older version. Not sure how to solve this.(There's a single test failing on
pypy
on Travis, I will investigate this later)Fix #103