Skip to content
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

gh-111031: Check more files in test_tokenize #111032

Merged
merged 2 commits into from
Oct 19, 2023

Conversation

sobolevn
Copy link
Member

@sobolevn sobolevn commented Oct 18, 2023

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

By default, this test only tests a random sample of ten test files:

if not support.is_resource_enabled("cpu"):
testfiles = random.sample(testfiles, 10)

You have to pass -ucpu to run the test on all test files. If I run python -m test test_tokenize -ucpu with your PR branch, the test fails:

======================================================================
ERROR: test_random_files (test.test_tokenize.TestRoundtrip.test_random_files) (file='C:\\Users\\alexw\\coding\\cpython\\Lib\\test\\test_fstring.py')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\alexw\coding\cpython\Lib\test\test_tokenize.py", line 1915, in test_random_files
    self.check_roundtrip(f)
  File "C:\Users\alexw\coding\cpython\Lib\test\test_tokenize.py", line 1812, in check_roundtrip
    tokens2_from2 = [tok[:2] for tok in tokenize.tokenize(readline2)]
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\alexw\coding\cpython\Lib\tokenize.py", line 445, in tokenize
    yield from _generate_tokens_from_c_tokenizer(rl_gen.__next__, encoding, extra_tokens=True)
  File "C:\Users\alexw\coding\cpython\Lib\tokenize.py", line 541, in _generate_tokens_from_c_tokenizer
    raise TokenError(msg, (e.lineno, e.offset)) from None
tokenize.TokenError: ('unterminated string literal (detected at line 708)', (708, 40))

@bedevere-app
Copy link

bedevere-app bot commented Oct 18, 2023

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@sobolevn
Copy link
Member Author

Hm, indeed. Let's convert this PR to remove other stuff (I planned to create 2 PRs anyway for this).

These also all seem to pass, though I'm not sure why they're currently removed (there's no comment indicating why)

5f6fa82#diff-b07c4f10c75a22e102f114227a0a9b7b763ddda7a330109994e69b29540ea9bbL583-L586

Maybe it was due to time concerns

Before:

» ./python.exe -m test -ucpu test_tokenize -m test_random_files
Using random seed 454459699
0:00:00 load avg: 1.23 Run 1 test sequentially
0:00:00 load avg: 1.23 [1/1] test_tokenize

== Tests result: SUCCESS ==

1 test OK.

Total duration: 17.4 sec
Total tests: run=1 (filtered)
Total test files: run=1/1 (filtered)
Result: SUCCESS

After (+1 sec):

» ./python.exe -m test -ucpu test_tokenize -m test_random_files  
Using random seed 1054419542
0:00:00 load avg: 1.28 Run 1 test sequentially
0:00:00 load avg: 1.28 [1/1] test_tokenize

== Tests result: SUCCESS ==

1 test OK.

Total duration: 18.8 sec
Total tests: run=1 (filtered)
Total test files: run=1/1 (filtered)
Result: SUCCESS

@sobolevn sobolevn changed the title gh-111031: Check test_fstring.py in test_tokenize gh-111031: Check more files in test_tokenize Oct 18, 2023
@sobolevn sobolevn added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Oct 18, 2023
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @sobolevn for commit 45944b9 🤖

If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Oct 18, 2023
@AlexWaygood AlexWaygood added the needs backport to 3.12 bug and security fixes label Oct 18, 2023
Copy link
Member

@sunmy2019 sunmy2019 left a comment

Choose a reason for hiding this comment

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

Yeah, this is now correct. We still cannot untokenize test_fstring.py yet.

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

Just one buildbot failure, and test_tokenize passed on that buildbot. Thanks!

@AlexWaygood AlexWaygood merged commit e9b5399 into python:main Oct 19, 2023
100 of 105 checks passed
@miss-islington-app
Copy link

Thanks @sobolevn for the PR, and @AlexWaygood for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 19, 2023
(cherry picked from commit e9b5399)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
@bedevere-app
Copy link

bedevere-app bot commented Oct 19, 2023

GH-111061 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 bug and security fixes label Oct 19, 2023
@AlexWaygood
Copy link
Member

I'll defer to Pablo and Lys, but I feel we probably shouldn't backport this to 3.11, since the tokenizemodule is implemented completely differently in Python 3.11. 3.12 should be fine, though.

@lysnikolaou
Copy link
Contributor

I'll defer to Pablo and Lys, but I feel we probably shouldn't backport this to 3.11, since the tokenizemodule is implemented completely differently in Python 3.11. 3.12 should be fine, though.

Yup, 3.12 should be fine, but not 3.11.

AlexWaygood pushed a commit that referenced this pull request Oct 19, 2023
…11061)

gh-111031: Check more files in `test_tokenize` (GH-111032)
(cherry picked from commit e9b5399)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip news tests Tests in the Lib/test dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants