Skip to content

Refactor str tests to reflect that str and unicode are merged in Python 3 #81005

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

Closed
asqui mannequin opened this issue May 7, 2019 · 4 comments
Closed

Refactor str tests to reflect that str and unicode are merged in Python 3 #81005

asqui mannequin opened this issue May 7, 2019 · 4 comments
Labels
tests Tests in the Lib/test dir type-feature A feature request or enhancement

Comments

@asqui
Copy link
Mannequin

asqui mannequin commented May 7, 2019

BPO 36824
Nosy @ncoghlan, @serhiy-storchaka, @asqui, @tirkarthi
PRs
  • gh-81005: Refactor str tests to reflect that str and unicode are merged in Python 3 #13172
  • 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:

    assignee = None
    closed_at = None
    created_at = <Date 2019-05-07.06:37:53.164>
    labels = ['3.8', 'type-feature', 'tests']
    title = 'Refactor str tests to reflect that str and unicode are merged in Python 3'
    updated_at = <Date 2019-05-07.20:05:56.998>
    user = 'https://github.com/asqui'

    bugs.python.org fields:

    activity = <Date 2019-05-07.20:05:56.998>
    actor = 'dfortunov'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Tests']
    creation = <Date 2019-05-07.06:37:53.164>
    creator = 'dfortunov'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 36824
    keywords = ['patch']
    message_count = 4.0
    messages = ['341685', '341687', '341689', '341809']
    nosy_count = 4.0
    nosy_names = ['ncoghlan', 'serhiy.storchaka', 'dfortunov', 'xtreak']
    pr_nums = ['13172']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue36824'
    versions = ['Python 3.8']

    @asqui
    Copy link
    Mannequin Author

    asqui mannequin commented May 7, 2019

    Unit tests of str and related types (e.g. UserString) contain nomenclature and structure that dates back to the Python 2 distinction between str and unicode.

    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 UnicodeTest class to StrTest
      (to reflect the type that is now being tested)
    • Remove MixinStrUnicodeUserStringTest class and move its tests into CommonTest
      (The comment for this 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.)
    • Promote tests from the current UnicodeTest class to CommonTest
      where it makes sense to do so; remove checks that no longer make sense.
      (e.g. checks around mixed str/unicode arguments that are all just str now)
      Maybe the duplicative checkequalnofix() method can also go away now?
    • The BadSeq1 helper 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.

    @asqui asqui mannequin added stdlib Python modules in the Lib dir 3.8 (EOL) end of life type-feature A feature request or enhancement labels May 7, 2019
    @SilentGhost SilentGhost mannequin added tests Tests in the Lib/test dir and removed stdlib Python modules in the Lib dir labels May 7, 2019
    @serhiy-storchaka
    Copy link
    Member

    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.

    @asqui
    Copy link
    Mannequin Author

    asqui mannequin commented May 7, 2019

    Agreed. This functionality is in BaseTest (which is the base for CommonTest) and I don't propose to change this.

    @asqui
    Copy link
    Mannequin Author

    asqui mannequin commented May 7, 2019

    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 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 :-)

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @arhadthedev arhadthedev removed the 3.8 (EOL) end of life label May 18, 2023
    hugovk added a commit that referenced this issue May 23, 2023
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    tests Tests in the Lib/test dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants