Skip to content

pytester: testdir: revisit env setup #6687

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

Open
blueyed opened this issue Feb 7, 2020 · 1 comment
Open

pytester: testdir: revisit env setup #6687

blueyed opened this issue Feb 7, 2020 · 1 comment
Labels
plugin: pytester related to the pytester builtin plugin

Comments

@blueyed
Copy link
Contributor

blueyed commented Feb 7, 2020

Until not long ago Testdir.__init__ would set os.environ directly, then it was changed to use MonkeyPatch, and in master currently also sets some vars ($HOME) only during inner runs, e.g. within runpytest etc.
This was changed in features via #6219 most recently, which I consider kind of a regression to the behavior in master (initially I've done #6219 in a different way, addressing the issue that an outer monkeypatch gets not used, but then it got dragged into a simpler direction).

One issue with the current method is for example that e.g. pytest itself might be affected by this, since the patching is still active during teardown, and so e.g. the terminal plugin might be affected by it.

I'm not sure if $HOME etc should get only set "magically" during inner runs, but I think it makes sense to couple the patching to the test "call" phase as much as possible.
One approach for this might be to use pytest_runtest_call for this, which I've prototyped in blueyed#192.

But maybe there's a better method that would ensure a fixture (testdir) gets teared down before the terminal reporter (and other plugins) get called for the test report?

(Also changing os.environ during __init__ does not feel right to me - although given that this is a class to be used primarily as a fixture, but still.)

@blueyed blueyed added the plugin: pytester related to the pytester builtin plugin label Feb 7, 2020
@blueyed blueyed added this to the 5.4 milestone Feb 7, 2020
@blueyed blueyed removed this from the 5.4 milestone Feb 23, 2020
@blueyed
Copy link
Contributor Author

blueyed commented Feb 23, 2020

Removed from the milestone - I think it should not block a release (https://twitter.com/nicoddemus/status/1228131327431577606).
(especially since nobody appears to be interested in it besides me anyway)

@blueyed blueyed closed this as completed Aug 31, 2020
@blueyed blueyed reopened this Aug 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: pytester related to the pytester builtin plugin
Projects
None yet
Development

No branches or pull requests

1 participant