Skip to content

TypeError when module under test or function under test is named 'test' #33

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

Closed
pytestbot opened this issue Mar 14, 2011 · 2 comments
Closed
Labels
type: bug problem that needs to be addressed

Comments

@pytestbot
Copy link
Contributor

Originally reported by: Jason R. Coombs (BitBucket: jaraco, GitHub: jaraco)


I encountered an issue (during test collection) where I get a type error when the test function is named test. The error occurs on Linux and Windows. Here's a simple example to reproduce:

jaraco@shinobi:~/projects/foo$ ls -R
.:
mymod  test

./mymod:
__init__.py  __init__.pyc  test.py  test.pyc

./test:
test.py  test.pyc
jaraco@shinobi:~/projects/foo$ cat mymod/test.py
class test(object): pass
jaraco@shinobi:~/projects/foo$ cat test/test.py
from mymod.test import test
jaraco@shinobi:~/projects/foo$ PYTHONPATH=. py.test test/test.py
============================= test session starts ==============================
platform linux2 -- Python 2.7.1 -- pytest-2.0.2
collected 0 items / 1 errors 

==================================== ERRORS ====================================
________________________ ERROR collecting test/test.py _________________________
../../lib/python2.7/inspect.py:749: in getargs
>           raise TypeError('{!r} is not a code object'.format(co))
E           TypeError: <class 'mymod.test.test'> is not a code object
=========================== 1 error in 0.04 seconds ============================

@pytestbot
Copy link
Contributor Author

Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42):


fix issue33 - no collection error for classes prefixed "test" deriving from object

@pytestbot
Copy link
Contributor Author

Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42):


you can install the dev version with "pip install -U -i http://pypi.testrun.org pytest"

@pytestbot pytestbot added the type: bug problem that needs to be addressed label Jun 15, 2015
fkohlgrueber pushed a commit to fkohlgrueber/pytest that referenced this issue Oct 27, 2018
fkohlgrueber pushed a commit to fkohlgrueber/pytest that referenced this issue Oct 27, 2018
mgorny pushed a commit to mgorny/pytest that referenced this issue May 27, 2023
* Py3k Support across most of the modules 
* Added devpi server fixture to create an index for a test function
* Handle pyramid installed as a transient test egg
* Update setup.cfg to current pytest standard
* Updated plugins using old pytest_funcarg__ syntax
* Adding debug to httpd server
* Split up httpd modules config from main template so derived classes can override this. Updated modules to include worker definitions now required in recent linux distros
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug problem that needs to be addressed
Projects
None yet
Development

No branches or pull requests

1 participant