Skip to content

gh-81005: Refactor str tests to reflect that str and unicode are merged in Python 3 #13172

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

Merged
merged 9 commits into from
May 23, 2023

Conversation

asqui
Copy link
Contributor

@asqui asqui commented May 7, 2019

Various cleanup and refactoring of unit tests for string-like types.
See https://bugs.python.org/issue36824 and/or individual commit messages for more details.

I haven't done the "Promote tests from the current UnicodeTest class to CommonTest" portion yet, but I'm running out of sprint time so I wanted to submit what I have.

I believe these changes are suitable for merge to master, but keen to hear feedback :-)

https://bugs.python.org/issue36824

asqui added 6 commits May 7, 2019 14:44
  (to reflect the type that is now being tested)
  (The comment for this mixin class says
    # additional tests that only work for
    # stringlike objects, i.e. str, UserString
   but in the absence of `unicode` the `CommonTest` class is also only
   used for these two types now, so no need for the distinction.)
  communicate its purpose, and to disambiguate it from the more general
  `BaseTest` class, which covers behaviours shared with the `bytes`
  and `bytesarray` types.
  (Seems to date back to the first introduction of this code, in 2003!)
  non-str types. Back in 2007 there was a change to allow str.join() to
  convert non-str values automatically, but this is no longer the case.
  raising TypeError, so BadSeq1 and the associated check seem to be
  redundant. This is the existing check, in test_join():
      self.assertRaises(TypeError, '.'.join, ['a', 'b', 3])
  (Unless there is some specific difference we're testing by supplying a
   custom sequence, BadSeq1, rather than a plain list?)
- Define BadSeq2 closer to its only usage, and give it a more meaningful
  name. (Previously this type was referenced from multiple locations but
  this is no longer the case.)
@asqui
Copy link
Contributor Author

asqui commented May 8, 2019

As this is a test-only change with no external visibility, I don' think it needs a NEWS entry. Should the "skip news" label be applied to this PR?

Copy link
Contributor

@jdemeyer jdemeyer left a comment

Choose a reason for hiding this comment

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

The changes look good to me. I agree with the skip news.

Copy link
Member

@iritkatriel iritkatriel left a comment

Choose a reason for hiding this comment

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

This has merge conflicts now,.

@bedevere-bot
Copy link

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.

@furkanonder
Copy link
Contributor

@asqui Could you resolve the conflicts?

@asqui
Copy link
Contributor Author

asqui commented May 13, 2023

Sure! I'm AFK for the next few days but I'll take a look when I'm back next week.

@ghost
Copy link

ghost commented May 18, 2023

All commit authors signed the Contributor License Agreement.
CLA signed

@asqui
Copy link
Contributor Author

asqui commented May 18, 2023

Changes to the renamed file merged in cleanly with absolutely no conflicts. (I was surprised given the age of this PR so did some sanity checks and it all looks good.)

CLA signed (again; was there a change to the CLA that required everyone to re-sign?)

I think this is good to merge now? (Needs the Skip News label.)

@iritkatriel iritkatriel dismissed their stale review May 18, 2023 07:42

Merge conflicts resolved

@arhadthedev
Copy link
Member

(Needs the Skip News label.)

I think that something like String tests are modified to reflect that ``str`` and ``unicode`` are merged in Python 3. Patch by Daniel Fortunov. is indeed required here. The list of tests got changed so whoever runs them periodically to build comparison graphs needs to be aware.

/cc @AlexWaygood (to check whether I apply #104570 (comment) correctly)

@AlexWaygood
Copy link
Member

(Needs the Skip News label.)

I think that something like String tests are modified to reflect thatstrandunicodeare merged in Python 3. Patch by Daniel Fortunov. is indeed required here. The list of tests got changed so whoever runs them periodically to build comparison graphs needs to be aware.

/cc @AlexWaygood (to check whether I apply #104570 (comment) correctly)

Good call @arhadthedev. Changes to our test suite often don't need NEWS entries, as they don't have much impact on end users. But something as significant as renaming a whole test file probably does need a NEWS entry, as it will affect the invocation people will need to use to run the tests.

@arhadthedev arhadthedev changed the title bpo-36824: Refactor str tests to reflect that str and unicode are merged in Python 3 gh-81005: Refactor str tests to reflect that str and unicode are merged in Python 3 May 18, 2023
@asqui
Copy link
Contributor Author

asqui commented May 19, 2023

Added the suggested NEWS entry.

(This is my first time using blurb so hopefully I did it correctly!)

@asqui
Copy link
Contributor Author

asqui commented May 19, 2023

Hmm looks like I should have used the GH issue number for the bpo-imported issue that this PR is fixing (I mistakenly put the number for this PR itself)

I'm AFK again for the next few days so won't be able to fix this until next week.

I guess all is needed is to rename the news file to feature the correct number - I don't know of any way to do that through GitHub.com without my laptop.

@hugovk
Copy link
Member

hugovk commented May 19, 2023

I've renamed the NEWS file to use the GitHub issue number.

@hugovk
Copy link
Member

hugovk commented May 19, 2023

And I've opened python/core-workflow#504 to suggest more validation in blurb.

@hugovk hugovk merged commit ddb1485 into python:main May 23, 2023
@hugovk
Copy link
Member

hugovk commented May 23, 2023

Thank you for the PR and for your patience!

@asqui asqui deleted the str-tests-refactor-bpo-36824 branch May 23, 2023 21:48
@asqui
Copy link
Contributor Author

asqui commented May 23, 2023

Yay, merged at last! Thanks for the reviews and help along the way 😄

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.

10 participants