nose

Nose doesn't find Django tests

半城伤御伤魂 提交于 2020-01-03 07:06:08
问题 I am trying to use Django-nose in my current project, but I can't figure out how to get nose to run my tests. So I started a simple Django 1.4.1 project to get to know nose. But not even on this simple test project I could get it running. Before I go on: I know there are a ton of similar questions on Stackoverflow, like for instance this one: How do I tell Django-nose where my tests are? But after Googling around, reading blog posts and StackOverflow answers I still couldn't get it running.

Django user setup for nose tests

那年仲夏 提交于 2020-01-03 05:00:25
问题 I tried seting up a user for nose tests but it doesnot work in global scope defined: from django.contrib.auth.models import User import nose.tools as noz inside a test class defined: def setUp(self): self.client = Client() user = User(username="test", password="test") user.save() The user is saved, which i have tested with the noz.set_trace() but when a test function calls for the same user's login, assertion error is raised: nosetests --verbosity 1 Creating test database for alias 'default'.

Print a different long description in nose tests along with test name python

纵然是瞬间 提交于 2020-01-02 08:50:28
问题 I am using the command: nosetests test.py When this is run only the first line of the description gets printed. I want the whole description along with the test name. How do i do that? test.py file import unittests class TestClass(unittest.TestCase): def test_1(self): """this is a long description // continues on second line which does not get printed """ some code; self.assertTrue(True) def test_2(self): """this is another or different long description // continues on second line which does

Repeated single or multiple tests with Nose

筅森魡賤 提交于 2020-01-01 04:37:28
问题 Similar to this question, I'd like to have Nose run a test (or all tests) n times -- but not in parallel. I have a few hundred tests in a project; some are some simple unit tests. Others are integration tests w/ some degree of concurrency. Frequently when debugging tests I want to "hit" a test harder; a bash loop works, but makes for a lot of cluttered output -- no more nice single "." for each passing test. Having the ability to beat on the selected tests for some number of trials seems like

Change names of tests created by nose test generators

走远了吗. 提交于 2019-12-30 02:18:09
问题 Nose has a bug - test names created by generators are not cached, so the error looks like it happened in the last test, not the actual test where it failed. I got around it following the solution in the bug report discussion, but it only works for names shown on stdout, not in the XML report (--with-xunit) from functools import partial, update_wrapper def testGenerator(): for i in range(10): func = partial(test) # make decorator with_setup() work again update_wrapper(func, test) func

A Nose plugin to specify the order of unit test execution

谁都会走 提交于 2019-12-29 06:43:52
问题 I have a desire to use Nose for an over the wire integration test suite. However, the order of execution of some of these tests is important. That said, I thought I would toss together a quick plugin to decorate a test with the order I want it executed: https://gist.github.com/Redsz/5736166 def Foo(unittest.TestCase): @step(number=1) def test_foo(self): pass @step(number=2) def test_boo(self): pass From reviewing the built in plugins I had thought, I could simply override

Python imports for tests using nose - what is best practice for imports of modules above current package

浪尽此生 提交于 2019-12-28 04:51:23
问题 This is a question which is asked frequently in different forms, and often obtains "lol you're not doing it properly" responses. Pretty sure that's because there's a common sense scenario people (including me) are trying to use as an implementation, and the solution is not obvious (if you've not done it before). Would accept an answer which "lets the fly out of the bottle". Given project/ __init__.py /code __init__.py sut.py /tests __init__.py test_sut.py Where tests_sut.py starts: import

Why python mock patch doesn't work?

假装没事ソ 提交于 2019-12-28 02:07:34
问题 I have two files spike.py class T1(object): def foo(self, afd): return "foo" def get_foo(self): return self.foo(1) def bar(): return "bar" test_spike.py: from unittest import TestCase import unittest from mock import patch, MagicMock from spike import T1, bar class TestStuff(TestCase): @patch('spike.T1.foo', MagicMock(return_value='patched')) def test_foo(self): foo = T1().get_foo() self.assertEqual('patched', foo) @patch('spike.bar') def test_bar(self, mock_obj): mock_obj.return_value =

how to make nose to log output of cases to separate files?

久未见 提交于 2019-12-24 12:44:07
问题 I am using nose to run a bunch of test cases. I would like to record output of each case to separate files, and to know result[success/failure] of each case. unfortunately, I can not figure out how to do it with nose. can anybody provide some clues? thank you 回答1: Firstly, this sounds like unusual usage , and may indicate that you should rethink your testing scheme. I can think of a couple of ways to address this. The simplest would be to have each test log itself instead of having nose do it

How to select some test methods in a fixture using regex (i.e. -m) in nosetests?

百般思念 提交于 2019-12-24 11:36:20
问题 Below is a pared down illustrative representation of my problem : import sys import nose def test_equality_stdalone(): assert "b" == "b" def test_inequality_stdalone(): assert "b" != "c" def test_xxx_stdalone(): assert "xxx" == "xxx" class TestClass(object): def setUp(self): pass def tearDown(self): pass def test_equality(self): assert "a" == "a" def test_xxx(self): assert "xxx" == "xxx" if __name__ == "__main__": nose.main(argv=sys.argv[:] + ["-v", "-m", ".*equality.*", __file__]) This test