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

warn about invalid test module names #1426

Closed
cztomczak opened this issue Mar 2, 2016 · 6 comments
Closed

warn about invalid test module names #1426

cztomczak opened this issue Mar 2, 2016 · 6 comments
Labels
good first issue easy issue that is friendly to new contributor topic: collection related to the collection phase topic: reporting related to terminal output and user-facing messages and errors

Comments

@cztomczak
Copy link

PyTest throws import errors when there are dots in my files:

c:\github\pycef\unittests>py.test
============================= test session starts =============================
platform win32 -- Python 2.7.11, pytest-2.9.0, py-1.4.31, pluggy-0.3.1
rootdir: c:\github\pycef\unittests, inifile: pytest.ini
collected 0 items / 8 errors

=================================== ERRORS ====================================
______________________ ERROR collecting app.Settings.py _______________________
c:\python27\lib\site-packages\py\_path\local.py:650: in pyimport
    __import__(modname)
E   ImportError: No module named app.Settings
______________________ ERROR collecting app.Switches.py _______________________
c:\python27\lib\site-packages\py\_path\local.py:650: in pyimport
    __import__(modname)
E   ImportError: No module named app.Switches
_____________________ ERROR collecting browser.Browser.py _____________________
c:\python27\lib\site-packages\py\_path\local.py:650: in pyimport
    __import__(modname)
E   ImportError: No module named browser.Browser
_________________ ERROR collecting browser.BrowserSettings.py _________________
c:\python27\lib\site-packages\py\_path\local.py:650: in pyimport
    __import__(modname)
E   ImportError: No module named browser.BrowserSettings
____________________ ERROR collecting browser.Embedder.py _____________________
c:\python27\lib\site-packages\py\_path\local.py:650: in pyimport
    __import__(modname)
E   ImportError: No module named browser.Embedder

Scripts run fine when executed from command line:

python app.Settings.py

It is only PyTest having problems running them.

Python 2.7 32-bit.
OS: Win7 Pro SP1

@The-Compiler
Copy link
Member

Note you won't be able to import that file (i.e. using import app.Settings) in Python either, so I'm not sure if pytest can (and/or should) support this.

@RonnyPfannschmidt
Copy link
Member

this is not a bug, tests are imported, and dots are not valid in importable module names

we should warn about that however

@RonnyPfannschmidt RonnyPfannschmidt added topic: reporting related to terminal output and user-facing messages and errors good first issue easy issue that is friendly to new contributor topic: collection related to the collection phase labels Mar 2, 2016
@RonnyPfannschmidt RonnyPfannschmidt changed the title Dot in filename: ImportError: No module named app.Settings warn about invalid test module names Mar 2, 2016
@lgpage
Copy link

lgpage commented Apr 17, 2016

Just be careful to allow for PEP 3149

@RonnyPfannschmidt
Copy link
Member

thanks for the warning, i don't think that pep affects us - since the abi tags are not part of a module name

@hartym
Copy link
Contributor

hartym commented Jul 23, 2016

Looks resolved by PR #1520 and merged in features branch (commit 5685589), works for me.

@RonnyPfannschmidt
Copy link
Member

thanks for the note, closing as solved via #1520 in commit 5685589

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue easy issue that is friendly to new contributor topic: collection related to the collection phase topic: reporting related to terminal output and user-facing messages and errors
Projects
None yet
Development

No branches or pull requests

5 participants