nose

Pass command line arguments to nose via “python setup.py test”

怎甘沉沦 提交于 2019-12-23 16:30:11
问题 Package Settings I have built a Python package which uses nose for testing. Therefore, setup.py contains: .. test_suite='nose.collector', tests_require=['nose'], .. And python setup.py test works as expected: running test ... ---------------------------------------------------------------------- Ran 3 tests in 0.065s OK Running with XUnit output Since I'm using Jenkins CI, I would like to output the nose results to JUnit XML format: nosetests <package-name> --with-xunit --verbose However,

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

Run Unittest On Main Django Database

不羁岁月 提交于 2019-12-22 10:56:53
问题 I'm looking for a way to run a full celery setup during django tests, asked in this other SO question After thinking about it, I think I could settle for running a unittest (it's more of an integration test) in which I run the test script against the main Django (development) database. Is there a way to write unittests, run them with Nose and do so against the main database? I imagine it would be a matter of telling Nose (or whatever other framework) about the django settings. I've looked at

How to use nose coverage with --timid flag

浪尽此生 提交于 2019-12-22 10:56:19
问题 I'd like to run "nosetests --with-coverage" using Ned Batchelder's coverage module, but passing the coverage module the --timid flag. Is there a way (e.g. setting an environment variable) to make coverage run with --timid? 回答1: You've got two options: Use a .coveragerc file to provide options to coverage.py Instead of running coverage inside nose, run nose inside coverage: coverage run c:\python25\scripts\nosetests-script.py (sorry for the Windows syntax if you aren't on Windows) 来源: https:/

How do I generate coverage xml report for a single package?

断了今生、忘了曾经 提交于 2019-12-22 10:54:45
问题 I'm using nose and coverage to generate coverage reports. I only have one package right now, ae , so I specify to only cover that: nosetests -w tests/unit --with-xunit --with-coverage --cover-package=ae And here are the results, which look good: Name Stmts Exec Cover Missing ---------------------------------------------- ae 1 1 100% ae.util 253 224 88% 39, 63-65, 284, 287, 362, 406 ---------------------------------------------- TOTAL 263 234 88% -----------------------------------------------

Skip a unit test from a Nose2 Plugin

一笑奈何 提交于 2019-12-22 10:27:24
问题 I'm having trouble actually skipping a unit test from a Nose2 plugin. I am able to mark the test skipped and see the reason in the final result, but the test still runs. This example code should basically skip any test, as long as the plugin is active. from nose2.events import Plugin class SkipAllTests(Plugin): def startTest(self, event): event.result.addSkip(event.test, 'skip it') event.handled = True If I call event.test.skipTest('reason') it actually raises the SkipTest exception like it

How can I mock sqlite3.Cursor

梦想的初衷 提交于 2019-12-22 05:27:33
问题 I've been pulling my hair out trying to figure out how to mock the sqlite3.Cursor class specifically the fetchall method. Consider the following code sample import sqlite3 from mock import Mock, patch from nose.tools import assert_false class Foo: def check_name(name): conn = sqlite3.connect('temp.db') c = conn.cursor() c.execute('SELECT * FROM foo where name = ?', name) if len(c.fetchall()) > 0: return True return False @patch('sqlite3.Cursor.fetchall', Mock(return_value=['John', 'Bob']))

How to make nosetests use python3

折月煮酒 提交于 2019-12-21 03:11:04
问题 I try to use nosetests ❯ nosetests '/pathTo/test' but it uses python 2.7 for my tests: sys.version_info(major=2, minor=7, micro=5, releaselevel='final', serial=0) So some of them fails, because they were written in python 3.3 . I work it around and installed virtual environment: pyvenv-3.3 py3env Activated it: source ~/py3env/bin/activate Check python virsion in virtual environment: ❯ python --version ⏎ Python 3.3.3 (py3env) Ok. But nosetest still uses python2.7 even in virtual environment:

Nosetest including unwanted parent directories

纵然是瞬间 提交于 2019-12-19 15:44:41
问题 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