FAQ Database Discussion Community


Disable automatic test execution for some tests unless those are explicitly requested

python,unit-testing,nosetests
I have a few very slow tests and many short unittests. I would like to be able to run only the short unittests with plain nosetests command and if I decide it's time to run the slow tests, to be able to call them explicitly. What I'd like to be...

Switch from .bat to .py - duplicate logging

python-2.7,nosetests
I have a suite of tests I run with Nose and Python 2.7. I used to run the suite with runner.bat file. Using that, I would get nice logged output, like so: 2015-02-10 16:28:28,759 - DEBUG - Firefox version: 35.0 2015-02-10 16:28:28,788 - DEBUG - Running against Production on firefox...

Running Jenkins job with multiple browsers

jenkins,junit,nosetests
I am using the combination of Jenkins, python, unittest, nosetests to run test suites. I publish the results in nosetests.xml to Jenkins using Junit plugin. My question: How can I run the same test suites with different browsers (Chrome, FF, IE,…,etc) and publish all the results in the same Jenkins...

Nose does not run tests

python,nose,nosetests
Suppose you have a python package named A with the following directory structure A ├── B.py └── __init__.py where __init__.py is empty and the content of B.py is given by def test_B(): assert False Running nose on the simple package above misses the test $ nosetests A ---------------------------------------------------------------------- Ran 0...

Why does Python2.7 insist on Python3 print statement?

python-2.7,python-3.x,numpy,nose,nosetests
I was trying to see how nose & unittesting were being used in a package I'm learning about. This package uses nosetester, which is provided with numpy (why this is done also confuses me). My nosetester.py is in /usr/local/lib/python2.7/dist-packages/numpy/testing/. I am running Python 2.7.6. However, when I add a tracing...

Nose test runner finding all tests except a tag

python,tags,nosetests
I'm trying to figure out if there's a way to have the nose test runner run all tests except for those with a specific tag. Looks like this is possible with attributes but I don't see if there's a way to do it with tags, which are a subset of...

Setup and teardown functions executed once for all nosetests tests

python,nosetests
How to execute setup and teardown functions once for all nosetests tests? def common_setup(): #time consuming code pass def common_teardown(): #tidy up pass def test_1(): pass def test_2(): pass #desired behavior common_setup() test_1() test_2() common_teardown() Note that there exists a similar question with an answer that is not working with...

Using inheritance setUp() and tearDown() methods in nose tests

python,python-2.7,nosetests
I have a general test class in my nosetests suit and some sub-classes, inheriting from it. The config is likewise: class CGeneral_Test(object):: """This class defines the general testcase""" def __init__ (self): do_some_init() print "initialisation of general class done!" def setUp(self): print "this is the general setup method" do_setup() def tearDown(self):...

Python unit test using nosetests.exe prevent logging in files using logging module

python,unit-testing,logging,command-line,nosetests
I created a class for logging: import logging, time class QaLogger(): def __init__(self, filename='LOG.log', logger_name='Qa_Automation'): logging.basicConfig(filename=filename, level=logging.INFO) self.logger = logging.getLogger(logger_name) self.logger.initialized = True def log(self, msg): localtime = time.localtime() time_string = time.strftime("%Y-%m-%d-%H:%M:%S", localtime) self.logger.info(time_string + ": " + msg) Then I use this to log output to files when I...

how to omit imports using .coveragerc in coverage.py?

python,unit-testing,nosetests,coverage.py
I am using nosetests --with-coverage to test and see code coverage of my unit tests. The class that I test has many external dependencies and I mock all of them in my unit test. When I run nosetests --with-coverage, it shows a really long list of all the imports (including...

Nosetest Generator Method Behavior

python,generator,nosetests
I am trying to write a test class that includes a generator and run the test with nosetests. However, I am confused by the way the nosetests test runner seems to isolate the methods in the test class so they do not share the same self: class Test(object): def check(self):...

Python assertion error during nosetest?

python,nosetests
While testing i am getting assertion error like below AssertionError: Actual Items Not In Expected: [{'handicapped': False, 'first_name': u'JAMES', 'substance_abuse': False, 'tobacco_use': False}] here expected values are equal to actual . If both are same why it still expect ?...

NoseTest: running with coverage from Python script

python,nosetests
I want to run NoseTest from a Python script. But I want not only run it, but also measure test coverage. Just now I have the following code: import os import sys import nose sys.path.append(os.path.dirname(os.path.abspath(os.path.dirname(__file__)))) import tests if __name__ == "__main__": config = nose.config.Config(verbosity=3, stopOnError=False, argv=["--with-coverage"]) result = nose.run(module=tests, config=config)...

How to run tests in order of their appearance in test script using nose?

nose,py.test,nosetests,python-unittest,python-nose
I want run my tests in order of they are written not in alphabetical order that unittest does by default. import unittest class test2(unittest.TestCase): def test1(self): pass def test0(self): pass class test1(unittest.TestCase): def testB(self): pass def testA(self): pass In this example I want to set unittest or nosetests to run...

How can I unit test when code throws an ImportError?

python,unit-testing,nose,nosetests
I have a Python module that tries to import a module, and if it fails, adds sets up a lightweight class to replicate some of the functionality as a fallback. How can I write a unit test that covers both cases - when the module is present, and when the...

Selenium Send Keys Slow in IE9/10/11 Windows 7 64Bit (32bit IEServer)

python,internet-explorer,selenium,nosetests
Running Selenium Tests via Python 2.7.9 or C# app I'm getting really slow character input into text fields. Elsewhere I have seen the fix of using the 32bit IEDriver.exe but this hasn't fixed the issue for me. I've also tried with 'protected mode' all set to on and off. As...

How am I getting 'InternalError: table “dev~guestbook!!Entities” already exists' when I just created datastore?

python,google-app-engine,tdd,nosetests
I'm trying to figure out how to setup Test Driven Development for GAE. I start the tests with: nosetests -v --with-gae I keep getting the error: InternalError: table "dev~guestbook!!Entities" already exists The datastore doesn't exist until I create it in the setUp(), but I'm still getting an error that the...

Python nose test failing on JSON response

python,json,nosetests,flask-restful
This is the method in ReportRunner class in report_runner.py in my Flask-Restful app: class ReportRunner(object): def __init__(self): pass def setup_routes(self, app): app.add_url_rule("/run_report", view_func=self.run_report) def request_report(self, key): # code # def key_exists(self, key): # code # def run_report(self): key = request.args.get("key", "") if self.key_exists(key): self.request_report(report_type, key) return jsonify(message = "Success! Your...