Repository navigation
Refactor str tests to reflect that str and unicode are merged in Python 3 #81005
Description
Activity
Unit tests of
strand related types (e.g.UserString) contain nomenclature and structure that dates back to the Python 2 distinction betweenstrandunicode.Previously it was undesirable to disturb the structure of these tests too much as this would complicate the merging of bug fixes back to Python 2, however with Python 2 drawing near to end-of-life this is perhaps less of a concern.
I would propose the following changes as a start:
- Rename test_unicode.py to test_str.py, and
UnicodeTestclass toStrTest
(to reflect the type that is now being tested) - Remove
MixinStrUnicodeUserStringTestclass and move its tests intoCommonTest
(The comment for this class saysadditional tests that only work for
stringlike objects, i.e. str, UserString
but in the absence ofunicodetheCommonTest
class is also only used for these two types now.) - Promote tests from the current
UnicodeTestclass toCommonTest
where it makes sense to do so; remove checks that no longer make sense.
(e.g. checks around mixedstr/unicodearguments that are all juststrnow)
Maybe the duplicativecheckequalnofix()method can also go away now? - The
BadSeq1helper class is not used because the corresponding check was
commented out in 2007. Either reinstate the check, or remove this class.
I'm happy to submit a PR for this, but just wanted to get some feedback before making the changes.
- Rename test_unicode.py to test_str.py, and
- addedstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory3.8 (EOL)end of lifeend of lifetype-featureA feature request or enhancementA feature request or enhancement
on May 7, 2019 - addedtestsTests in the Lib/test dirTests in the Lib/test dirand removedstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
on May 7, 2019 There is still the functionality common to str, bytes and bytearray. So it make sense to have the common class for testing str, bytes, bytearray and UserList and other common class (subclass of the former one) for testing str and UserList.
Agreed. This functionality is in
BaseTest(which is the base forCommonTest) and I don't propose to change this.PS opened here: #13172
I've tried to break down the changes into individual steps, with justification in commit messages. Happy to collapse these down into fewer commits before merge if preferred.I haven't done the "Promote tests from the current
UnicodeTestclass toCommonTest" 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 :-)
- added a commit that references this issue
on May 23, 2023
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields: