Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Test discovery fails when importing functions to test module #127

jpellerin opened this Issue · 1 comment

1 participant


What steps will reproduce the problem?
1. Write module with a function which has the word 'test' in the name e.g


def foo_test(parameter1, parameter2):

  1. Write a unit test for it import unittest from uut import foo_test

class Test(unittest.TestCase):

def testName(self):
    foo_test('foo', 'bar')
  1. Run test with nose

What is the expected output? What do you see instead?
I expect the test to execute without errors. Instead I get this output:

C:\Documents and Settings\matuusit\workspace\NoseDiscovery\src>nosetests tests


ERROR: tests.uut_test.foo_test

Traceback (most recent call last):
File "C:\Apps\python\lib\site-packages\nose-0.11.4-py2.6.egg\nose\", line 186, in runTest
File "C:\Apps\python\lib\site-packages\nose-0.11.4-py2.6.egg\nose\", line 634, in newfunc
return func(
arg, **kw)
TypeError: foo_test() takes exactly 2 arguments (0 given)

Ran 2 tests in 0.000s

FAILED (errors=1)

What version of the product are you using? On what operating system? version 0.11.4 on Windows XP

Please provide any additional information below.
I can work around this problem by importing the module and using:
uut.foo_test('foo', 'bar')

Google Code Info:
Issue #: 410
Created On: 2011-04-15T06:59:12.000Z
Closed On: 2011-04-15T13:04:58.000Z

@jpellerin jpellerin was assigned

This isn't a bug -- foo_test is a function that nose would normally collect as a test because its name matches the testMatch regex. If you want to avoid having it collected you can rename it, or mark it as a non-test by setting foo_test.test = False -- or as you said, by not importing test-like functions into the top level of a test module.

Google Code Info:
Created On: 2011-04-15T13:04:58.000Z

@jpellerin jpellerin closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.