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

ImportError is raised only when python -m unittest discover is given #76021

Closed
Hirokih2Horiuchi mannequin opened this issue Oct 22, 2017 · 2 comments
Closed

ImportError is raised only when python -m unittest discover is given #76021

Hirokih2Horiuchi mannequin opened this issue Oct 22, 2017 · 2 comments
Labels
OS-mac OS-windows stdlib Python modules in the Lib dir tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@Hirokih2Horiuchi
Copy link
Mannequin

Hirokih2Horiuchi mannequin commented Oct 22, 2017

BPO 31840
Nosy @pfmoore, @ronaldoussoren, @tjguk, @ned-deily, @zware, @serhiy-storchaka, @zooba
Files
  • test.py: runs or raises
  • 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 2017-10-22.06:30:25.502>
    created_at = <Date 2017-10-22.06:06:57.230>
    labels = ['OS-mac', 'type-bug', 'library', 'invalid', 'tests', 'OS-windows']
    title = '`ImportError` is` raised` only when `python -m unittest discover` is given'
    updated_at = <Date 2017-10-22.06:30:25.489>
    user = 'https://bugs.python.org/Hirokih2Horiuchi'

    bugs.python.org fields:

    activity = <Date 2017-10-22.06:30:25.489>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2017-10-22.06:30:25.502>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)', 'macOS', 'Tests', 'Windows']
    creation = <Date 2017-10-22.06:06:57.230>
    creator = 'Hiroki \xe2\x80\x9ch2\xe2\x80\x9d Horiuchi'
    dependencies = []
    files = ['47230']
    hgrepos = []
    issue_num = 31840
    keywords = []
    message_count = 2.0
    messages = ['304729', '304731']
    nosy_count = 8.0
    nosy_names = ['paul.moore', 'ronaldoussoren', 'tim.golden', 'ned.deily', 'zach.ware', 'serhiy.storchaka', 'steve.dower', 'Hiroki \xe2\x80\x9ch2\xe2\x80\x9d Horiuchi']
    pr_nums = []
    priority = 'normal'
    resolution = 'not a bug'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue31840'
    versions = ['Python 2.7', 'Python 3.6']

    @Hirokih2Horiuchi
    Copy link
    Mannequin Author

    Hirokih2Horiuchi mannequin commented Oct 22, 2017

    Create a package pkg. Put test.py there. Write none = None in pkg/__init__.py.
    In the directory containing pkg/, python [23] -m unittest pkg.test will terminate normally, but python [23] -m unittest discover pkg will raise ImportError. The phenomenon is the same in macOS Sierra, Debian 9.0, Windows 7. I do not think this is a very kind behavior.
    Thank you.

    @Hirokih2Horiuchi Hirokih2Horiuchi mannequin added stdlib Python modules in the Lib dir OS-mac tests Tests in the Lib/test dir OS-windows type-bug An unexpected behavior, bug, or error labels Oct 22, 2017
    @serhiy-storchaka
    Copy link
    Member

    Run

    python -m unittest discover --start-directory pkg --top-level-directory .
    

    By default the top level directory is the same as the start directory (i.e. pkg).

    @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
    OS-mac OS-windows stdlib Python modules in the Lib dir tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant