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
[BEAM-3713] Add pytest for unit tests #9756
Conversation
run seed job |
1 similar comment
run seed job |
R: @chadrik This should be tested with a "run seed job", which should succeed. "run python_pytest precommit" will then launch a pytest-based precommit job (without ITs), but it's not critical that this job passes at this stage. |
This looks great. What's the plan for deploying it? Do you plan to merge it as is to get it in front of more users for testing, or will you replace nose with pytest before the merge? |
I will first merge the PR as is with separate targets for nose and pytest.
Once we are satisfied that we have no missing tests and people have had the
chance to try it, we'll switch over to pytest by default.
…On Thu, Oct 10, 2019, 09:16 Chad Dombrova ***@***.***> wrote:
This looks great. What's the plan for deploying it? Do you plan to merge
it as is to get it in front of more users for testing, or will you replace
nose with pytest before the merge?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#9756?email_source=notifications&email_token=AAA7FTZ3FUXXGSQBLHP7KOLQN5IOXA5CNFSM4I7GBNFKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEA45P7Y#issuecomment-540661759>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAA7FT4SQAAYJNUQCX4QDI3QN5IOXANCNFSM4I7GBNFA>
.
|
Sounds good.
…On Thu, Oct 10, 2019 at 2:26 PM Udi Meiri ***@***.***> wrote:
I will first merge the PR as is with separate targets for nose and pytest.
Once we are satisfied that we have no missing tests and people have had the
chance to try it, we'll switch over to pytest by default.
On Thu, Oct 10, 2019, 09:16 Chad Dombrova ***@***.***>
wrote:
> This looks great. What's the plan for deploying it? Do you plan to merge
> it as is to get it in front of more users for testing, or will you
replace
> nose with pytest before the merge?
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <
#9756?email_source=notifications&email_token=AAA7FTZ3FUXXGSQBLHP7KOLQN5IOXA5CNFSM4I7GBNFKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEA45P7Y#issuecomment-540661759
>,
> or unsubscribe
> <
https://github.com/notifications/unsubscribe-auth/AAA7FT4SQAAYJNUQCX4QDI3QN5IOXANCNFSM4I7GBNFA
>
> .
>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#9756?email_source=notifications&email_token=AAAPOE3N7DQIDJ5CXAWJUITQN5XUNA5CNFSM4I7GBNFKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEA5J34Q#issuecomment-540712434>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAPOE7ZW6LREEVESBKBRNLQN5XUNANCNFSM4I7GBNFA>
.
|
@@ -228,6 +229,8 @@ def test_biqquery_read_streaming_fail(self): | |||
r'source is not currently available'): | |||
p.run() | |||
|
|||
@pytest.mark.skipif(sys.version_info >= (3, 7), | |||
reason='TODO(BEAM-8095): Segfaults in Python 3.7') |
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.
hmmm... this only segfaults when using pytest? what happens if you disable xdist?
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.
I changed it to no_xdist
. It still segfaults when using xdist or when attempting to run under a debugger in PyCharm.
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.
Regarding problems with this test, see: https://issues.apache.org/jira/browse/BEAM-8397?focusedCommentId=16958087&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-16958087
@chadrik PTAL |
sdks/python/conftest.py
Outdated
if sys.version_info < (3,): | ||
collect_ignore_glob.append('*_py3.py') | ||
for minor in [5, 6, 7, 8, 9]: | ||
if sys.version_info < (3, minor): | ||
collect_ignore_glob.append('*_py3%d.py' % minor) |
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.
How about something like this:
MAX_SUPPORTED_PYTHON_VERSION = (3, 8)
# See pytest.ini for main collection rules.
collect_ignore_glob = []
if sys.version_info < (3,):
collect_ignore_glob.append('*_py3.py')
else:
for minor in range(sys.version_info.minor +1, MAX_SUPPORTED_PYTHON_VERSION[1] + 1):
collect_ignore_glob.append('*_py3%d.py' % minor)
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.
oh, btw, what did you think of this suggestion?
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.
IDK. It's more verbose but I don't have a preference.
Ideally, I'd like a single source of truth for the list of Python supported versions (python_requires
in setup.py is such a source but it's hard to parse).
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.
IDK. It's more verbose but I don't have a preference.
I think it'll be easier to maintain long term: just update the max support python version.
But maintainability aside, it seems a bit odd to test for our lower bound in a loop when we know precisely what the lower bound is: sys.version_info.minor +1
Ideally, I'd like a single source of truth for the list of Python supported versions (python_requires in setup.py is such a source but it's hard to parse).
true.
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.
But maintainability aside, it seems a bit odd to test for our lower bound in a loop when we know precisely what the lower bound is:
sys.version_info.minor +1
You're right.
I had two thoughts related to this today, as I struggled trying to diagnose some failed tests on jenkins.
|
Colors already work for me with tox and pytest. Let's get this PR merged so you can try it out yourself. :) |
Great. I've been digging into my problem with colored mypy output problem and I think it's a tty issue. I think mypy needs a mechanism to force colors even when a tty is not present.
I've also been thinking about investigating using tox's support fo parallel execution instead of gradle: https://tox.readthedocs.io/en/latest/example/basic.html#parallel-mode
Looks good to me! |
This is apache#7949 without IT support. - Runs unit tests using pytest - tox: `tox -e py27-gcp-pytest,py36-pytest,etc.` - gradle: `../../gradlew pythonPreCommitPytest` - github PR phrase: `run python_pytest precommit` - Tests run in parallel (still single-threaded but on multiple worker processes). - no_xdist marker used for tests that don't work the xdist plugin. - Allows specifying test module in tox cmd line. Example: ```sh tox -e py27-pytest apache_beam.transforms.window_test ```
... instead of completely skipping it for Python 3.7.
b0e79de
to
636f1ae
Compare
PTAL |
Looks good. I say we merge this once the tests are confirmed passing. |
Run Java PreCommit |
Run CommunityMetrics PreCommit |
Run Python PreCommit |
1 similar comment
Run Python PreCommit |
This is apache#7949 without IT support. - Runs unit tests using pytest - tox: `tox -e py27-gcp-pytest,py36-pytest,etc.` - gradle: `../../gradlew pythonPreCommitPytest` - github PR phrase: `run python_pytest precommit` - Tests run in parallel (still single-threaded but on multiple worker processes). - no_xdist marker used for tests that don't work the xdist plugin. - Allows specifying test module in tox cmd line. Example: ```sh tox -e py27-pytest apache_beam.transforms.window_test ```
This is #7949 without IT support.
This does not replace regular precommit/postcommit/tox environments.
Pytest will replace nose once we can verify all tests are collected by pytest and blocking bugs are solved (see BEAM-3713).
tox -e py27-gcp-pytest,py36-pytest,etc.
../../gradlew pythonPreCommitPytest
run python_pytest precommit
processes).
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
R: @username
).[BEAM-XXX] Fixes bug in ApproximateQuantiles
, where you replaceBEAM-XXX
with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.Post-Commit Tests Status (on master branch)
Pre-Commit Tests Status (on master branch)
See .test-infra/jenkins/README for trigger phrase, status and link of all Jenkins jobs.