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

test___all__ and test_support alter execution environment #69881

Closed
Arfrever mannequin opened this issue Nov 22, 2015 · 6 comments
Closed

test___all__ and test_support alter execution environment #69881

Arfrever mannequin opened this issue Nov 22, 2015 · 6 comments
Labels
tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@Arfrever
Copy link
Mannequin

Arfrever mannequin commented Nov 22, 2015

BPO 25695
Nosy @vstinner, @ezio-melotti, @vadmium, @serhiy-storchaka
Files
  • issue25695.diff
  • defer-TESTDIRN.patch
  • 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 = <Date 2015-11-24.22:44:23.982>
    created_at = <Date 2015-11-22.08:58:57.923>
    labels = ['type-bug', 'tests']
    title = 'test___all__ and test_support alter execution environment'
    updated_at = <Date 2015-11-24.22:44:23.981>
    user = 'https://bugs.python.org/Arfrever'

    bugs.python.org fields:

    activity = <Date 2015-11-24.22:44:23.981>
    actor = 'martin.panter'
    assignee = 'none'
    closed = True
    closed_date = <Date 2015-11-24.22:44:23.982>
    closer = 'martin.panter'
    components = ['Tests']
    creation = <Date 2015-11-22.08:58:57.923>
    creator = 'Arfrever'
    dependencies = []
    files = ['41122', '41128']
    hgrepos = []
    issue_num = 25695
    keywords = ['patch', 'needs review']
    message_count = 6.0
    messages = ['255088', '255093', '255126', '255139', '255293', '255296']
    nosy_count = 7.0
    nosy_names = ['vstinner', 'ezio.melotti', 'Arfrever', 'SilentGhost', 'python-dev', 'martin.panter', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue25695'
    versions = ['Python 3.6']

    @Arfrever
    Copy link
    Mannequin Author

    Arfrever mannequin commented Nov 22, 2015

    test___all__ and test_support alter execution environment.
    Problem seems to be present only in Python 3.6.

    $ python3.5 -m test test___all__ test_support
    [1/2] test___all__
    [2/2] test_support
    All 2 tests OK.
    $ python3.6 -m test test___all__ test_support
    [1/2] test___all__
    Warning -- files was modified by test___all__
    [2/2] test_support
    Warning -- files was modified by test_support
    2 tests altered the execution environment:
        test___all__ test_support

    When running these test files separately, problem is only present for test___all__:

    $ python3.5 -m test test___all__
    [1/1] test___all__
    1 test OK.
    $ python3.6 -m test test___all__
    [1/1] test___all__
    Warning -- files was modified by test___all__
    1 test altered the execution environment:
        test___all__
    $ python3.5 -m test test_support
    [1/1] test_support
    1 test OK.
    $ python3.6 -m test test_support
    [1/1] test_support
    1 test OK.

    @Arfrever Arfrever mannequin added the tests Tests in the Lib/test dir label Nov 22, 2015
    @SilentGhost
    Copy link
    Mannequin

    SilentGhost mannequin commented Nov 22, 2015

    test_support has this line:

    TESTDIRN = os.path.basename(tempfile.mkdtemp(dir='.'))

    Which is the culprit. The reason it gets so far as to import the module is due to the "fuzzy logic" check looking for __all__
    What I'd suggest is replacing simple "in" string search with re.search for '\b__all__\b'. The downside of this is that the test execution time increased from .4 s to .7 s on my machine.

    @vadmium
    Copy link
    Member

    vadmium commented Nov 23, 2015

    This was introduced with revision f8fa7bc837a3. I guess I overlooked the new messages because I run the tests with -Wall, which is affected by bpo-18383.

    It seems a bad idea to create a temporary directory when you import the test_support module. I propose this patch to defer creation until the one test that uses it is run.

    As for your patch Silent Ghost, I’m not sure. It kind of side-steps the real issue by tweaking a heuristic. Maybe we should keep the heuristic as it is, because it is simpler.

    @vadmium vadmium added the type-bug An unexpected behavior, bug, or error label Nov 23, 2015
    @serhiy-storchaka
    Copy link
    Member

    defer-TESTDIRN.patch LGTM.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Nov 24, 2015

    New changeset fb72d6d7703c by Martin Panter in branch 'default':
    Issue bpo-25695: Defer creation of TESTDIRN until the test case is run
    https://hg.python.org/cpython/rev/fb72d6d7703c

    @vadmium
    Copy link
    Member

    vadmium commented Nov 24, 2015

    This should be fixed now. Thanks for the report Arfrever and the analysis Ghost. I still get these warnings, but they are discussed in bpo-18383:

    Warning -- warnings.filters was modified by test___all__
    Warning -- warnings.filters was modified by test_warnings

    @vadmium vadmium closed this as completed Nov 24, 2015
    @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-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants