Skip to content

Revert #10603 so that conftest.py belongs to python_tests again#10619

Merged
Eric-Arellano merged 5 commits intopantsbuild:masterfrom
Eric-Arellano:conftest-round2
Aug 15, 2020
Merged

Revert #10603 so that conftest.py belongs to python_tests again#10619
Eric-Arellano merged 5 commits intopantsbuild:masterfrom
Eric-Arellano:conftest-round2

Conversation

@Eric-Arellano
Copy link
Copy Markdown
Contributor

@Eric-Arellano Eric-Arellano commented Aug 15, 2020

In #10603, we moved conftest.py from python_tests to python_library. This is because Pants now runs file-at-a-time for Pytest thanks to the model change in #10511. This causes conftest.py to error because it doesn't have any test files.

We decided in #10603 that conftest.py should be under python_library because it is not actual tests. For example, test util code goes under a python_library target already.

However, python_library owning a conftest.py by default ended up being problematic, as it caused test code to be mixed with production code, which is generally not desired. See #10613 for an approach to fix this.

Instead of adding a conftest target, this PR instead moves back conftest.py to python_tests and special cases pytest_runner.py to skip conftest.py. Even though this is less correct, it's simpler for users and it avoids making 1.x users having to change a bunch of things. Conceptually, conftest.py can be seen as "config" for tests, rather than traditional "test utils" like you'd have in a python_library.

[ci skip-rust]

…an `python_tests` (pantsbuild#10603)"

This reverts commit 255f9e0.

[ci skip-rust]

[ci skip-build-wheels]
…s` again

# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
@Eric-Arellano
Copy link
Copy Markdown
Contributor Author

I still need to add a PR description, but wanted to get this up before I have to leave for the next 2 hours.

@coveralls
Copy link
Copy Markdown

coveralls commented Aug 15, 2020

Coverage Status

Coverage remained the same at 0.0% when pulling b11e14f on Eric-Arellano:conftest-round2 into 6f243d7 on pantsbuild:master.


@rule(desc="Run Pytest in an interactive process")
async def debug_python_test(test_setup: TestTargetSetup) -> TestDebugRequest:
def debug_python_test(setup: TestTargetSetup) -> TestDebugRequest:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

async?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for async if there are no awaits in the rule.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels like a gotcha, if someone adds await they will have to notice this and add async. Although that's just a normal demand of asyncio, so maybe it's fine.

Yeah, it's fine.

# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
@Eric-Arellano
Copy link
Copy Markdown
Contributor Author

PR description added.

# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]

@rule(desc="Run Pytest in an interactive process")
async def debug_python_test(test_setup: TestTargetSetup) -> TestDebugRequest:
def debug_python_test(setup: TestTargetSetup) -> TestDebugRequest:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels like a gotcha, if someone adds await they will have to notice this and add async. Although that's just a normal demand of asyncio, so maybe it's fine.

Yeah, it's fine.

@Eric-Arellano Eric-Arellano merged commit 659ffd6 into pantsbuild:master Aug 15, 2020
@Eric-Arellano Eric-Arellano deleted the conftest-round2 branch August 15, 2020 14:55
Eric-Arellano added a commit that referenced this pull request Aug 17, 2020
This allows us to output the original exit code to the user, which is helpful because Pytest codes are significant.

This PR also fixes an issue with `test --debug` unintentionally running on `conftest.py` files. Per #10619, we special case that file to skip it.

[ci skip-rust]
[ci skip-build-wheels]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants