nosetests

Excluding abstractproperties from coverage reports

可紊 提交于 2019-12-30 01:39:15
问题 I have an abstract base class along the lines of: class MyAbstractClass(object): __metaclass__ = ABCMeta @abstractproperty def myproperty(self): pass But when I run nosetests (which coverage) on my project, it complains that the property def line is untested. It can't actually be tested (AFAIK) as instantiation of the abstract class will result in an exception being raised.. Are there any workarounds to this, or do I just have to accept < 100% test coverage? Of course, I could remove the

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

How can I define one setup function for all nosetests tests?

安稳与你 提交于 2019-12-23 22:50:00
问题 I'm using google app engine with python and want to run some tests using nosetest. I want each test to run the same setup function. I have already a lot of tests, so I don't want to go through them all and copy&paste the same function. can I define somewhere one setup function and each test would run it first? thanks. 回答1: You can write your setup function and apply it using the with_setup decorator: from nose.tools import with_setup def my_setup(): ... @with_setup(my_setup) def test_one(): .

nosetests, python

浪尽此生 提交于 2019-12-23 03:30:55
问题 I am trying to learn python, the guide I am following is asking me to write a simple 'game', utilizing tuples, lists, and classes. When running the 'nosetests' command, I get the following error: E. ====================================================================== ERROR: tests.LEXICON_tests.test_directions ---------------------------------------------------------------------- Traceback (most recent call last): File "/Library/Python/2.6/site-packages/nose/case.py", line 187, in runTest

Specially named directories using nosetests

浪尽此生 提交于 2019-12-22 14:06:18
问题 Does nosetests treat directories with certain names differently? Is a src directory special? If I have a project whose source directory is named src , nosetests seems to work fine. However, if the directory is named anything else, nosetests reports a bunch of import errors. Here's what I did: run tests ~/src$ nosetests .. ---------------------------------------------------------------------- Ran 2 tests in 0.001s OK rename directory ~/src$ cd .. ~/$ mv src/ src2 rerun tests ~/$ cd src2 ~/src2

Problems installing NoseXUnit

≡放荡痞女 提交于 2019-12-22 13:59:03
问题 I tried to install NoseXUnit using pip. Trying to run nosetests with it ends with the following error message: # nosetests --with-nosexunit /usr/lib/python2.7/site-packages/nose-1.3.0-py2.7.egg/nose/plugins/manager.py:395: RuntimeWarning: Unable to load plugin nosexunit = nosexunit.plugin:NoseXUnit: (coverage 3.7.1 (/usr/lib/python2.7/site-packages), Requirement.parse('coverage==2.85')) RuntimeWarning) Usage: nosetests [options] nosetests: error: no such option: --with-nosexunit So it seems

Force Nosetests to Use Python 2.7 instead of 3.4

你。 提交于 2019-12-22 05:17:50
问题 I've been learning Python using version 3.4. I recently started learning Web.py so have been using Python 2.7 for that, since web.py not supported in Python 3.4. I have nose 1.3.4 module installed for both Python 3.4 and 2.7. I need to run the nosetests command on some Python code written in 2.7 that uses the Web.py module. However, when I type nosetests command it automatically uses Python 3.4, so is throwing an error as unable to import the Web.py module in my Python code. Is there a way to

How to test that a function is called within a function with nosetests

被刻印的时光 ゝ 提交于 2019-12-21 08:08:33
问题 I'm trying to set up some automatic unit testing for a project. I have some functions which, as a side effect occasionally call another function. I want to write a unit test which tests that the second function gets called but I'm stumped. Below is pseudocode example: def a(self): data = self.get() if len(data) > 3500: self.b() # Bunch of other magic, which is easy to test. def b(self): serial.write("\x00\x01\x02") How do I test that b() -gets called? 回答1: You can mock the function b using

Using nose plugin to pass a boolean to my package

半世苍凉 提交于 2019-12-20 04:38:30
问题 Can a variable be moved from the cmd to my module when using nose tests? Scenario: I am running tests with selenium that need to run against both production and sandbox versions of the website (www.sandbox.myurl.com and www.myurl.com) I wrote a custom nose plugin that lets me set which environment to run against EDITED CODE env = None class EnvironmentSelector(Plugin): """Selects if test will be run against production or sandbox environments. """ def __init__(self): Plugin.__init__(self) self

List all Tests Found by Nosetest

你。 提交于 2019-12-18 13:53:12
问题 I use nosetests to run my unittests and it works well. I want to get a list of all the tests nostests finds without actually running them. Is there a way to do that? 回答1: Version 0.11.1 is currently available. You can get a list of tests without running them as follows: nosetests -v --collect-only 回答2: I recommend using: nosetests -vv --collect-only While the -vv option is not described in man nosetests , "An Extended Introduction to the nose Unit Testing Framework" states that: Using the -vv