Note that there are some explanatory texts on larger screens.

plurals
  1. POnose runs test on function in setUp when no suite specified
    text
    copied!<p>I have a tests file in one of my Pyramid projects. It has <em>one</em> suite with <em>six</em> tests in it:</p> <pre><code>... from .scripts import populate_test_data class FunctionalTests(unittest.TestCase): def setUp(self): settings = appconfig('config:testing.ini', 'main', relative_to='../..') app = main({}, **settings) self.testapp = TestApp(app) self.config = testing.setUp() engine = engine_from_config(settings) DBSession.configure(bind=engine) populate_test_data(engine) def tearDown(self): DBSession.remove() tearDown() def test_index(self): ... def test_login_form(self): ... def test_read_recipe(self): ... def test_tag(self): ... def test_dish(self): ... def test_dashboard_forbidden(self): ... </code></pre> <p>Now, when I run <code>nosetests templates.py</code> (where <code>templates.py</code> is the mentioned file) I get the following output:</p> <pre><code>......E ====================================================================== ERROR: templates.populate_test_data ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/yentsun/env/local/lib/python2.7/site-packages/nose-1.1.2-py2.7.egg/nose/case.py", line 197, in runTest self.test(*self.arg) File "/home/yentsun/env/local/lib/python2.7/site-packages/nose-1.1.2-py2.7.egg/nose/util.py", line 622, in newfunc return func(*arg, **kw) TypeError: populate_test_data() takes exactly 1 argument (0 given) ---------------------------------------------------------------------- Ran 7 tests in 1.985s FAILED (errors=1) </code></pre> <p>When I run the tests with test suite specified <code>nosetests templates.py:FunctionalTests</code>, the output is, as expected, ok:</p> <pre><code>...... ---------------------------------------------------------------------- Ran 6 tests in 1.980s OK </code></pre> <p>Why do I have different output and why is an extra (7th) test run?</p> <p><strong>UPDATE.</strong> Its a bit frustrating, but I when removed the word <em>test</em> from the name <code>populate_test_data</code> (it became <code>populate_dummy_data</code>), everything worked fine.</p> <p>The problem is solved for now, but maybe somebody knows what went wrong here - why a function from <code>setUp</code> had been tested?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload