Skip to content

gh-71339: Use new assertion methods in tests #129046

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
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Jan 20, 2025

They provide better error report.

Only 1-2 lines are changed in the half of files, 3-4 lines in other quarter of files, and only in about 10 files there are more than 10 changed lines. So all this have been united in a single PR.

@picnixz
Copy link
Member

picnixz commented Jan 20, 2025

Not sure if it's me or not, but having that many files to review makes my GH interface crash (or load very slowly). Would it be possible to split this PR, at least per folders? just so that 1) it reduces the number of review requests 2) it helps us to review if possible?

@serhiy-storchaka
Copy link
Member Author

I have already already created 15 other PRs for groups of files with significant number of changes. But it is not worth to create a PR for 5 changed lines in 2 files.

@erlend-aasland
Copy link
Contributor

Merging in main should fix CI.

@picnixz
Copy link
Member

picnixz commented Jan 20, 2025

(Once #129060 has been merged)

@erlend-aasland
Copy link
Contributor

(Once #129060 has been merged)

Doh, of course; in my head, CI was already done and my PR was merged 😆

@@ -3251,14 +3251,14 @@ def x(self): pass
class EmptyProtocol(Protocol): pass

@runtime_checkable
class SupportsStartsWith(Protocol):
class SupportsStartswith(Protocol):
Copy link
Member

Choose a reason for hiding this comment

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

Not sure why this name was changed, could you undo changes to this file?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch. I initially wrote all this for assertStartsWith. Then I replaced "With" with "with". Then I replaced back "with" with "With", but used more strict patterns to avoid false positives, so some names left changed.

Copy link
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

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

I'll trust you on this one as they are so many files to review (I've reviewed the first 30 files and my file). I assume you actually used a regex or something like that to replace the occurrences but if the test suite is running fine I think we're good. To be sure I'd run this with build bots as well in case local testing was skipping some tests.

Instead of splitting the PR by folders I should have probably asked to split it per usage (namely one PR for hasattr tests, one for issubclass tests, etc) but let's keep this one now that we have it (if there are more PRs after this one, just keep in mind that it's easier to review the same mechanical change across multiple files rather than multiple mechanical changes)

@picnixz picnixz added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Jan 21, 2025
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @picnixz for commit cc1f37a 🤖

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 Jan 21, 2025
@picnixz
Copy link
Member

picnixz commented Jan 21, 2025

(Oh maybe I shouldn't have scheduled build bots if you had other commits... sorry in advance, though I can look at the buildbots status page)

@terryjreedy
Copy link
Member

terryjreedy commented Jan 23, 2025

I was checking test_idle when I found this PR in my mailbox. (EDIT) 10 rather than just 2 idle tests can be changed and I want to backport them. I think it easiest if I make a separate PR (DONE, #129213) attached to the same issue I copied the 2 changes made here so there should be no conflict.

EDIT The IDLE changes are merged and backported.

@terryjreedy
Copy link
Member

terryjreedy commented Jan 23, 2025

I non-recursively searched self.assert.*(issubclass|hasattr|startswith|endswith) inF:\dev\3x\Lib\test\test_t*.py (with IDLE) and found the same change candidates in the test_t*.py files included here (and only a couple of false positives). The replacements all looked right.

This is the 1 AMD64 Android failure.

======================================================================
FAIL: testAssertHasAttr (test.test_unittest.test_case.Test_TestCase.testAssertHasAttr)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/user/0/org.python.testbed/files/python/lib/python3.14/test/test_unittest/test_case.py", line 803, in testAssertHasAttr
    with self.assertRaises(self.failureException) as cm:
         ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: AssertionError not raised

@serhiy-storchaka
Copy link
Member Author

The patch was initially created in 2016. It was then updated few years later, and just before creating this PR. Since the IDLE tests are located outside of the Lib/test tree, I missed new tests there.

@mhsmith
Copy link
Member

mhsmith commented Jan 23, 2025

!buildbot ios

@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @mhsmith for commit cc1f37a 🤖

The command will test the builders whose names match following regular expression: ios

The builders matched are:

  • iOS ARM64 Simulator PR

@mhsmith
Copy link
Member

mhsmith commented Jan 23, 2025

!buildbot android

@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @mhsmith for commit cc1f37a 🤖

The command will test the builders whose names match following regular expression: android

The builders matched are:

  • aarch64 Android PR
  • AMD64 Android PR

@mhsmith
Copy link
Member

mhsmith commented Jan 23, 2025

!buildbot android

@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @mhsmith for commit cc1f37a 🤖

The command will test the builders whose names match following regular expression: android

The builders matched are:

  • AMD64 Android PR
  • aarch64 Android PR

@mhsmith
Copy link
Member

mhsmith commented Jan 23, 2025

Not sure what happened before with Android and iOS, but they both seem fine now.

@serhiy-storchaka
Copy link
Member Author

It was an issue in different tests which was fixed by #129133.

No need to trigger buildbots. This PR is not emergent. It will be merged after merging all related PRs. Some changes can be extracted into separate PRs (like IDLE's).

@kumaraditya303 kumaraditya303 removed their request for review February 21, 2025 18:16
@brettcannon brettcannon removed their request for review April 14, 2025 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting merge skip news tests Tests in the Lib/test dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants