Browse files

[0.10-dev] Imported last revision from python-hosting to start 0.10-d…

…ev branch
  • Loading branch information...
0 parents commit 05bff2bd41a7d1930dbfc4eb87a19e1461f5b467 @jpellerin jpellerin committed Dec 19, 2006
Showing with 9,526 additions and 0 deletions.
  1. +7 −0 AUTHORS
  2. +255 −0 CHANGELOG
  3. +10 −0 MANIFEST.in
  4. +19 −0 NEWS
  5. +59 −0 NEWS_0.9
  6. +30 −0 NOTES
  7. +287 −0 README.txt
  8. +74 −0 TODO_0_9
  9. +82 −0 examples/attrib_plugin.py
  10. +88 −0 examples/html_plugin/htmlplug.py
  11. +24 −0 examples/html_plugin/setup.py
  12. +4 −0 examples/plugin/plug.py
  13. +27 −0 examples/plugin/setup.py
  14. +219 −0 ez_setup.py
  15. +251 −0 index.html.tpl
  16. +504 −0 lgpl.txt
  17. +309 −0 nose/__init__.py
  18. +147 −0 nose/case.py
  19. +117 −0 nose/commands.py
  20. +70 −0 nose/config.py
  21. +481 −0 nose/core.py
  22. +11 −0 nose/exc.py
  23. +131 −0 nose/importer.py
  24. +202 −0 nose/inspector.py
  25. +370 −0 nose/loader.py
  26. +151 −0 nose/plugins/__init__.py
  27. +177 −0 nose/plugins/attrib.py
  28. +409 −0 nose/plugins/base.py
  29. +139 −0 nose/plugins/cover.py
  30. +121 −0 nose/plugins/doctests.py
  31. +51 −0 nose/plugins/missed.py
  32. +79 −0 nose/plugins/prof.py
  33. +109 −0 nose/proxy.py
  34. +250 −0 nose/result.py
  35. +467 −0 nose/selector.py
  36. +264 −0 nose/suite.py
  37. +103 −0 nose/tools.py
  38. +144 −0 nose/twistedtools.py
  39. +240 −0 nose/util.py
  40. +59 −0 notes
  41. +54 −0 scripts/mkindex.py
  42. +94 −0 scripts/mkrelease.py
  43. +146 −0 scripts/mkwiki.py
  44. +12 −0 setup.cfg
  45. +62 −0 setup.py
  46. +6 −0 unit_tests/helpers.py
  47. +53 −0 unit_tests/mock.py
  48. +7 −0 unit_tests/support/foo/__init__.py
  49. +1 −0 unit_tests/support/foo/bar/__init__.py
  50. +8 −0 unit_tests/support/foo/bar/buz.py
  51. +7 −0 unit_tests/support/foo/doctests.txt
  52. +1 −0 unit_tests/support/foo/test_foo.py
  53. +3 −0 unit_tests/support/foo/tests/dir_test_file.py
  54. +1 −0 unit_tests/support/other/file.txt
  55. +1 −0 unit_tests/support/pkgorg/lib/modernity.py
  56. +4 −0 unit_tests/support/pkgorg/tests/test_mod.py
  57. +3 −0 unit_tests/support/script.py
  58. +1 −0 unit_tests/support/test-dir/test.py
  59. +13 −0 unit_tests/support/test.py
  60. +54 −0 unit_tests/test_cases.py
  61. +80 −0 unit_tests/test_collector.py
  62. +36 −0 unit_tests/test_config.py
  63. +41 −0 unit_tests/test_core.py
  64. +53 −0 unit_tests/test_importer.py
  65. +125 −0 unit_tests/test_inspector.py
  66. +50 −0 unit_tests/test_lazy_suite.py
  67. +254 −0 unit_tests/test_loader.py
  68. +40 −0 unit_tests/test_logging.py
  69. +44 −0 unit_tests/test_plugin_interfaces.py
  70. +455 −0 unit_tests/test_plugins.py
  71. +193 −0 unit_tests/test_proxy.py
  72. +163 −0 unit_tests/test_result.py
  73. +357 −0 unit_tests/test_selector.py
  74. +38 −0 unit_tests/test_selector_plugins.py
  75. +37 −0 unit_tests/test_suite.py
  76. +95 −0 unit_tests/test_tools.py
  77. +65 −0 unit_tests/test_twisted.py
  78. +130 −0 unit_tests/test_utils.py
  79. +198 −0 work.py
7 AUTHORS
@@ -0,0 +1,7 @@
+Jason Pellerin
+Kumar McMillan
+Mika Eloranta
+Jay Parlar
+Scot Doyle
+James Casbon
+Antoine Pitrou
255 CHANGELOG
@@ -0,0 +1,255 @@
+0.9.2
+
+- Added make_decorator function to nose.tools. Used to construct decorator
+ functions that are well-behaved and preserve as much of the original
+ function's metadata as possible. Thanks to Antoine Pitrou for the patch.
+- Added nose.twistedtools, contributed by Antoine Pitrou. This module adds
+ @deferred decorator that makes it simple to write deferred tests, with or
+ without timeouts.
+- Added nosetests setuptools command. Now you can run python setup.py
+ nosetests and have access to all nose features and plugins. Thanks to James
+ Casbon for the patch.
+
+0.9.1
+
+- New function nose.runmodule() finds and runs tests only in a
+ single module, which defaults to __main__ (like unittest.main() or
+ doctest.runmodule()). Thanks Greg Wilson for the suggestion.
+- Multiple -w (--where) arguments can now be used in one command line,
+ to find and run tests in multiple locations. Thanks Titus Brown for
+ the suggestion.
+- Multiple --include and --exclude arguments are now accepted in one command
+ line. Thanks Michal Kwiatkowski for the feature request.
+- Coverage will now include modules not imported by any test when
+ using the new --cover-inclusive switch. Thanks James Casbon for the
+ patch.
+- module:TestClass test selections now properly select all tests in the test
+ class.
+- startTest and stopTest are now called in plugins at the beginning and end of
+ test suites, including test modules, as well as individual tests. Thanks
+ Michal Kwiatkowski for the suggestion.
+- Fix bug in test selection when run as ``python setup.py test``: 'test' was
+ passing through and being used as the test name selection. Thanks Kumar
+ McMillan for the bug report.
+- Fix bug in handling of -x/--stop option where the test run would stop on
+ skipped or deprecated tests. Thanks Kumar McMillan for the bug report.
+- Fix bug in loading tests from projects with layouts that place modules in
+ /lib or /src dirs and tests in a parallel /tests dir.
+- Fix bug in python version detection. Thanks Kevin Dangoor for the bug report
+ and fix.
+- Fix log message in selector that could raise IndexError. Thanks Kumar
+ McMillan for the bug report and patch.
+- Fix bug in handling doctest extension arguments specified in environment and
+ on command line. Thanks Ian Bicking for the bug report.
+- Fix bug in running fixtures (setup/teardown) that are not functions, and
+ report a better error message when a fixture is not callable. Thanks Ian
+ Bicking for the bug report.
+
+0.9.0
+
+- More unit tests and better test coverage. Numerous bugfixes deriving from
+ same.
+- Make --exe option do what it says, and turn it on by default on
+ Windows. Add --noexe option so windows users can turn if off.Thanks
+ richard at artsalliancemedia dot com for the bug reports.
+- Handle a working directory that happens to be in the middle of a package
+ more gracefully. Thanks Max Ischenko for the bug report and test case.
+- Fix bugs in test name comparison when a test module is specified whose name
+ overlaps that of a non-test module. Thanks Max Ischenko for the bug report
+ and test case.
+- Fix warning spam when a non-existent test file is requested on the command
+ line. Thanks Max Ischenko for the bug report.
+
+0.9.0b2
+
+- Allow --debug to set any logger to DEBUG. Thanks to casbon at gmail dot com for
+ the patch.
+- Fix doctest help, which was missing notes about the environment variables
+ that it accepts. Thanks to Kumar McMillan for the patch.
+- Restore sys.stdout after run() in nose.core. Thanks to Titus Brown for the
+ bug report.
+- Correct handling of trailing comma in attrib plugin args. Thanks Titus Brown
+ for the patch.
+
+0.9.0b1
+
+- Fix bug in handling of OR conditions in attrib plugin. Thanks to Titus
+ Brown for the bug report.
+- Fix bug in nose.importer that would cause an attribute error when a local
+ module shadowed a builtin, or other object in sys.modules, without a
+ __file__ attribute. Thanks to casbon at gmail dot com for the bug report.
+- Fix bug in nose.tools decorators that would cause decorated tests to appear
+ with incorrect names in result output.
+
+0.9.0a2
+
+- In TestLoader, use inspect's isfunction() and ismethod() to filter functions
+ and methods, instead of callable(). Thanks to Kumar McMillan for reporting
+ the bug.
+- Fix doctest plugin: return an empty iterable when no tests are found in a
+ directory instead of None. Thanks to Kumar McMillan for the bug report and
+ patch.
+- Ignore executable python modules, unless run with --exe file. This is a
+ partial defense against nose causing trouble by loading python modules that
+ are not import-safe. The full defense: don't write modules that aren't
+ import safe!
+- Catch and warn about errors on plugin load instead of dying.
+- Renamed builtin profile module from nose.plugins.profile to
+ nose.plugins.prof to avoid shadowing stdlib profile.py module.
+
+0.9.0a1
+
+- Add support for plugins, with hooks for selecting, loading and reporting on
+ tests. Doctest and coverage are now plugins.
+- Add builtin plugins for profiling with hotshot, selecting tests by
+ attribute (contributed by Mika Eloranta), and warning of missed tests
+ specified on command line.
+- Change command line test selection syntax to match unittest. Thanks to Titus
+ Brown for the suggestion.
+- Option to drop into pdb on error or failure.
+- Option to stop running on first error or failure. Thanks to Kevin Dangoor
+ for the suggestion.
+- Support for doctests in files other than python modules (python 2.4 only)
+- Reimplement base test selection as single self-contained class.
+- Reimplement test loading as unittest-compatible TestLoader class.
+- Remove all monkeypatching.
+- Reimplement output capture and assert introspection support in
+ unittest-compatible Result class.
+- Better support for multiline constructions in assert introspection.
+- More context output with assert introspections.
+- Refactor setuptools test command support to use proxied result, which
+ enables output capture and assert introspection support without
+ monkeypatching. Thanks to Philip J. Eby for the suggestion and skeleton
+ implementation.
+- Add support for generators in test classes. Thanks to Jay Parlar for the
+ suggestion and patch.
+- Add nose.tools package with some helpful test-composition functions and
+ decorators, including @raises, contributed by Scot Doyle.
+- Reimplement nose.main (TestProgram) to have unittest-compatible signature.
+- All-new import path handling. You can even turn it off! (If you don't,
+ nose will ensure that all directories from which it imports anything are on
+ sys.path before the import.)
+- Logging package used for verbose logging.
+- Support for skipped and deprecated tests.
+- Configuration is no longer global.
+
+0.8.7
+
+- Add support for py.test-style test generators. Thanks to Jay Parlar for
+ the suggestion.
+- Fix bug in doctest discovery. Thanks to Richard Cooper for the bug report.
+- Fix bug in output capture being appended to later exceptions. Thanks to
+ Titus Brown for the patch that uncovered the bug.
+- Fix bug(?) in Exception patch that caused masked hasattr/__getattr__ loops
+ to either become actual infinite loops, or at least take so long to finally
+ error out that they might as well be infinite.
+- Add -m option to restrict test running to only tests in a particular package
+ or module. Like the -f option, -m does not restrict test *loading*, only
+ test *execution*.
+- When loading and running a test module, ensure that the module's path is in
+ sys.path for the duration of the run, not just while importing the module.
+- Add id() method to all callable test classes, for greater unittest
+ compatibility.
+
+0.8.6
+
+- Fix bug with coverage output when sys.modules contains entries without
+ __file__ attributes
+- Added -p (--cover-packages) switch that may be used to restrict coverage
+ report to modules in the indicated package(s)
+
+0.8.5
+
+- Output capture and verbose assertion errors now work when run like
+ 'python setup.py test', as advertised.
+- Code coverage improvements: now coverage will be output for all modules
+ imported by any means that were not in sys.modules at the start of the test
+ run. By default, test modules will be excluded from the coverage report, but
+ you can include them with the -t (--cover-tests) option.
+
+0.8.4
+
+- Fix bugs in handling of setup/teardown fixtures that could cause TypeError
+ exceptions in fixtures to be silently ignored, or multiple fixtures of the
+ same type to run. Thanks to Titus Brown for the bug report.
+
+0.8.3
+
+- Add -V (--version) switch to nosetests
+- Fix bug where sys.path would not be set up correctly when running some
+ tests, producing spurious import errors (Thanks to Titus Brown and Mike
+ Thomson for the bug reports)
+- For test classses not derived from unittest.TestCase, output (module.Class)
+ "doc string" as test description, when method doc string is available
+ (Thanks to David Keeney for the suggestion, even if this isn't quite what he
+ meant)
+
+0.8.2
+
+- Revise import to bypass sys.path and manipulate sys.modules more
+ intelligently, ensuring that the test module we think we are loading is the
+ module we actually load, and that modules loaded by other imports are not
+ reloaded without cause
+- Allow test directories inside of packages. Formerly directories matching
+ testMatch but lacking an __init__.py would cause an ImportError when located
+ inside of packages
+- Fix bugs in different handling of -f switch in combination with -w and -o
+
+0.8.1
+
+- Fix bug in main() that resulted in incorrect exit status for nosetests
+ script when tests fail
+- Add missing test files to MANIFEST.in
+- Miscellaneous pylint cleanups
+
+0.8
+
+- Add doctest support
+- Add optional code coverage support, using Ned Batchelder's coverage.py;
+ activate with --coverage switch or NOSE_COVERAGE environment variable
+- More informative error message on import error
+- Fix bug where module setup could be called twice and teardown skipped
+ for certain setup method names.
+- main() returns success value, does not exit. run_exit() added to support
+ old behavior; nosetests script now calls nose.run_exit()
+
+0.7.5
+
+- Fix bus error on exit
+- Discover tests inside of non-TestCase classes that match testMatch
+- Reorganize selftest: now selftest tests the output of a full nose run
+- Add test_with_setup.py contributed by Kumar McMillan
+
+0.7.2
+
+- Refactor and correct bugs in discovery and test loading
+- Reorganize and expand documentation
+- Add -f (run this test file only) switch
+
+0.7.1
+
+- Bugfix release: test files in root of working directory were not being
+ stripped of file extension before import.
+
+0.7
+
+- Change license to LGPL
+- Major rework of output capture and assert introspection
+- Improve test discovery: now finds tests in packages
+- Replace -n switch ('no cwd') with -w switch ('look here')
+
+0.6
+
+- New nosetests script
+- Allow specification of names on command line that are loadable but not
+ directly loadable as modules (eg nosetests -o path/to/tests.py)
+- Add optional py.test-like assert introspection. Thanks to Kevin Dangoor
+ for the suggestion.
+- Improvements to selftest
+
+0.5.1
+
+- Increased compatibility with python 2.3 (and maybe earlier)
+- Increased compatibility with tests written for py.test: now calls
+ module.setup_module(module) if module.setup_module() fails
+
10 MANIFEST.in
@@ -0,0 +1,10 @@
+include AUTHORS
+include ez_setup.py
+include unit_tests/*/*.py
+include unit_tests/*/*/*.py
+include unit_tests/*/*/*/*.py
+include unit_tests/*/*/*/*/*.py
+include CHANGELOG
+include NEWS
+include README.txt
+include lgpl.txt
19 NEWS
@@ -0,0 +1,19 @@
+New in version 0.9.1
+--------------------
+
+Nose 0.9.1 is mainly a bug-fix release, but it does contain a few new
+features.
+
+* The --where (-w), --include and --exclude arguments may now all appear
+ multiple times in a single command line, allowing easier running of
+ multiple test suites and test suites with more diverse layouts.
+* For programmatic use, nose.runmodule() was added. Similar to
+ doctest.runmodule() and unittest.main(), nose.runmodule() will load and run
+ tests in the current module, which defaults to __main__.
+* A number of changes to plugins and plugin hooks make current plugins work
+ better and allow more interesting plugins to be written.
+
+Just about everything in this release was driven by requests from
+users. Thanks to the many folks who filed bug reports and suggested features,
+ideas and solutions to thorny problems.
+
59 NEWS_0.9
@@ -0,0 +1,59 @@
+New in version 0.9
+------------------
+
+0.9 Final is here!
+==================
+
+nose 0.9 includes a host of new features, as well as numerous
+backwards-incompatible changes to interfaces and implementation.
+
+Thanks to the many folks who have contributed patches and ideas and made bug
+reports for the development version of 0.9, especially Mika Eloranta, Jay
+Parlar, Kevin Dangoor, Scot Doyle, Titus Brown and Philip J.Eby.
+
+Here's a quick rundown of what's new in 0.9
+
+- Plugins
+
+ The most important new feature is support for plugins using setuptools
+ entrypoints. nose plugins can select and load tests (like the builtin
+ doctest plugin), reject tests (like the builtin attrib plugin, contributed
+ by Mika Eloranta, that allows users to select tests by attribute),
+ watch and report on tests (like the builtin coverage and profiler plugins),
+ completely replace test result output (like the html result plugin in the
+ examples directory) or any combination of the above. Writing plugins is
+ simple: subclass nose.plugins.Plugin and implement any of the methods in
+ nose.plugins.IPluginInterface.
+
+- Better compatibility with unittest
+
+ Test loading has been consolidated into a test loader class that is drop-in
+ compatible with unittest.TestLoader. Likewise test result output, including
+ output capture, assert introspection, and support for skipped and deprecated
+ tests, in nose.result.TextTestResult. If you want those features and not the
+ rest of nose, you can use just those classes. nose.main() has also been
+ rewritten to have the same signature as unittest.main().
+
+- Better command line interface
+
+ Command line test selection is more intuitive and powerful, enabling easy
+ and correct running of single tests while ensuring that fixtures (setup and
+ teardown) are correctly executed at all levels. No more -f -m or -o options:
+ now simply specify the tests to run::
+
+ nosetests this/file.py that.module
+
+ Tests may be specified down to the callable::
+
+ nosetests this/file.py:TestClass that.module:this_test
+ nosetests that.module:TestClass.test_method
+
+ There are also new options for dropping into pdb on errors or failures, and
+ stopping the test run on the first error or failure (thanks to Kevin Dangoor
+ for the idea).
+
+- More!
+
+ Helpful test decorators and functions in nose.tools. Support for generators
+ in test classes. Better import path handling -- that you can shut off!
+ Detailed verbose logging using the logging package. And more...
30 NOTES
@@ -0,0 +1,30 @@
+notes on loading from modules
+
+this pretty much all has to take place inside of the _tests iterator.
+
+
+if the module is wanted
+ run setup
+ load tests (including submodules) and yield each test
+ run teardown
+else if the module is not wanted:
+ * do not import the module *
+ if the module is a package:
+ recurse into the package looking for test modules
+
+
+make suite.TestSuite
+put run, call, setup, teardown, shortdescription there
+
+make LazySuite subclass it
+
+get rid of TestModule
+
+do module import in loadTestsFromModuleName; if an error, pass the error
+to the module suite, whose run() should re-raise the error so that import
+errors are seen only when we actually try to run the tests
+
+make ModuleSuite class with setUp, tearDown doing try_run, it gets
+additional module and error keyword args
+
+rename TestDir to DirectorySuite
287 README.txt
@@ -0,0 +1,287 @@
+nose: a discovery-based unittest extension.
+
+nose provides an alternate test discovery and running process for
+unittest, one that is intended to mimic the behavior of py.test as much
+as is reasonably possible without resorting to too much magic.
+
+Basic usage
+-----------
+
+Use the nosetests script (after installation by setuptools)::
+
+ nosetests [options] [(optional) test files or directories]
+
+You may also use nose in a test script::
+
+ import nose
+ nose.main()
+
+If you don't want the test script to exit with 0 on success and 1 on failure
+(like unittest.main), use nose.run() instead::
+
+ import nose
+ result = nose.run()
+
+`result` will be true if the test run succeeded, or false if any test failed
+or raised an uncaught exception. Lastly, you can run nose.core directly, which
+will run nose.main()::
+
+ python /path/to/nose/core.py
+
+Please see the usage message for the nosetests script for information
+about how to control which tests nose runs, which plugins are loaded,
+and the test output.
+
+Features
+--------
+
+Run as collect
+==============
+
+nose begins running tests as soon as the first test module is loaded, it
+does not wait to collect all tests before running the first.
+
+Output capture
+==============
+
+Unless called with the -s (--nocapture) switch, nose will capture stdout
+during each test run, and print the captured output only for tests that
+fail or have errors. The captured output is printed immediately
+following the error or failure output for the test. (Note that output in
+teardown methods is captured, but can't be output with failing tests,
+because teardown has not yet run at the time of the failure.)
+
+Assert introspection
+====================
+
+When run with the -d (--detailed-errors) switch, nose will try to output
+additional information about the assert expression that failed with each
+failing test. Currently, this means that names in the assert expression
+will be expanded into any values found for them in the locals or globals
+in the frame in which the expression executed.
+
+In other words if you have a test like::
+
+ def test_integers():
+ a = 2
+ assert a == 4, "assert 2 is 4"
+
+You will get output like::
+
+ File "/path/to/file.py", line XX, in test_integers:
+ assert a == 4, "assert 2 is 4"
+ AssertionError: assert 2 is 4
+ >> assert 2 == 4, "assert 2 is 4"
+
+Setuptools integration
+======================
+
+nose may be used with the setuptools_ test command. Simply specify
+nose.collector as the test suite in your setup file::
+
+ setup (
+ # ...
+ test_suite = 'nose.collector'
+ )
+
+Then to find and run tests, you can run::
+
+ python setup.py test
+
+When running under setuptools, you can configure nose settings via the
+environment variables detailed in the nosetests script usage message.
+
+Please note that when run under the setuptools test command, some plugins will
+not be available, including the builtin coverage, profiler, and missed test
+plugins.
+
+nose also includes its own setuptools command, `nosetests`, that provides
+support for all plugins and command line options, as well as configuration
+using the setup.cfg file. See nose.commands_ for more information about the
+`nosetests` command.
+
+.. _setuptools: http://peak.telecommunity.com/DevCenter/setuptools
+.. _nose.commands: #commands
+
+Writing tests
+-------------
+
+As with py.test, nose tests need not be subclasses of TestCase. Any function
+or class that matches the configured testMatch regular expression
+('(?:^|[\b_\.-])[Tt]est)'' by default) and lives in a module that also
+matches that expression will be run as a test. For the sake of compatibility
+with legacy unittest test cases, nose will also load tests from
+unittest.TestCase subclasses just like unittest does. Like py.test, functional
+tests will be run in the order in which they appear in the module
+file. TestCase derived tests and other test classes are run in alphabetical
+order.
+
+Fixtures
+========
+
+nose supports fixtures (setup and teardown methods) at the package,
+module, and test level. As with py.test or unittest fixtures, setup always
+runs before any test (or collection of tests for test packages and modules);
+teardown runs if setup has completed successfully, whether or not the test
+or tests pass. For more detail on fixtures at each level, see below.
+
+Test packages
+=============
+
+nose allows tests to be grouped into test packages. This allows
+package-level setup; for instance, if you need to create a test database
+or other data fixture for your tests, you may create it in package setup
+and remove it in package teardown once per test run, rather than having to
+create and tear it down once per test module or test case.
+
+To create package-level setup and teardown methods, define setup and/or
+teardown functions in the __init__.py of a test package. Setup methods may
+be named 'setup', 'setup_package', 'setUp',or 'setUpPackage'; teardown may
+be named 'teardown', 'teardown_package', 'tearDown' or 'tearDownPackage'.
+Execution of tests in a test package begins as soon as the first test
+module is loaded from the test package.
+
+Test modules
+============
+
+A test module is a python module that matches the testMatch regular
+expression. Test modules offer module-level setup and teardown; define the
+method 'setup', 'setup_module', 'setUp' or 'setUpModule' for setup,
+'teardown', 'teardown_module', or 'tearDownModule' for teardown. Execution
+of tests in a test module begins after all tests are collected.
+
+Test classes
+============
+
+A test class is a class defined in a test module that is either a subclass
+of unittest.TestCase, or matches testMatch. Test classes that don't
+descend from unittest.TestCase are run in the same way as those that do:
+methods in the class that match testMatch are discovered, and a test case
+constructed to run each with a fresh instance of the test class. Like
+unittest.TestCase subclasses, other test classes may define setUp and
+tearDown methods that will be run before and after each test method.
+
+Test functions
+==============
+
+Any function in a test module that matches testMatch will be wrapped in a
+FunctionTestCase and run as a test. The simplest possible failing test is
+therefore::
+
+ def test():
+ assert False
+
+And the simplest passing test::
+
+ def test():
+ pass
+
+Test functions may define setup and/or teardown attributes, which will be
+run before and after the test function, respectively. A convenient way to
+do this, especially when several test functions in the same module need
+the same setup, is to use the provided with_setup decorator::
+
+ def setup_func():
+ # ...
+
+ def teardown_func():
+ # ...
+
+ @with_setup(setup_func,teardown_func)
+ def test():
+ # ...
+
+For python 2.3, add the attributes by calling the decorator function like
+so::
+
+ def test():
+ # ...
+ test = with_setup(setup_func,teardown_func)(test)
+
+or by direct assignment::
+
+ test.setup = setup_func
+ test.teardown = teardown_func
+
+Test generators
+===============
+
+nose supports test functions and methods that are generators. A simple
+example from nose's selftest suite is probably the best explanation::
+
+ def test_evens():
+ for i in range(0, 5):
+ yield check_even, i, i*3
+
+ def check_even(n, nn):
+ assert n % 2 == 0 or nn % 2 == 0
+
+This will result in 4 tests. nose will iterate the generator, creating a
+function test case wrapper for each tuple it yields. As in the example, test
+generators must yield tuples, the first element of which must be a callable
+and the remaining elements the arguments to be passed to the callable.
+
+Setup and teardown functions may be used with test generators. The setup and
+teardown attributes must be attached to the generator function::
+
+ @with_setup(setup_func, teardown_func)
+ def test_generator():
+ ...
+ yield func, arg, arg ...
+
+The setup and teardown functions will be executed for each test that the
+generator returns.
+
+For generator methods, the setUp and tearDown methods of the class (if any)
+will be run before and after each generated test case.
+
+Please note that method generators `are not` supported in unittest.TestCase
+subclasses.
+
+About the name
+--------------
+
+* nose is the least silly short synonym for discover in the dictionary.com
+ thesaurus that does not contain the word 'spy'.
+* Pythons have noses
+* The nose knows where to find your tests
+* Nose Obviates Suite Employment
+
+Contact the author
+------------------
+
+To report bugs, ask questions, or request features, please use the trac
+instance provided by the great folks at python hosting, here:
+http://nose.python-hosting.com. Or, email the author at
+jpellerin+nose at gmail dot com. Patches are welcome!
+
+Similar test runners
+--------------------
+
+nose was inspired mainly by py.test_, which is a great test runner, but
+formerly was not all that easy to install, and is not based on unittest.
+
+Test suites written for use with nose should work equally well with py.test,
+and vice versa, except for the differences in output capture and command line
+arguments for the respective tools.
+
+.. _py.test: http://codespeak.net/py/current/doc/test.html
+
+License and copyright
+---------------------
+
+nose is copyright Jason Pellerin 2005-2006
+
+This program is free software; you can redistribute it and/or modify it
+under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation; either version 2 of the License, or (at your
+option) any later version.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program; if not, write to the Free Software Foundation,
+Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
74 TODO_0_9
@@ -0,0 +1,74 @@
+BUGS
+----
+
+split_test_name is detected as a test: rename it
+
+
+Refactor
+--------
+ - Make conf passed not global
+ - Use logging for messaging
+
+ X split out test selection into selector class
+ X use in core
+ X move config to own module
+ X move capture to result module
+ X implement in result
+ - remove from core
+ X use text test result in core
+ X use plugins in core
+ X coverage
+
+Output capture handling
+-----------------------
+ - Monkeypatch in a new _TextTestResult instead of all of the current chicanery
+
+
+Assert introspection
+--------------------
+ - use in assertion error only -- only replace that class (replace the
+ reference(s) in unittest as well)
+ - introspect object instances? what about methods (probably not)
+ - fix the 'EOF in multi-line input' bug
+
+
+Error handling
+--------------
+ - exit on error or fail
+ X pdb on error or fail
+
+
+Path handling
+-------------
+ X importer:
+ (all configurable!)
+ * before attempting import, ensure that the path to the module to
+ be imported is in sys.path;
+ * if the module is a file other than __init__.py in a dir containing an
+ __init__.py, walk up to find the root dir (with no __init__.py) and
+ ensure that directory is in sys.path
+ * after import, walk up package to package root and ensure that the
+ package root is in sys.path
+ * investigate Kumar's load/reload bug
+
+
+Plugins
+-------
+ - test selector: decide if a dir, module, file, class, or function is a
+ wanted test
+ X doctest
+ - test collector: given a context (module, directory, or file) return tests
+ X doctest
+ - test watcher: before_all, before_test, after_test, after_all ..
+ X coverage
+ - profile
+
+
+Utilities
+--------
+@raises(*exc) -- assert func call raises exception
+@timed(under, over, exact) -- assert func execs in under, over, exact time
+
+SkipTest exception ... catch in addError, addSkip instead, print skipped in
+output after failed
+Deprecated too?
82 examples/attrib_plugin.py
@@ -0,0 +1,82 @@
+"""
+Examples of test function/method attribute usage with patched nose
+
+Simple syntax (-a, --attr) examples:
+ * nosetests -a status=stable
+ => only test cases with attribute "status" having value "stable"
+
+ * nosetests -a priority=2,status=stable
+ => both attributes must match
+
+ * nosetests -a tags=http
+ => attribute list "tags" must contain value "http" (see test_foobar()
+ below for definition)
+
+ * nosetests -a slow
+ => attribute "slow" must be defined and its value cannot equal to False
+ (False, [], "", etc...)
+
+ * nosetests -a !slow
+ => attribute "slow" must NOT be defined or its value must be equal to False
+
+Eval expression syntax (-A, --eval-attr) examples:
+ * nosetests -A "not slow"
+ * nosetests -A "(priority > 5) and not slow"
+
+This example and the accompanied patch is in public domain, free for any use.
+
+email: mika.eloranta@gmail.com
+
+"""
+
+__author__ = 'Mika Eloranta'
+
+def attr(**kwargs):
+ """Add attributes to a test function/method/class"""
+ def wrap(func):
+ func.__dict__.update(kwargs)
+ return func
+ return wrap
+
+# test function with single attribute
+@attr(priority = 1)
+def test_dummy():
+ print "dummy"
+
+# test function with multiple attributes
+@attr(status = "stable", # simple string attribute
+ slow = True, # attributes can be of any type
+ # (e.g. bool)
+ priority = 1, # ...or int
+ tags = ["http", "pop", "imap"]) # will be run if any of the list items
+ # matches
+def test_foobar():
+ print "foobar"
+
+# another way of adding attributes...
+def test_fluffy():
+ print "fluffy"
+test_fluffy.status = "unstable"
+test_fluffy.slow = True
+test_fluffy.priority = 2
+
+# works for class methods, too
+class TestSomething:
+ @attr(status = "stable", priority = 2)
+ def test_xyz(self):
+ print "xyz"
+
+# class methods "inherit" attributes from the class but can override them
+class TestOverride:
+ value = "class"
+ # run all methods with "nosetests -a value"
+
+ @attr(value = "method")
+ def test_override(self):
+ # run with "nosetests -a value=method"
+ print "override"
+
+ def test_inherit(self):
+ # run with "nosetests -a value=class"
+ print "inherit"
+
88 examples/html_plugin/htmlplug.py
@@ -0,0 +1,88 @@
+"""This is a very basic example of a plugin that controls all test
+output. In this case, it formats the output as ugly unstyled html.
+
+Upgrading this plugin into one that uses a template and css to produce
+nice-looking, easily-modifiable html output is left as an exercise for
+the reader who would like to see his or her name in the nose AUTHORS file.
+"""
+import traceback
+from nose.plugins import Plugin
+
+class HtmlOutput(Plugin):
+ """Output test results as ugly, unstyled html.
+ """
+
+ name = 'html-output'
+
+ def __init__(self):
+ super(HtmlOutput, self).__init__()
+ self.html = [ '<html><head>',
+ '<title>Test output</title>',
+ '</head><body>' ]
+
+ def addSuccess(self, test, capt):
+ self.html.append('<span>ok</span>')
+
+ def addSkip(self, test):
+ self.html.append('<span>SKIPPED</span>')
+
+ def addDeprecated(self, test):
+ self.html.append('<span>DEPRECATED</span>')
+
+ def addError(self, test, err, capt):
+ err = self.formatErr(err)
+ self.html.append('<span>ERROR</span>')
+ self.html.append('<pre>%s</pre>' % err)
+ if capt:
+ self.html.append('<pre>%s</pre>' % capt)
+
+ def addFailure(self, test, err, capt, tb_info):
+ err = self.formatErr(err)
+ self.html.append('<span>FAIL</span>')
+ self.html.append('<pre>%s</pre>' % err)
+ if tb_info:
+ self.html.append('<pre>%s</pre>' % tb_info)
+ if capt:
+ self.html.append('<pre>%s</pre>' % capt)
+
+ def finalize(self, result):
+ self.html.append('<div>')
+ self.html.append("Ran %d test%s" %
+ (result.testsRun, result.testsRun != 1 and "s" or ""))
+ self.html.append('</div>')
+ self.html.append('<div>')
+ if not result.wasSuccessful():
+ self.html.extend(['<span>FAILED ( ',
+ 'failures=%d ' % len(result.failures),
+ 'errors=%d' % len(result.errors),
+ ')</span>'])
+ else:
+ self.html.append('OK')
+ self.html.append('</div></body></html>')
+ # print >> sys.stderr, self.html
+ for l in self.html:
+ self.stream.writeln(l)
+
+ def formatErr(self, err):
+ exctype, value, tb = err
+ return traceback.format_exception(exctype, value, tb)
+
+ def setOutputStream(self, stream):
+ # grab for own use
+ self.stream = stream
+ # return dummy stream
+ class dummy:
+ def write(self, *arg):
+ pass
+ def writeln(self, *arg):
+ pass
+ d = dummy()
+ return d
+
+ def startTest(self, test):
+ self.html.extend([ '<div><span>',
+ test.shortDescription() or str(test),
+ '</span>' ])
+
+ def stopTest(self, test):
+ self.html.append('</div>')
24 examples/html_plugin/setup.py
@@ -0,0 +1,24 @@
+import sys
+try:
+ import ez_setup
+ ez_setup.use_setuptools()
+except ImportError:
+ pass
+
+from setuptools import setup
+
+setup(
+ name='Example html output plugin',
+ version='0.1',
+ author='Jason Pellerin',
+ author_email = 'jpellerin+nose@gmail.com',
+ description = 'Example nose html output plugin',
+ license = 'GNU LGPL',
+ py_modules = ['htmlplug'],
+ entry_points = {
+ 'nose.plugins': [
+ 'htmlout = htmlplug:HtmlOutput'
+ ]
+ }
+
+ )
4 examples/plugin/plug.py
@@ -0,0 +1,4 @@
+from nose.plugins import Plugin
+
+class ExamplePlugin(Plugin):
+ pass
27 examples/plugin/setup.py
@@ -0,0 +1,27 @@
+"""
+An example of how to create a simple nose plugin.
+
+"""
+try:
+ import ez_setup
+ ez_setup.use_setuptools()
+except ImportError:
+ pass
+
+from setuptools import setup
+
+setup(
+ name='Example plugin',
+ version='0.1',
+ author='Jason Pellerin',
+ author_email = 'jpellerin+nose@gmail.com',
+ description = 'Example nose plugin',
+ license = 'GNU LGPL',
+ py_modules = ['plug'],
+ entry_points = {
+ 'nose.plugins': [
+ 'example = plug:ExamplePlugin'
+ ]
+ }
+
+ )
219 ez_setup.py
@@ -0,0 +1,219 @@
+#!python
+"""Bootstrap setuptools installation
+
+If you want to use setuptools in your package's setup.py, just include this
+file in the same directory with it, and add this to the top of your setup.py::
+
+ from ez_setup import use_setuptools
+ use_setuptools()
+
+If you want to require a specific version of setuptools, set a download
+mirror, or use an alternate download directory, you can do so by supplying
+the appropriate options to ``use_setuptools()``.
+
+This file can also be run as a script to install or upgrade setuptools.
+"""
+import sys
+DEFAULT_VERSION = "0.6c2"
+DEFAULT_URL = "http://cheeseshop.python.org/packages/%s/s/setuptools/" % sys.version[:3]
+
+md5_data = {
+ 'setuptools-0.6b1-py2.3.egg': '8822caf901250d848b996b7f25c6e6ca',
+ 'setuptools-0.6b1-py2.4.egg': 'b79a8a403e4502fbb85ee3f1941735cb',
+ 'setuptools-0.6b2-py2.3.egg': '5657759d8a6d8fc44070a9d07272d99b',
+ 'setuptools-0.6b2-py2.4.egg': '4996a8d169d2be661fa32a6e52e4f82a',
+ 'setuptools-0.6b3-py2.3.egg': 'bb31c0fc7399a63579975cad9f5a0618',
+ 'setuptools-0.6b3-py2.4.egg': '38a8c6b3d6ecd22247f179f7da669fac',
+ 'setuptools-0.6b4-py2.3.egg': '62045a24ed4e1ebc77fe039aa4e6f7e5',
+ 'setuptools-0.6b4-py2.4.egg': '4cb2a185d228dacffb2d17f103b3b1c4',
+ 'setuptools-0.6c1-py2.3.egg': 'b3f2b5539d65cb7f74ad79127f1a908c',
+ 'setuptools-0.6c1-py2.4.egg': 'b45adeda0667d2d2ffe14009364f2a4b',
+ 'setuptools-0.6c2-py2.3.egg': 'f0064bf6aa2b7d0f3ba0b43f20817c27',
+ 'setuptools-0.6c2-py2.4.egg': '616192eec35f47e8ea16cd6a122b7277',
+}
+
+import sys, os
+
+def _validate_md5(egg_name, data):
+ if egg_name in md5_data:
+ from md5 import md5
+ digest = md5(data).hexdigest()
+ if digest != md5_data[egg_name]:
+ print >>sys.stderr, (
+ "md5 validation of %s failed! (Possible download problem?)"
+ % egg_name
+ )
+ sys.exit(2)
+ return data
+
+
+def use_setuptools(
+ version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir,
+ download_delay=15
+):
+ """Automatically find/download setuptools and make it available on sys.path
+
+ `version` should be a valid setuptools version number that is available
+ as an egg for download under the `download_base` URL (which should end with
+ a '/'). `to_dir` is the directory where setuptools will be downloaded, if
+ it is not already available. If `download_delay` is specified, it should
+ be the number of seconds that will be paused before initiating a download,
+ should one be required. If an older version of setuptools is installed,
+ this routine will print a message to ``sys.stderr`` and raise SystemExit in
+ an attempt to abort the calling script.
+ """
+ try:
+ import setuptools
+ if setuptools.__version__ == '0.0.1':
+ print >>sys.stderr, (
+ "You have an obsolete version of setuptools installed. Please\n"
+ "remove it from your system entirely before rerunning this script."
+ )
+ sys.exit(2)
+ except ImportError:
+ egg = download_setuptools(version, download_base, to_dir, download_delay)
+ sys.path.insert(0, egg)
+ import setuptools; setuptools.bootstrap_install_from = egg
+
+ import pkg_resources
+ try:
+ pkg_resources.require("setuptools>="+version)
+
+ except pkg_resources.VersionConflict, e:
+ # XXX could we install in a subprocess here?
+ print >>sys.stderr, (
+ "The required version of setuptools (>=%s) is not available, and\n"
+ "can't be installed while this script is running. Please install\n"
+ " a more recent version first.\n\n(Currently using %r)"
+ ) % (version, e.args[0])
+ sys.exit(2)
+
+def download_setuptools(
+ version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir,
+ delay = 15
+):
+ """Download setuptools from a specified location and return its filename
+
+ `version` should be a valid setuptools version number that is available
+ as an egg for download under the `download_base` URL (which should end
+ with a '/'). `to_dir` is the directory where the egg will be downloaded.
+ `delay` is the number of seconds to pause before an actual download attempt.
+ """
+ import urllib2, shutil
+ egg_name = "setuptools-%s-py%s.egg" % (version,sys.version[:3])
+ url = download_base + egg_name
+ saveto = os.path.join(to_dir, egg_name)
+ src = dst = None
+ if not os.path.exists(saveto): # Avoid repeated downloads
+ try:
+ from distutils import log
+ if delay:
+ log.warn("""
+---------------------------------------------------------------------------
+This script requires setuptools version %s to run (even to display
+help). I will attempt to download it for you (from
+%s), but
+you may need to enable firewall access for this script first.
+I will start the download in %d seconds.
+
+(Note: if this machine does not have network access, please obtain the file
+
+ %s
+
+and place it in this directory before rerunning this script.)
+---------------------------------------------------------------------------""",
+ version, download_base, delay, url
+ ); from time import sleep; sleep(delay)
+ log.warn("Downloading %s", url)
+ src = urllib2.urlopen(url)
+ # Read/write all in one block, so we don't create a corrupt file
+ # if the download is interrupted.
+ data = _validate_md5(egg_name, src.read())
+ dst = open(saveto,"wb"); dst.write(data)
+ finally:
+ if src: src.close()
+ if dst: dst.close()
+ return os.path.realpath(saveto)
+
+def main(argv, version=DEFAULT_VERSION):
+ """Install or upgrade setuptools and EasyInstall"""
+
+ try:
+ import setuptools
+ except ImportError:
+ egg = None
+ try:
+ egg = download_setuptools(version, delay=0)
+ sys.path.insert(0,egg)
+ from setuptools.command.easy_install import main
+ return main(list(argv)+[egg]) # we're done here
+ finally:
+ if egg and os.path.exists(egg):
+ os.unlink(egg)
+ else:
+ if setuptools.__version__ == '0.0.1':
+ # tell the user to uninstall obsolete version
+ use_setuptools(version)
+
+ req = "setuptools>="+version
+ import pkg_resources
+ try:
+ pkg_resources.require(req)
+ except pkg_resources.VersionConflict:
+ try:
+ from setuptools.command.easy_install import main
+ except ImportError:
+ from easy_install import main
+ main(list(argv)+[download_setuptools(delay=0)])
+ sys.exit(0) # try to force an exit
+ else:
+ if argv:
+ from setuptools.command.easy_install import main
+ main(argv)
+ else:
+ print "Setuptools version",version,"or greater has been installed."
+ print '(Run "ez_setup.py -U setuptools" to reinstall or upgrade.)'
+
+
+
+def update_md5(filenames):
+ """Update our built-in md5 registry"""
+
+ import re
+ from md5 import md5
+
+ for name in filenames:
+ base = os.path.basename(name)
+ f = open(name,'rb')
+ md5_data[base] = md5(f.read()).hexdigest()
+ f.close()
+
+ data = [" %r: %r,\n" % it for it in md5_data.items()]
+ data.sort()
+ repl = "".join(data)
+
+ import inspect
+ srcfile = inspect.getsourcefile(sys.modules[__name__])
+ f = open(srcfile, 'rb'); src = f.read(); f.close()
+
+ match = re.search("\nmd5_data = {\n([^}]+)}", src)
+ if not match:
+ print >>sys.stderr, "Internal error!"
+ sys.exit(2)
+
+ src = src[:match.start(1)] + repl + src[match.end(1):]
+ f = open(srcfile,'w')
+ f.write(src)
+ f.close()
+
+
+if __name__=='__main__':
+ if len(sys.argv)>2 and sys.argv[1]=='--md5update':
+ update_md5(sys.argv[2:])
+ else:
+ main(sys.argv[1:])
+
+
+
+
+
251 index.html.tpl
@@ -0,0 +1,251 @@
+<html>
+ <head>
+ <title>nose: a discovery-based unittest extension</title>
+ <style>
+ body {
+ margin 0px;
+ padding: 10px 40px;
+ font: x-small Georgia,Serif;
+ font-size/* */:/**/small;
+ font-size: /**/small;
+ }
+ a:link {
+ color:#58a;
+ text-decoration:none;
+ }
+ a:visited {
+ color:#969;
+ text-decoration:none;
+ }
+ a:hover {
+ color:#c60;
+ text-decoration:underline;
+ }
+
+ #menu {
+ padding-left 1em;
+ padding-right: 1em;
+ padding-bottom: 10px;
+ margin-left: 20px;
+ min-width: 200px;
+ width: 20%%;
+ border-left: 1px solid #ddd;
+ border-bottom: 1px solid #ddd;
+ background-color: #fff;
+ float: right;
+ }
+
+ #main {
+ margin: 0px;
+ padding: 0px;
+ padding-right: 20px;
+ width: 70%%;
+ float: left;
+ }
+
+ h1 {
+ font-size: 140%%;
+ margin-top: 0;
+ }
+
+ .section h1 {
+ font-size: 120%%;
+ }
+
+ .section h2 {
+ font-size: 105%%;
+ }
+
+ pre.literal-block {
+ font: small;
+ background: #ddd;
+ }
+
+ #menu ul {
+ margin: 0 1em .25em;
+ padding: 0;
+ list-style:none;
+ }
+
+ #menu h2 {
+ font-size: 100%%;
+ color: #999;
+ margin: 0 .5em;
+ padding: 0;
+ }
+
+ #menu ul li {
+ margin: 0px;
+ padding: 0px 0px 0px 15px;
+ text-indent:-15px;
+ /* line-height:1.5em; */
+ }
+
+ #menu p, #menu ol li {
+ font-size: 90%%;
+ color:#666;
+ /* line-height:1.5em; */
+ margin: 0 1em .5em;
+ }
+
+ #menu ul li {
+ font-size: 90%%;
+ color:#666;
+ }
+
+ #menu dd {
+ margin: 0;
+ padding:0 0 .25em 15px;
+ }
+
+ #news {
+ border: 1px solid #999;
+ background-color: #eef;
+ /* wouldn't it be nice if this worked */
+ background-image: url(flake.svg);
+ padding: 4px;
+ padding-right: 8px;
+ }
+
+ #news h2 {
+ margin-top: 0px;
+ font-size: 105%%;
+ }
+
+ #news li p {
+ margin-left: 1.5em;
+ }
+
+ #news li p.first {
+ margin-left: 0;
+ font-weight: bold;
+ }
+
+ #news p {
+ margin-bottom: 0px;
+ }
+
+ </style>
+ </head>
+ <body>
+
+
+ <div id="menu">
+ <h2><a href="nose-%(version)s.tar.gz">Download</a></h2>
+ <p>Current version: %(version)s <br />(%(date)s)</p>
+
+ <h2>Install</h2>
+ <p>Current version: <br /><tt>easy_install nose==%(version)s</tt></p>
+ <p>Unstable (trunk): <br /><tt>easy_install nose==dev</tt></p>
+
+ <h2>Read</h2>
+ <ul>
+ <li>
+ <a href="http://ivory.idyll.org/articles/nose-intro.html">
+ An Extended Introduction to the nose Unit Testing Framework
+ </a>
+ <br />Titus Brown's excellent article provides a great overview of
+ nose and its uses.
+ </li>
+ <li><a href="#usage">nosetests usage</a>
+ <br />How to use the command-line test runner.
+ </li>
+ </ul>
+
+ <h2><a href="http://groups.google.com/group/nose-announce">
+ Announcement list</a></h2>
+ <p>Sign up to receive email announcements
+ of new releases</p>
+
+ <h2><a href="http://nose.python-hosting.com/">Trac</a></h2>
+ <p>Report bugs, request features, wik the wiki, browse source.</p>
+
+ <h2>Get the code</h2>
+ <p><tt>svn co http://svn.nose.python-hosting.com/trunk</tt></p>
+
+ <h2>Other links</h2>
+ <ul>
+ <li><a href="/mrl/">My blog</a></li>
+ <li>
+ <a href="http://codespeak.net/py/current/doc/test.html">py.test</a>
+ </li>
+ <li><a href="http://www.turbogears.com/testgears/">testgears</a></li>
+ <li>
+ <a href="http://peak.telecommunity.com/DevCenter/setuptools">setuptools</a>
+ </li>
+ </ul>
+ </div>
+ <div id="main">
+ <h1>nose: a discovery-based unittest extension.</h1>
+
+ <p>nose provides an alternate test discovery and running process for
+ unittest, one that is intended to mimic the behavior of py.test as much
+ as is reasonably possible without resorting to too much magic.
+ </p>
+
+ <div id="news">
+ <h2>News</h2>
+ %(news)s
+ <p>See the <a href="#changelog">changelog</a> for details.</p>
+ </div>
+
+ <h2>Install</h2>
+
+ <p>Install nose using setuptools:
+ <pre>easy_install nose</pre>
+ </p>
+
+ <p>Or, if you don't have setuptools installed, use the download link at
+ right to download the source package, and install in the normal fashion:
+ Ungzip and untar the source package, cd to the new directory, and:
+
+ <pre>python setup.py install</pre>
+ </p>
+
+ %(body)s
+
+ <h2><a name="tools"></a>nose.tools</h2>
+
+ %(tools)s
+
+ <p><b>FIXME:</b> use pudge to generate rst docs for all tools funcs</p>
+
+ <h2><a name="commands"></a>nosetests setuptools command</h2>
+
+ %(commands)s
+
+ <h2><a name="usage"></a>nosetests usage</h2>
+
+ %(usage)s
+
+ <h2>Bug reports</h2>
+
+ <p>Please report bugs and make feature
+ requests <a href="http://nose.python-hosting.com">here</a>.</p>
+
+ <h2>Hack</h2>
+
+ <p><a href="http://nose.python-hosting.com/wiki/WritingPlugins">Write
+ plugins!</a> It's easy and fun.</p>
+
+ <p>Get the code:
+ <pre>svn co http://svn.nose.python-hosting.com/trunk</pre>
+ </p>
+
+ <p><a href="mailto:jpellerin+nose@gmail.com">Patches are
+ welcome</a>. I'd suggest grabbing a copy
+ of <a href="http://svk.elixus.org/">svk</a> so that you can have
+ local version control and submit full patches against an up-to-date
+ tree easily.
+ </p>
+
+ <p>Thanks to the great folks at python hosting for providing the
+ subversion repository and trac instance.</p>
+
+ <h2><a name="changelog"></a>Changelog</h2>
+ %(changelog)s
+
+ </div>
+
+ </body>
+</html>
504 lgpl.txt
@@ -0,0 +1,504 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
+
309 nose/__init__.py
@@ -0,0 +1,309 @@
+"""nose: a discovery-based unittest extension.
+
+nose provides an alternate test discovery and running process for
+unittest, one that is intended to mimic the behavior of py.test as much
+as is reasonably possible without resorting to too much magic.
+
+Basic usage
+-----------
+
+Use the nosetests script (after installation by setuptools)::
+
+ nosetests [options] [(optional) test files or directories]
+
+You may also use nose in a test script::
+
+ import nose
+ nose.main()
+
+If you don't want the test script to exit with 0 on success and 1 on failure
+(like unittest.main), use nose.run() instead::
+
+ import nose
+ result = nose.run()
+
+`result` will be true if the test run succeeded, or false if any test failed
+or raised an uncaught exception. Lastly, you can run nose.core directly, which
+will run nose.main()::
+
+ python /path/to/nose/core.py
+
+Please see the usage message for the nosetests script for information
+about how to control which tests nose runs, which plugins are loaded,
+and the test output.
+
+Features
+--------
+
+Run as collect
+==============
+
+nose begins running tests as soon as the first test module is loaded, it
+does not wait to collect all tests before running the first.
+
+Output capture
+==============
+
+Unless called with the -s (--nocapture) switch, nose will capture stdout
+during each test run, and print the captured output only for tests that
+fail or have errors. The captured output is printed immediately
+following the error or failure output for the test. (Note that output in
+teardown methods is captured, but can't be output with failing tests,
+because teardown has not yet run at the time of the failure.)
+
+Assert introspection
+====================
+
+When run with the -d (--detailed-errors) switch, nose will try to output
+additional information about the assert expression that failed with each
+failing test. Currently, this means that names in the assert expression
+will be expanded into any values found for them in the locals or globals
+in the frame in which the expression executed.
+
+In other words if you have a test like::
+
+ def test_integers():
+ a = 2
+ assert a == 4, "assert 2 is 4"
+
+You will get output like::
+
+ File "/path/to/file.py", line XX, in test_integers:
+ assert a == 4, "assert 2 is 4"
+ AssertionError: assert 2 is 4
+ >> assert 2 == 4, "assert 2 is 4"
+
+Setuptools integration
+======================
+
+nose may be used with the setuptools_ test command. Simply specify
+nose.collector as the test suite in your setup file::
+
+ setup (
+ # ...
+ test_suite = 'nose.collector'
+ )
+
+Then to find and run tests, you can run::
+
+ python setup.py test
+
+When running under setuptools, you can configure nose settings via the
+environment variables detailed in the nosetests script usage message.
+
+Please note that when run under the setuptools test command, some plugins will
+not be available, including the builtin coverage, profiler, and missed test
+plugins.
+
+nose also includes its own setuptools command, `nosetests`, that provides
+support for all plugins and command line options, as well as configuration
+using the setup.cfg file. See nose.commands_ for more information about the
+`nosetests` command.
+
+.. _setuptools: http://peak.telecommunity.com/DevCenter/setuptools
+.. _nose.commands: #commands
+
+Writing tests
+-------------
+
+As with py.test, nose tests need not be subclasses of TestCase. Any function
+or class that matches the configured testMatch regular expression
+('(?:^|[\\b_\\.-])[Tt]est)'' by default) and lives in a module that also
+matches that expression will be run as a test. For the sake of compatibility
+with legacy unittest test cases, nose will also load tests from
+unittest.TestCase subclasses just like unittest does. Like py.test, functional
+tests will be run in the order in which they appear in the module
+file. TestCase derived tests and other test classes are run in alphabetical
+order.
+
+Fixtures
+========
+
+nose supports fixtures (setup and teardown methods) at the package,
+module, and test level. As with py.test or unittest fixtures, setup always
+runs before any test (or collection of tests for test packages and modules);
+teardown runs if setup has completed successfully, whether or not the test
+or tests pass. For more detail on fixtures at each level, see below.
+
+Test packages
+=============
+
+nose allows tests to be grouped into test packages. This allows
+package-level setup; for instance, if you need to create a test database
+or other data fixture for your tests, you may create it in package setup
+and remove it in package teardown once per test run, rather than having to
+create and tear it down once per test module or test case.
+
+To create package-level setup and teardown methods, define setup and/or
+teardown functions in the __init__.py of a test package. Setup methods may
+be named 'setup', 'setup_package', 'setUp',or 'setUpPackage'; teardown may
+be named 'teardown', 'teardown_package', 'tearDown' or 'tearDownPackage'.
+Execution of tests in a test package begins as soon as the first test
+module is loaded from the test package.
+
+Test modules
+============
+
+A test module is a python module that matches the testMatch regular
+expression. Test modules offer module-level setup and teardown; define the
+method 'setup', 'setup_module', 'setUp' or 'setUpModule' for setup,
+'teardown', 'teardown_module', or 'tearDownModule' for teardown. Execution
+of tests in a test module begins after all tests are collected.
+
+Test classes
+============
+
+A test class is a class defined in a test module that is either a subclass
+of unittest.TestCase, or matches testMatch. Test classes that don't
+descend from unittest.TestCase are run in the same way as those that do:
+methods in the class that match testMatch are discovered, and a test case
+constructed to run each with a fresh instance of the test class. Like
+unittest.TestCase subclasses, other test classes may define setUp and
+tearDown methods that will be run before and after each test method.
+
+Test functions
+==============
+
+Any function in a test module that matches testMatch will be wrapped in a
+FunctionTestCase and run as a test. The simplest possible failing test is
+therefore::
+
+ def test():
+ assert False
+
+And the simplest passing test::
+
+ def test():
+ pass
+
+Test functions may define setup and/or teardown attributes, which will be
+run before and after the test function, respectively. A convenient way to
+do this, especially when several test functions in the same module need
+the same setup, is to use the provided with_setup decorator::
+
+ def setup_func():
+ # ...
+
+ def teardown_func():
+ # ...
+
+ @with_setup(setup_func,teardown_func)
+ def test():
+ # ...
+
+For python 2.3, add the attributes by calling the decorator function like
+so::
+
+ def test():
+ # ...
+ test = with_setup(setup_func,teardown_func)(test)
+
+or by direct assignment::
+
+ test.setup = setup_func
+ test.teardown = teardown_func
+
+Test generators
+===============
+
+nose supports test functions and methods that are generators. A simple
+example from nose's selftest suite is probably the best explanation::
+
+ def test_evens():
+ for i in range(0, 5):
+ yield check_even, i, i*3
+
+ def check_even(n, nn):
+ assert n % 2 == 0 or nn % 2 == 0
+
+This will result in 4 tests. nose will iterate the generator, creating a
+function test case wrapper for each tuple it yields. As in the example, test
+generators must yield tuples, the first element of which must be a callable
+and the remaining elements the arguments to be passed to the callable.
+
+Setup and teardown functions may be used with test generators. The setup and
+teardown attributes must be attached to the generator function::
+
+ @with_setup(setup_func, teardown_func)
+ def test_generator():
+ ...
+ yield func, arg, arg ...
+
+The setup and teardown functions will be executed for each test that the
+generator returns.
+
+For generator methods, the setUp and tearDown methods of the class (if any)
+will be run before and after each generated test case.
+
+Please note that method generators `are not` supported in unittest.TestCase
+subclasses.
+
+About the name
+--------------
+
+* nose is the least silly short synonym for discover in the dictionary.com
+ thesaurus that does not contain the word 'spy'.
+* Pythons have noses
+* The nose knows where to find your tests
+* Nose Obviates Suite Employment
+
+Contact the author
+------------------
+
+To report bugs, ask questions, or request features, please use the trac
+instance provided by the great folks at python hosting, here:
+http://nose.python-hosting.com. Or, email the author at
+jpellerin+nose at gmail dot com. Patches are welcome!
+
+Similar test runners
+--------------------
+
+nose was inspired mainly by py.test_, which is a great test runner, but
+formerly was not all that easy to install, and is not based on unittest.
+
+Test suites written for use with nose should work equally well with py.test,
+and vice versa, except for the differences in output capture and command line
+arguments for the respective tools.
+
+.. _py.test: http://codespeak.net/py/current/doc/test.html
+
+License and copyright
+---------------------
+
+nose is copyright Jason Pellerin 2005-2006
+
+This program is free software; you can redistribute it and/or modify it
+under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation; either version 2 of the License, or (at your
+option) any later version.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program; if not, write to the Free Software Foundation,
+Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+"""
+
+from nose.core import TestCollector, collector, configure, main, run, \
+ run_exit, runmodule
+from nose.exc import SkipTest, DeprecatedTest
+from nose.loader import TestLoader
+from nose.suite import LazySuite
+from nose.result import TextTestResult
+from nose.tools import with_setup # backwards compatibility
+from nose.util import file_like, split_test_name, test_address
+
+__author__ = 'Jason Pellerin'
+__versioninfo__ = (0, 10, '0a1')
+__version__ = '.'.join(map(str, __versioninfo__))
+
+__all__ = [
+ 'TextTestResult', 'LazySuite',
+ 'SkipTest', 'DeprecatedTest',
+ 'TestCollector', 'TestLoader',
+ 'collector', 'configure', 'main', 'run', 'run_exit', 'runmodule',
+ 'with_setup', 'file_like', 'split_test_name', 'test_address'
+ ]
147 nose/case.py
@@ -0,0 +1,147 @@
+"""nose unittest.TestCase subclasses. It is not necessary to subclass these
+classes when writing tests; they are used internally by nose.loader.TestLoader
+to create test cases from test functions and methods in test classes.
+"""
+import logging
+import unittest
+from nose.util import try_run
+
+log = logging.getLogger(__name__)
+
+class FunctionTestCase(unittest.TestCase):
+ """TestCase wrapper for functional tests.
+
+ Don't use this class directly; it is used internally in nose to
+ create test cases for functional tests.
+
+ This class is very similar to unittest.FunctionTestCase, with a few
+ extensions:
+ * The test descriptions are disambiguated by including the full
+ module path when a test with a similar name has been seen in
+ the test run.
+ * It allows setup and teardown functions to be defined as attributes
+ of the test function. A convenient way to set this up is via the
+ provided with_setup decorator:
+
+ def setup_func():
+ # ...
+
+ def teardown_func():
+ # ...
+
+ @with_setup(setup_func, teardown_func)
+ def test_something():
+ # ...
+
+ """
+ _seen = {}
+
+ def __init__(self, testFunc, setUp=None, tearDown=None, description=None,
+ fromDirectory=None):
+ self.testFunc = testFunc
+ self.setUpFunc = setUp
+ self.tearDownFunc = tearDown
+ self.description = description
+ self.fromDirectory = fromDirectory
+ unittest.TestCase.__init__(self)
+
+ def id(self):
+ return str(self)
+
+ def runTest(self):
+ self.testFunc()
+
+ def setUp(self):
+ """Run any setup function attached to the test function
+ """
+ if self.setUpFunc:
+ self.setUpFunc()
+ else:
+ names = ('setup', 'setUp', 'setUpFunc')
+ try_run(self.testFunc, names)
+
+ def tearDown(self):
+ """Run any teardown function attached to the test function
+ """
+ if self.tearDownFunc:
+ self.tearDownFunc()
+ else:
+ names = ('teardown', 'tearDown', 'tearDownFunc')
+ try_run(self.testFunc, names)
+
+ def __str__(self):
+ if hasattr(self.testFunc, 'compat_func_name'):
+ name = self.testFunc.compat_func_name
+ else:
+ name = self.testFunc.__name__
+ name = "%s.%s" % (self.testFunc.__module__, name)
+
+ if self._seen.has_key(name) and self.fromDirectory is not None:
+ # already seen this exact test name; put the
+ # module dir in front to disambiguate the tests
+ name = "%s: %s" % (self.fromDirectory, name)
+ self._seen[name] = True
+ return name
+ __repr__ = __str__
+
+ def shortDescription(self):
+ pass # FIXME
+
+
+class MethodTestCase(unittest.TestCase):
+ """Test case that wraps one method in a test class.
+ """
+ def __init__(self, cls, method, method_desc=None, *arg):
+ self.cls = cls
+ self.method = method
+ self.method_desc = method_desc
+ self.testInstance = self.cls()
+ self.testCase = getattr(self.testInstance, method)
+ self.arg = arg
+ log.debug('Test case: %s%s', self.testCase, self.arg)
+ unittest.TestCase.__init__(self)
+
+ def __str__(self):
+ return self.id()
+
+ def desc(self):
+ if self.method_desc is not None:
+ desc = self.method_desc
+ else: