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

Comments

Projects
None yet
5 participants
@cztomczak

cztomczak commented Mar 2, 2016

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

This comment has been minimized.

Member

The-Compiler commented Mar 2, 2016

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

This comment has been minimized.

Member

RonnyPfannschmidt commented Mar 2, 2016

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 changed the title from Dot in filename: ImportError: No module named app.Settings to warn about invalid test module names Mar 2, 2016

@omarkohl omarkohl referenced this issue Apr 17, 2016

Merged

Raise CollectError if import test module fails #1520

4 of 4 tasks complete
@lgpage

This comment has been minimized.

lgpage commented Apr 17, 2016

Just be careful to allow for PEP 3149

@RonnyPfannschmidt

This comment has been minimized.

Member

RonnyPfannschmidt commented Apr 17, 2016

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

@hartym

This comment has been minimized.

Contributor

hartym commented Jul 23, 2016

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

@RonnyPfannschmidt

This comment has been minimized.

Member

RonnyPfannschmidt commented Jul 23, 2016

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