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

Use test_both() consistently throughout test_importlib #65702

Closed
ericsnowcurrently opened this issue May 14, 2014 · 5 comments
Closed

Use test_both() consistently throughout test_importlib #65702

ericsnowcurrently opened this issue May 14, 2014 · 5 comments
Assignees
Labels
tests Tests in the Lib/test dir type-feature A feature request or enhancement

Comments

@ericsnowcurrently
Copy link
Member

BPO 21503
Nosy @brettcannon, @ericsnowcurrently
Files
  • use-test_both-consistently.diff
  • 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 = 'https://github.com/ericsnowcurrently'
    closed_at = <Date 2014-05-16.17:46:12.678>
    created_at = <Date 2014-05-14.00:25:28.910>
    labels = ['type-feature', 'tests']
    title = 'Use test_both() consistently throughout test_importlib'
    updated_at = <Date 2014-05-16.17:46:12.677>
    user = 'https://github.com/ericsnowcurrently'

    bugs.python.org fields:

    activity = <Date 2014-05-16.17:46:12.677>
    actor = 'eric.snow'
    assignee = 'eric.snow'
    closed = True
    closed_date = <Date 2014-05-16.17:46:12.678>
    closer = 'eric.snow'
    components = ['Tests']
    creation = <Date 2014-05-14.00:25:28.910>
    creator = 'eric.snow'
    dependencies = []
    files = ['35246']
    hgrepos = []
    issue_num = 21503
    keywords = ['patch']
    message_count = 5.0
    messages = ['218494', '218666', '218669', '218672', '218676']
    nosy_count = 3.0
    nosy_names = ['brett.cannon', 'python-dev', 'eric.snow']
    pr_nums = []
    priority = 'low'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue21503'
    versions = ['Python 3.5']

    @ericsnowcurrently
    Copy link
    Member Author

    test_importlib.util provides the test_both() function that facilitates testing both the frozen and source versions of importlib. The function helps to keep the tests more maintainable. However, the following test modules are not using test_both():

    Lib/test/test_importlib/test_abc.py
    Lib/test/test_importlib/test_api.py
    Lib/test/test_importlib/test_locks.py
    Lib/test/test_importlib/test_spec.py
    Lib/test/test_importlib/test_windows.py

    Furthermore, the remaining test modules use test_both() inconsistently. Here is a patch that makes consistent use of test_both() and formats usage in a way that helps with readability.

    @ericsnowcurrently ericsnowcurrently self-assigned this May 14, 2014
    @ericsnowcurrently ericsnowcurrently added tests Tests in the Lib/test dir type-feature A feature request or enhancement labels May 14, 2014
    @brettcannon
    Copy link
    Member

    I see you noticed my shift in strategy after I realized part way through a cleaner way of doing things. =)

    LGTM

    I don't love the formatting of the test_both() lines, but I think that one is just an aesthetic thing that will never make people happy -- weird line wrapping or really long lines -- so just leave it as-is in your patch.

    @ericsnowcurrently
    Copy link
    Member Author

    I don't love the formatting of the test_both() lines, but I think that one is just an aesthetic thing that will never make people happy -- weird line wrapping or really long lines -- so just leave it as-is in your patch.

    Yeah, I went with the formatting that I did because I found it a
    little easier to follow (stronger separation between elements) and
    visually distinguish in the code. It was also a little easier to
    grep/search for.

    @ericsnowcurrently
    Copy link
    Member Author

    FWIW, this change was motivated by the importlib backport (I found some time to work on it). The import_importlib()/test_both() approach definitely makes backporting the tests easier (thanks for that).

    BTW, thanks for also consolidating the various test_importlib util modules. That also helped.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented May 16, 2014

    New changeset 34d65746d5ca by Eric Snow in branch 'default':
    Issue bpo-21503: Use test_both() consistently in test_importlib.
    http://hg.python.org/cpython/rev/34d65746d5ca

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    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

    2 participants