Skip to content

Lib/test/test_compileall.py fails when run directly #70289

Closed

Description

@vstinner
BPO 26101
Nosy @brettcannon, @vstinner
Files
  • test_compileall.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 = 'https://github.com/vstinner'
    closed_at = <Date 2016-01-18.11:07:19.029>
    created_at = <Date 2016-01-13.16:40:57.137>
    labels = ['tests']
    title = 'Lib/test/test_compileall.py fails when run directly'
    updated_at = <Date 2016-01-18.11:07:19.027>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2016-01-18.11:07:19.027>
    actor = 'vstinner'
    assignee = 'vstinner'
    closed = True
    closed_date = <Date 2016-01-18.11:07:19.029>
    closer = 'vstinner'
    components = ['Tests']
    creation = <Date 2016-01-13.16:40:57.137>
    creator = 'vstinner'
    dependencies = []
    files = ['41607']
    hgrepos = []
    issue_num = 26101
    keywords = ['patch']
    message_count = 5.0
    messages = ['258154', '258158', '258159', '258161', '258512']
    nosy_count = 3.0
    nosy_names = ['brett.cannon', 'vstinner', 'python-dev']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue26101'
    versions = ['Python 3.6']

    Activity

    1. vstinner commented on Jan 13, 2016

      @vstinner
      MemberAuthor

      "./python Lib/test/test_compileall.py" fails on test_compile_path() because the Lib/test/ directory is in sys.path and this directory contains invalid Python scripts like Lib/test/badsyntax_pep3120.py

      Attached patch fixes the issue by removing temporarely Lib/test/ from sys.path.

      Note: Python 3.5 doesn't test compileall.compile_path() which fails. The new test was added by the changeset 71f071f2e074 of the issue bpo-25768.

    2. brettcannon commented on Jan 13, 2016

      @brettcannon
      Member

      A cleaner way to do what you're after is to use test_importlib.util.import_state() where you can pass in an explicit value for sys.path to be temporarily set.

      Otherwise I'm fine with the idea of the proposed change.

    3. vstinner commented on Jan 13, 2016

      @vstinner
      MemberAuthor

      A cleaner way to do what you're after is to use test_importlib.util.import_state() where you can pass in an explicit value for sys.path to be temporarily set.

      I would prefer to not couple test_importlib and test_compileall to keep tests independent. If you consider that it's worth, import_state() must be moved to test.support.

    4. brettcannon commented on Jan 13, 2016

      @brettcannon
      Member

      Don't care enough to do the work to separate it out, so if you don't want to bother either then LGTM.

    5. python-dev commented on Jan 18, 2016

      python-devmannequin
      Mannequin

      New changeset c6a0f424837a by Victor Stinner in branch 'default':
      Fix test_compilepath() of test_compileall
      https://hg.python.org/cpython/rev/c6a0f424837a

    6. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Labels

    testsTests in the Lib/test dir

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions