nose

How to run included tests on deployed pylons application

I have installed pylons based application from egg, so it sits somewhere under /usr/lib/python2.5/site-packages. I see that the tests are packaged too and I would like to run them (to catch a problem that shows up on deployed application but not on development version). So how do I run them? Doing "nosetests" from directory containing ...

Preferred Python unit-testing framework

Hello, So far I've been using the built-in unittest module for unit-testing Python code. However, for simple cases it seems like an overkill. Being a derivative of xUnit, it appears a bit heavy for the dynamic nature of Python, where I would expect to write less to achieve the same effects. On the other hand, it is built-in, makes you w...

How do I get nose to discover dynamically-generated testcases?

This is a follow-up to a previous question of mine. In the previous question, methods were explored to implement what was essentially the same test over an entire family of functions, ensuring testing did not stop at the first function that failed. My preferred solution used a metaclass to dynamically insert the tests into a unittest.T...

Running unit tests with Nose inside a Python environment such as Autodesk Maya?

I'd like to start creating unit tests for my Maya scripts. These scripts must be run inside the Maya environment and rely on the maya.cmds module namespace. How can I run Nose tests from inside a running environment such as Maya? ...

List all Tests Found by Nosetest

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? ...

Using paver and nose together with an atypical directory structure

I'm trying to write a task for Paver that will run nosetests on my files. My directory structure looks like this: project/ file1.py file2.py file3.py build/ pavement.py subproject/ file4.py test/ file5.py file6.py Doctests (using the --with_doctest option) should be run on all the *.py files,...

I need a sample of python unit testing sqlalchemy model with nose

Can someone show me how to write unit tests for sqlalchemy model I created using nose. I just need one simple example. Thanks. ...

Can I restrict nose coverage output to directory (rather than package)?

My SUT looks like: foo.py bar.py tests/__init__.py [empty] tests/foo_tests.py tests/bar_tests.py tests/integration/__init__.py [empty] tests/integration/foo_tests.py tests/integration/bar_tests.py When I run nosetests --with-coverage, I get details for all sorts of modules that I'd rather ignore. But I can't use the --cover-package=P...

Problems using nose in a virtualenv.

I am unable to use nose (nosetests) in a virtualenv project - it can't seem to find the packages installed in the virtualenv environment. The odd thing is that i can set test_suite = 'nose.collector' in setup.py and run the tests just fine as python setup.py test but when running nosetests straight, there are all sorts of import e...

Unit testing with nose: tests at compile time?

Is it possible for the nose unit testing framework to perform tests during the compilation phase of a module? In fact, I'd like to test something with the following structure: x = 123 # [x is used here...] def test_x(): assert (x == 123) del x # Deleted because I don't want to clutter the module with unnecessary attributes nosetes...

How should I verify a log message when testing Python code under nose?

Hi all I'm trying to write a simple unit test that will verify that, under a certain condition, a class in my application will log an error via the standard logging API. I can't work out what the cleanest way to test this situation is. I know that nose already captures logging output through it's logging plugin, but this seems to be i...

How can I get nose to find class attributes defined on a base test class?

I'm getting some integration tests running against the database, and I'd like to have a structure that looks something like this: class OracleMixin(object): oracle = True # ... set up the oracle connection class SqlServerMixin(object): sql_server = True # ... set up the sql server connection class SomeTests(object): ...

setuptools / dpkg-buildpackage: Refuse to build if nosetests fail

I have a very simple python package that I build into debian packages using setuptools, cdbs and pycentral: setup.py: from setuptools import setup setup(name='PHPSerialize', version='1.0', py_modules=['PHPSerialize'], test_suite = 'nose.collector' ) debian/rules: #!/usr/bin/make -f DEB_PYTHON_SYSTEM = pycentral include /usr/...

Python test framework with support of non-fatal failures

I'm evaluating "test frameworks" for automated system tests; so far I'm looking for a python framework. In py.test or nose I can't see something like the EXPECT macros I know from google testing framework. I'd like to make several assertions in one test while not aborting the test at the first failure. Am I missing something in these fra...

nose tests of Pylons app with models in init_model?

I have a stock Pylons app created using paster create -t pylons with one controller and matched functional test, added using paster controller, and a SQLAlchemy table and mapped ORM class. The SQLAlchemy stuff is defined in the init_model() function rather than in module scope (and needs to be there). Running python setup.py test raises...

Nose unable to find tests in ubuntu

Is there any reason why Nose wouldn't be able to find tests in Ubuntu 9.04? I'm using nose 0.11.1 with python 2.5.4. I can run tests only if I explicitly specify the filename. If I don't specify the filename it just says 0 tests. The same project runs tests fine on my Mac, so i'm quite stumped. ...

How do I use PyMock and Nose with Django models?

I'm trying to do TDD with PyMock, but I keep getting error when I use Nose and execute core.py from command line: "ERROR: Failure: ImportError (Settings cannot be imported, because environment variable DJA NGO_SETTINGS_MODULE is undefined.)" If I remove "from cms.models import Entry" from the unit test module I created, everything work...

Nose test script with command line arguments.

I would like to be able to run a nose test script which accepts command line arguments. For example, something along the lines: test.py import nose, sys def test(): # do something with the command line arguments print sys.argv if __name__ == '__main__': nose.runmodule() However, whenever I run this with a command line a...

Run nosetests with warnings as errors?

When running nosetests from the command line, how do you specify that 'non-ignored' warnings should be treated as errors? By default, warnings are printed, but not counted as failures: [snip]/service/accounts/database.py:151: SADeprecationWarning: Use session.add() self.session.save(state) [snip]/service/accounts/database.py:97: SADe...

How to produce html unit test output in Python?

I'm looking for any way to display the results of python unit tests in an html summary. There are tools like this for Java and Ruby... haven't yet located any tools that seem to do this for Python. Are there any out there? JUnit html output: Ruby RSpec output: ...