Skip to content

Importing backports and moves packages, imports (e.g. test.py) fromuser folders,  #268

Description

@ankostis

future-version: 0.16.0
python-ver: 3.5

When importing either future.moves or future.backports packages, it invokes import_top_level_modules() which attempts to import various modules by name. For instance, if there is a test.py in user project, it is also gets unexpectedly imported.

According the message of one implicated commit 264f9bc, the import_top_level_modules() method was introduced for "getting the test runner working on travis-ci on Py3".
Wouldn't be better to place this code in test-packages?

Activity

  1. added a commit that references this issue on Mar 20, 2017
  2. ccanepa commented on Apr 18, 2017

    @ccanepa
  3. Eldinnie commented on Sep 25, 2018

    @Eldinnie

    any update on this?

  4. added and removed on Jul 9, 2019
  5. MCMcCallum commented on Oct 17, 2019

    @MCMcCallum

    I was just bitten by this when using apache_beam with python3.

    To reproduce:

    echo "raise NotImplementedError('This test.py file should not be touched')" >> ./test.py
    pip install apache_beam
    python -c "import apache_beam as beam"
    

    I notice that the comment for exclude_local_folder_imports which is called from import_top_level_modules states:

    (This was need prior to v0.16.0 because the presence of a configparser
        folder would otherwise have prevented setuptools from running on Py3. Maybe
        it's not needed any more?)
    

    It seems to work fine without it. Perhaps it's time.

  6. robclewley commented on Aug 28, 2020

    @robclewley

    Also bitten while using the dash plotting library that relies on this package. I was getting very strange behavior because I happened to have a quick-and-dirty test.py for experimenting with my package during development, that turns out to have been running and silently changing critical state every time I did a local test of my app. I really dislike debugging silent issues like this. Please consider prioritizing the removal of this behavior.

  7. spaceone commented on Aug 4, 2023

    @spaceone

    Duplicate #259

  8. fried commented on Sep 3, 2025

    @fried

    Shadowing modules names from the standard lib is always going to lead to pain. "test" is a part of the standard lib, future is not in error in expecting it to exist. But users are in error in shadowing its name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions