nose

How do I run a single test with Nose in Pylons

你离开我真会死。 提交于 2019-12-02 15:47:45
I have a Pylons 1.0 app with a bunch of tests in the test/functional directory. I'm getting weird test results and I want to just run a single test. The nose documentation says I should be able to pass in a test name at the command line but I get ImportErrors no matter what I do For example: nosetests -x -s sometestname Gives: Traceback (most recent call last): File "/home/ben/.virtualenvs/tsq/lib/python2.6/site-packages/nose-0.11.4-py2.6.egg/nose/loader.py", line 371, in loadTestsFromName module = resolve_name(addr.module) File "/home/ben/.virtualenvs/tsq/lib/python2.6/site-packages/nose-0.11

Why isn't django-nose running the doctests in my models?

穿精又带淫゛_ 提交于 2019-12-02 09:27:05
问题 I'm trying to use doctests with django-nose. All my doctests are running, except not any doctests within a model (unless it is abstract). class TestModel1(models.Model): """ >>> print 'pass' pass """ pass class TestModel2(models.Model): """ >>> print 'pass' pass """ class Meta: abstract = True pass The first doctest does not run and the second does. Why is this? 回答1: Any chance you're getting bitten by this? http://github.com/jbalogh/django-nose/issues/2 If so, try upgrading django-nose 来源:

Python test fixture to run a single test?

你说的曾经没有我的故事 提交于 2019-12-01 19:57:48
问题 I'm looking for something like ruby rspec's focus metadata or elixir's mix tags to run a single python test. Ruby RSpec Example: # $ rspec spec it 'runs a single test', :focus do expect(2).to eq(2) end Elixir ExUnit & Mix Example: # $ mix test --only focus @tag :focus test "only run this test" do assert true end Is this possible / available with any python test runner and fixture combo? Running single tests by specifying nested module.class.test_name via command line args can become very

Python test fixture to run a single test?

孤街醉人 提交于 2019-12-01 19:07:14
I'm looking for something like ruby rspec's focus metadata or elixir's mix tags to run a single python test. Ruby RSpec Example: # $ rspec spec it 'runs a single test', :focus do expect(2).to eq(2) end Elixir ExUnit & Mix Example: # $ mix test --only focus @tag :focus test "only run this test" do assert true end Is this possible / available with any python test runner and fixture combo? Running single tests by specifying nested module.class.test_name via command line args can become very verbose in larger projects. So Something like: Desired Python Code: # $ nosetests --only focus from tests

How can you suppress traces for failed test cases using Nose?

假如想象 提交于 2019-12-01 18:08:16
I'm writing a test suit with nose, and would like failing cases to display an output like "FAILED: is_even(5): Not even" instead of the default output: ====================================================================== FAIL: seed_db.test_generator(5,) ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/nose/case.py", line 197, in runTest self.test(*self.arg) File "/home/apurcell/tests/prism/seed_db.py", line 59, in is_even nose.tools.eq_(x % 2, 0, msg="Not even") File "/usr/local/lib/python2

Nosetest including unwanted parent directories

馋奶兔 提交于 2019-12-01 15:49:33
I'm trying to limit nosetests to a specific directory, however during the test run it's including the parent directories of the dir I'm targetting and in doing so throws errors. Here's the key elements of output from the test run: nose.importer: DEBUG: Add path /projects/myproject/myproject/specs nose.importer: DEBUG: Add path /projects/myproject/myproject nose.importer: DEBUG: Add path /projects/myproject nose.importer: DEBUG: insert /projects/myproject into sys.path I'm using buildout with pbp.recipe.noserunner . Here's the relevant /projects/myproject/buildout.cfg section: [specs] recipe =

Excluding directory, module in python nosetest

烈酒焚心 提交于 2019-12-01 15:46:46
We use nose to discover tests and run them. All the tests are written in TestCase compatible way so any test runner can run the. Problem is we have some directories which doesn't have any test. But test runner continue to discover test from there. If one of those directory has lot of files its stuck. So how can I exclude that directory? Currently I am executing nosetests --processes=10 --verbosity 2 But there is a directory called scripts which takes ages to discover tests from it. So I want to exclude it. I tried nosetests --processes=10 --verbosity 2 --exclude='^scripts$' But no luck. There

Is there a downside for using __init__(self) instead of setup(self) for a nose test class?

大憨熊 提交于 2019-12-01 04:03:57
Running nosetests -s for class TestTemp(): def __init__(self): print '__init__' self.even = 0 def setup(self): print '__setup__' self.odd = 1 def test_even(self): print 'test_even' even_number = 10 assert even_number % 2 == self.even def test_odd(self): print 'test_odd' odd_number = 11 assert odd_number % 2 == self.odd prints out the following. __init__ __init__ __setup__ test_even .__setup__ test_odd . The test instances are created before tests are run, while setup runs right before the test. For the general case, __init__() and setup() accomplish the same thing, but is there a downside for

Is there a downside for using __init__(self) instead of setup(self) for a nose test class?

旧城冷巷雨未停 提交于 2019-12-01 01:47:13
问题 Running nosetests -s for class TestTemp(): def __init__(self): print '__init__' self.even = 0 def setup(self): print '__setup__' self.odd = 1 def test_even(self): print 'test_even' even_number = 10 assert even_number % 2 == self.even def test_odd(self): print 'test_odd' odd_number = 11 assert odd_number % 2 == self.odd prints out the following. __init__ __init__ __setup__ test_even .__setup__ test_odd . The test instances are created before tests are run, while setup runs right before the

How to access plugin options within a test? (Python Nose)

与世无争的帅哥 提交于 2019-12-01 00:24:45
We are trying to implement an automated testing framework using nose. The intent is to add a few command line options to pass into the tests, for example a hostname. We run these tests against a web app as integration tests. So, we've created a simple plugin that adds a option to the parser: import os from nose.plugins import Plugin class test_args(Plugin): """ Attempting to add command line parameters. """ name = 'test_args' enabled = True def options(self, parser, env=os.environ): super(test_args, self).options(parser, env) parser.add_option("--hostname", action="store", type="str", help=