-
Notifications
You must be signed in to change notification settings - Fork 437
test: add marker for running tests in subprocess #3383
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
645eca0
to
1141a3c
Compare
we'd probably want a ability to set/override env variables would be useful |
a202ce0
to
e1cc496
Compare
e1cc496
to
1d20866
Compare
1d20866
to
e2c65cd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you have an example of a failure? what they look like?
other than figuring out where we can put some usage docs for this, this is cool.
|
403dddd
to
c24b15b
Compare
0c89660
to
8dfa5dc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool, just a few open questions.
we can handle at any point as a follow-up, but I'd like to see the "provide a function, execute in a subprocess and get out/err/status back" part as a helper function. definitely useful for when we need to do anything fancy with out/err outside of direct comparisons
8dfa5dc
to
917f5fd
Compare
917f5fd
to
058ce4b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is super cool and overall I like the idea but am a little concerned about the magic, particularly for debugging if/when something goes wrong and for new users to the library.
I'm not sure it's intuitive to a new user if/what/how the code runs in the subprocess (scope, environment used). Having the code in a string indicates that it's scoped outside the current program with a given environment.
It's really nice that we can lint/format subprocess test code but I think we'll need to # noqa
quite often since there could be variable scoping and import issues.
Also, by having to parse and compile the code we distance ourselves from running code as it would run in the real world (something might run fine in this but not in reality) which was one of the primary motivations behind subprocess testing.
@Kyle-Verhoog thanks for your 👀 on this and the comments!
Perhaps we can improve the documentation? I think in general each test case has some implicit assumptions about scope and environment as they ought to be independent from each other. But I agree this is taking these guarantees a step further.
IMO this actually gives an idea of the kind of issues actual code used by customers would produce. Perhaps if we find that we use a lot of
I'm not sure I agree with this. In the end Python does the same thing when it processes a |
058ce4b
to
b0a267a
Compare
True, I'm just a tad worried about pushing it further for new-comers and contributors.
Yeah I think my concern was around shadowing of variables and such which would be detected as linting issues but don't apply because of the code executing in isolation in another process.
Yeah on second look the parsing and compiling isn't too complex and given how the function code is isolated I think I'm convinced that this isn't an issue 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just my two comments left to address, otherwise lgtm!!
b0a267a
to
5abab0b
Compare
5abab0b
to
b6dee67
Compare
b6dee67
to
0928d61
Compare
The run pytest marker can be used to run arbitrary Python code in a Python subprocess. This is meant to replace the existing fixture to allow actual Python code to be written and tested, instead of using literal strings.
0928d61
to
421931e
Compare
@Mergifyio backport 1.0 |
The `subprocess` pytest marker can be used to run arbitrary Python code in a Python subprocess. This is meant to replace the existing fixture to allow actual Python code to be written and tested, instead of using literal strings. ## Checklist - [ ] Added to the correct milestone. - [ ] Tests provided or description of manual testing performed is included in the code or PR. - [ ] Library documentation is updated. - [ ] [Corp site](https://github.com/DataDog/documentation/) documentation is updated (link to the PR). (cherry picked from commit c437ad2)
✅ Backports have been created
|
The `subprocess` pytest marker can be used to run arbitrary Python code in a Python subprocess. This is meant to replace the existing fixture to allow actual Python code to be written and tested, instead of using literal strings. ## Checklist - [ ] Added to the correct milestone. - [ ] Tests provided or description of manual testing performed is included in the code or PR. - [ ] Library documentation is updated. - [ ] [Corp site](https://github.com/DataDog/documentation/) documentation is updated (link to the PR). (cherry picked from commit c437ad2) Co-authored-by: Gabriele N. Tornetta <[email protected]>
@Mergifyio backport 0.x |
The `subprocess` pytest marker can be used to run arbitrary Python code in a Python subprocess. This is meant to replace the existing fixture to allow actual Python code to be written and tested, instead of using literal strings. ## Checklist - [ ] Added to the correct milestone. - [ ] Tests provided or description of manual testing performed is included in the code or PR. - [ ] Library documentation is updated. - [ ] [Corp site](https://github.com/DataDog/documentation/) documentation is updated (link to the PR). (cherry picked from commit c437ad2) # Conflicts: # tests/contrib/httpx/test_httpx.py # tests/integration/test_integration.py # tests/tracer/test_encoders.py
✅ Backports have been created
|
) * test: add marker for running tests in subprocess (#3383) The `subprocess` pytest marker can be used to run arbitrary Python code in a Python subprocess. This is meant to replace the existing fixture to allow actual Python code to be written and tested, instead of using literal strings. Co-authored-by: Gabriele N. Tornetta <[email protected]> Co-authored-by: Kyle Verhoog <[email protected]>
@Mergifyio backport 0.61 |
The `subprocess` pytest marker can be used to run arbitrary Python code in a Python subprocess. This is meant to replace the existing fixture to allow actual Python code to be written and tested, instead of using literal strings. ## Checklist - [ ] Added to the correct milestone. - [ ] Tests provided or description of manual testing performed is included in the code or PR. - [ ] Library documentation is updated. - [ ] [Corp site](https://github.com/DataDog/documentation/) documentation is updated (link to the PR). (cherry picked from commit c437ad2) # Conflicts: # tests/contrib/httpx/test_httpx.py # tests/integration/test_integration.py # tests/tracer/test_encoders.py
✅ Backports have been created
|
1 similar comment
✅ Backports have been created
|
) * test: add marker for running tests in subprocess (#3383) The `subprocess` pytest marker can be used to run arbitrary Python code in a Python subprocess. This is meant to replace the existing fixture to allow actual Python code to be written and tested, instead of using literal strings. ## Checklist - [ ] Added to the correct milestone. - [ ] Tests provided or description of manual testing performed is included in the code or PR. - [ ] Library documentation is updated. - [ ] [Corp site](https://github.com/DataDog/documentation/) documentation is updated (link to the PR). (cherry picked from commit c437ad2) # Conflicts: # tests/contrib/httpx/test_httpx.py # tests/integration/test_integration.py # tests/tracer/test_encoders.py * fix conflicts * Use pytest marker to generate snapshot, set variants pull/4418 Co-authored-by: Gabriele N. Tornetta <[email protected]> Co-authored-by: Munir Abdinur <[email protected]> Co-authored-by: Munir Abdinur <[email protected]>
The
subprocess
pytest marker can be used to run arbitrary Python code in a Pythonsubprocess. This is meant to replace the existing fixture to allow actual
Python code to be written and tested, instead of using literal strings.
Checklist