Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MERGE trunk r10:r196 into 0.10-dev branch: some tests now fail

  • Loading branch information...
commit 984bf51c327831a5c5a6807523be03ae56d8482a 1 parent ccb4cd7
@jpellerin jpellerin authored
Showing with 9,024 additions and 333 deletions.
  1. +48 −3 CHANGELOG
  2. +2 −1  MANIFEST.in
  3. +12 −15 NEWS
  4. +1 −1  README.txt
  5. +34 −12 index.html.tpl
  6. +122 −34 nose/__init__.py
  7. +0 −1  nose/commands.py
  8. +22 −3 nose/core.py
  9. +2 −0  nose/importer.py
  10. +2 −0  nose/loader.py
  11. +43 −37 nose/plugins/__init__.py
  12. +26 −5 nose/plugins/attrib.py
  13. +10 −6 nose/plugins/base.py
  14. +1 −0  nose/plugins/cover.py
  15. +36 −3 nose/plugins/doctests.py
  16. +25 −5 nose/plugins/prof.py
  17. +0 −88 nose/proxy.py
  18. +4 −1 nose/selector.py
  19. +4 −4 nose/suite.py
  20. +18 −8 nose/tools.py
  21. +247 −0 nosetests.1
  22. +3 −3 scripts/mkindex.py
  23. +14 −5 scripts/mkrelease.py
  24. +251 −65 scripts/mkwiki.py
  25. +125 −0 scripts/rst2wiki.py
  26. +3 −0  setup.cfg
  27. +23 −16 setup.py
  28. +115 −0 tickets.csv
  29. +7,578 −0 tickets.rss
  30. +12 −0 unit_tests/support/doctest/err_doctests.py
  31. +9 −0 unit_tests/support/doctest/no_doctests.py
  32. +19 −0 unit_tests/support/issue006/tests.py
  33. +3 −0  unit_tests/test_config.py
  34. +46 −0 unit_tests/test_doctest_error_handling.py
  35. +31 −0 unit_tests/test_issue_006.py
  36. +41 −5 unit_tests/test_plugins.py
  37. +59 −0 unit_tests/test_tools.py
  38. +27 −12 unit_tests/test_twisted.py
  39. +6 −0 unit_tests/test_twisted_testcase.py
View
51 CHANGELOG
@@ -1,14 +1,59 @@
+0.9.3
+
+- Added support for user configuration files. Thanks to Antoine Pitrou for the
+ patch.
+- Fixed bug that caused profiler plugin to leak 0-byte temp files. Thanks to
+ Antoine Pitrou for the patch.
+- Made usage of temp files in profiler plugin more sensible. Thanks to Michael
+ Sclenker for the bug report.
+- Fixed bug that stopped loading of twisted TestCase tests. Thanks to Kumar
+ McMillan for the bug report.
+- Corrected man page location. Thanks to luke macken for the bug report and
+ patch.
+- Added with_setup to nose.tools.__all__. Thanks to Allen Bierbaum for the bug
+ report.
+- Altered plugin loading so that builtin plugins can be loaded without
+ setuptools. Thanks to Allen Bierbaum for the suggestion.
+- Fixed a bug in the doctests plugin that caused an error when multiple
+ exclude arguments were specified. Thanks to mbeachy for the bug report and
+ patch.
+
0.9.2
+- 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.
- 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.
+- Added monkeypatch to doctests that keeps doctest from stepping on coverage
+ when the two plugins are used together. Thanks to David Avraamides for the
+ bug report.
+- Added isolation plugin. Use this plugin to automatically restore sys.modules
+ after each test module or package. Thanks to Michal Kwiatkowski for the
+ feature request.
+- Fixed bug where -vvvv turned off verbose logging instead of making it even
+ more verbose. Thanks to Ian Bicking for the bug report.
+- Fixed bug where assert inspection would fail when the trailing """ of a
+ docstring was one of the inspected lines. Thanks to cito at online dot de
+ for the bug report.
+- Updated attrib plugin to allow selection of test methods by attributes of
+ the test case class. Thanks to Jason Hildebrand for the patch.
+- Improved compatibility with python 2.2. Thanks to Chad Whitacre for the
+ patch.
+- Fixed bug in handling of options from setup.cfg. Thanks to Kumar McMillan for
+ the patch.
+- Fixed bug in generator methods, where a generator method using an inline
+ funciton would result in an AttributeError. Thanks to Antoine Pitrou for the
+ bug report.
+- Updated coverage plugin to ignore lines tagged with #pragma: no cover,
+ matching the behavior of coverage.py on the command line. Thanks to Bill
+ Zingler for the bug report.
+- Added a man page for nosetests. Thanks to Gustavo Noronha Silva for the
+ request and providing an example.
0.9.1
View
3  MANIFEST.in
@@ -7,4 +7,5 @@ include unit_tests/*/*/*/*/*.py
include CHANGELOG
include NEWS
include README.txt
-include lgpl.txt
+include lgpl.txt
+include nosetests.1
View
27 NEWS
@@ -1,19 +1,16 @@
-New in version 0.9.1
+New in version 0.9.3
--------------------
-Nose 0.9.1 is mainly a bug-fix release, but it does contain a few new
-features.
+nose 0.9.3 is mainly a bugfix release. The one new feature is support for user
+configuration files: now you can put your frequently used configuration
+options in .noserc or nose.cfg files, rather than typing them over and over
+and over again. Many thanks to Antoine Pitrou for that patch, and thanks to
+all of the other users who reported bugs and submitted patches and
+suggestions.
-* 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.
+Barring catastrophic bugs, this will be the last release of nose in the 0.9
+series. An alpha release of nose 0.10 should be forthcoming within a few
+weeks. Details about the new features and architecture changes in nose 0.10
+may be found here_.
-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.
-
+.. _here: http://code.google.com/p/python-nose/wiki/VersionZeroTen
View
2  README.txt
@@ -30,7 +30,7 @@ understand and hack. Other goals include:
interact with tests more easily.
This involves some major changes to how nose loads and runs tests.
-
+
Changes to loading
==================
View
46 index.html.tpl
@@ -125,6 +125,11 @@
margin-bottom: 0px;
}
+ p.note {
+ background: #fed;
+ border: 1px solid black;
+ padding: 6px;
+ }
</style>
</head>
<body>
@@ -157,11 +162,11 @@
<p>Sign up to receive email announcements
of new releases</p>
- <h2><a href="http://nose.python-hosting.com/">Trac</a></h2>
+ <h2><a href="http://code.google.com/p/python-nose/">Tracker</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>
+ <p><tt>svn co http://python-nose.googlecode.com/svn/trunk/ nose</tt></p>
<h2>Other links</h2>
<ul>
@@ -191,6 +196,11 @@
<h2>Install</h2>
+ <p class="note">
+ On most UNIX-like systems, you'll probably need to run these commands
+ as root or using sudo.
+ </p>
+
<p>Install nose using setuptools:
<pre>easy_install nose</pre>
</p>
@@ -201,14 +211,27 @@
<pre>python setup.py install</pre>
</p>
-
- %(body)s
- <h2><a name="tools"></a>nose.tools</h2>
+ <p>If you have an older version of setuptools installed, you may see an
+ error like this:
+
+ <blockquote>
+ <tt>The required version of setuptools (>=0.6c5) is not available, and
+ can't be installed while this script is running. Please install
+ a more recent version first.</tt>
+ </blockquote>
+
+ In that case, you'll need to update your setuptools install first,
+ either by running:
+
+ <pre>easy_install -U setuptools</pre>
- %(tools)s
+ or:
- <p><b>FIXME:</b> use pudge to generate rst docs for all tools funcs</p>
+ <pre>python ez_setup.py</pre>
+ </p>
+
+ %(body)s
<h2><a name="commands"></a>nosetests setuptools command</h2>
@@ -221,15 +244,15 @@
<h2>Bug reports</h2>
<p>Please report bugs and make feature
- requests <a href="http://nose.python-hosting.com">here</a>.</p>
+ requests <a href="http://code.google.com/p/python-nose/">here</a>.</p>
<h2>Hack</h2>
- <p><a href="http://nose.python-hosting.com/wiki/WritingPlugins">Write
+ <p><a href="http://code.google.com/p/python-nose/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>
+ <pre>svn checkout http://python-nose.googlecode.com/svn/trunk/ nose</pre>
</p>
<p><a href="mailto:jpellerin+nose@gmail.com">Patches are
@@ -239,8 +262,7 @@
tree easily.
</p>
- <p>Thanks to the great folks at python hosting for providing the
- subversion repository and trac instance.</p>
+ <p>Thanks to Google for providing the Google code hosting service.</p>
<h2><a name="changelog"></a>Changelog</h2>
%(changelog)s
View
156 nose/__init__.py
@@ -11,7 +11,17 @@
nosetests [options] [(optional) test files or directories]
-You may also use nose in a test script::
+In addition to passing command-line options, you may also put configuration
+options in a .noserc or nose.cfg file in your home directory. These are
+standard .ini-style config files. Put your nosetests configuration in a
+[nosetests] section, with the -- prefix removed::
+
+ [nosetests]
+ verbosity=3
+ with-doctest
+
+There are several other ways to use the nose test runner besides the
+`nosetests` script. You may use nose in a test script::
import nose
nose.main()
@@ -27,19 +37,48 @@
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
-==============
+Writing tests is easier
+=======================
+
+nose collects tests from `unittest.TestCase` subclasses, of course. But you can
+also write simple test functions, and test classes that are not subclasses of
+`unittest.TestCase`. nose also supplies a number of helpful functions for
+writing timed tests, testing for exceptions, and other common use cases. See
+`Writing tests`_ and `Testing tools`_ for more.
-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.
+Running tests is easier
+=======================
+
+nose collects tests automatically, as long as you follow some simple
+guidelines for organizing your library and test code. There's no need to
+manually collect test cases into test suites. Running tests is also more
+responsive, since nose begins running tests as soon as the first test module
+is loaded. See `Finding and running tests`_ for more.
+
+Setting up your test environment is easier
+==========================================
+
+nose supports fixtures at the package, module, and test case level, so
+expensive initialization can be done as infrequently as possible. See
+Fixtures_ for more.
+
+Doing what you want to do is easier
+===================================
+
+nose has plugin hooks for loading, running, watching and reporting on tests
+and test runs. If you don't like the default collection scheme, or it doesn't
+suit the layout of your project, or you need reports in a format different
+from the unittest standard, or you need to collect some additional information
+about tests (like code coverage or profiling data), you can write a plugin to
+do so. See `Writing plugins`_ for more.
Output capture
==============
@@ -72,6 +111,9 @@ def test_integers():
assert a == 4, "assert 2 is 4"
AssertionError: assert 2 is 4
>> assert 2 == 4, "assert 2 is 4"
+
+Please note that dotted names are not expanded, and callables are not called
+in the expansion.
Setuptools integration
======================
@@ -102,19 +144,20 @@ def test_integers():
.. _setuptools: http://peak.telecommunity.com/DevCenter/setuptools
.. _nose.commands: #commands
+.. _Writing plugins: http://code.google.com/p/python-nose/wiki/WritingPlugins
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.
+As with py.test, nose tests need not be subclasses of
+`unittest.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
========
@@ -135,9 +178,9 @@ def test_integers():
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'.
+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.
@@ -146,26 +189,26 @@ def test_integers():
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
+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:
+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
+`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
+`FunctionTestCase` and run as a test. The simplest possible failing test is
therefore::
def test():
@@ -187,7 +230,7 @@ def setup_func():
def teardown_func():
# ...
- @with_setup(setup_func,teardown_func)
+ @with_setup(setup_func, teardown_func)
def test():
# ...
@@ -196,13 +239,17 @@ def test():
def test():
# ...
- test = with_setup(setup_func,teardown_func)(test)
+ test = with_setup(setup_func, teardown_func)(test)
or by direct assignment::
test.setup = setup_func
test.teardown = teardown_func
+Please note that `with_setup` is useful *only* for test functions, not for
+test methods in TestCase subclasses or other test classes. For those cases,
+define `setUp` and `tearDown` methods in the class.
+
Test generators
===============
@@ -235,9 +282,49 @@ def test_generator():
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
+Please note that method generators *are not* supported in `unittest.TestCase`
subclasses.
-
+
+Finding and running tests
+-------------------------
+
+nose, by default, follows a few simple rules for test discovery.
+
+* If it looks like a test, it's a test. Names of directories, modules,
+ classes and functions are compared against the testMatch regular
+ expression, and those that match are considered tests. Any class that is a
+ `unittest.TestCase` subclass is also collected, so long as it is inside of a
+ module that looks like a test.
+
+* Directories that don't look like tests and aren't packages are not
+ inspected.
+
+* Packages are always inspected, but they are only collected if they look
+ like tests. This means that you can include your tests inside of your
+ packages (somepackage/tests) and nose will collect the tests without
+ running package code inappropriately.
+
+* When a project appears to have library and test code organized into
+ separate directories, library directories are examined first.
+
+* When nose imports a module, it adds that module's directory to sys.path;
+ when the module is inside of a package, like package.module, it will be
+ loaded as package.module and the directory of *package* will be added to
+ sys.path.
+
+Be aware that plugins and command line options can change any of those rules.
+
+Testing tools
+-------------
+
+The nose.tools module provides a number of testing aids that you may
+find useful, including decorators for restricting test execution time
+and testing for exceptions, and all of the same assertX methods found
+in `unittest.TestCase` (only spelled in pep08 fashion, so assert_equal
+rather than assertEqual). See `nose.tools`_ for a complete list.
+
+.. _nose.tools: http://code.google.com/p/python-nose/wiki/TestingTools
+
About the name
--------------
@@ -250,10 +337,11 @@ def test_generator():
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!
+You can email me at jpellerin+nose at gmail dot com.
+
+To report bugs, ask questions, or request features, please use the *issues*
+tab at the Google code site: http://code.google.com/p/python-nose/issues/list.
+Patches are welcome!
Similar test runners
--------------------
@@ -270,7 +358,7 @@ def test_generator():
License and copyright
---------------------
-nose is copyright Jason Pellerin 2005-2006
+nose is copyright Jason Pellerin 2005-2007
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
View
1  nose/commands.py
@@ -102,4 +102,3 @@ def run(self):
self.__config.cfgToArg(option_name, value,
lambda o: o.replace('_', '-')))
TestProgram(argv=argv, config=self.__config)
-
View
25 nose/core.py
@@ -1,5 +1,7 @@
"""Implements nose test program and collector.
"""
+from __future__ import generators
+
import logging
import os
import re
@@ -7,6 +9,8 @@
import types
import unittest
from warnings import warn
+from warnings import warn
+import ConfigParser
from nose.config import Config, all_config_files
from nose.importer import add_path
@@ -17,7 +21,7 @@
log = logging.getLogger('nose.core')
-
+compat_24 = sys.version_info >= (2, 4)
class TestCollector:
"""Main nose test collector.
@@ -107,7 +111,7 @@ def run(self, test):
class TestProgram(unittest.TestProgram):
- """usage: %prog [options] [names]
+ r"""usage: %prog [options] [names]
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
@@ -117,7 +121,7 @@ class TestProgram(unittest.TestProgram):
directories and packages found in its working directory (which
defaults to the current working directory). Any python source file,
directory or package that matches the testMatch regular expression
- (by default: (?:^|[\\b_\\.-])[Tt]est) will be collected as a test (or
+ (by default: (?:^|[\b_\.-])[Tt]est) will be collected as a test (or
source for collection of tests). In addition, all other packages
found in the working directory are examined for python source files
or directories that match testMatch. Package discovery descends all
@@ -174,6 +178,21 @@ class TestProgram(unittest.TestProgram):
the additional features (error classes, and plugin-supplied
features such as output capture and assert introspection) detailed
in the options below.
+
+ Configuration
+ -------------
+
+ In addition to passing command-line options, you may also put configuration
+ options in a .noserc or nose.cfg file in your home directory. These are
+ standard .ini-style config files. Put your nosetests configuration in a
+ [nosetests] section, with the -- prefix removed:
+
+ [nosetests]
+ verbosity=3
+ with-doctest
+
+ All configuration files that are found will be loaded and their options
+ combined.
"""
verbosity = 1
View
2  nose/importer.py
@@ -4,6 +4,8 @@
same names, which means that the first loaded would mask the rest when using
the builtin importer.
"""
+from __future__ import generators
+
import logging
import os
import sys
View
2  nose/loader.py
@@ -1,3 +1,5 @@
+from __future__ import generators
+
import logging
import os
import sys
View
80 nose/plugins/__init__.py
@@ -1,17 +1,17 @@
-"""nose plugins
-
-nose supports setuptools entry point plugins for test collection,
-selection, observation and reporting.
-
-Writing Plugins
+"""Writing Plugins
---------------
-Plugin classes should subclass nose.plugins.Plugin.
+nose supports setuptools_ entry point plugins for test collection,
+selection, observation and reporting. There are two basic rules for plugins:
-Plugins may implement any of the methods described in the class
-PluginInterface in nose.plugins.base. Please note that this class is for
-documentary purposes only; plugins may not subclass PluginInterface.
+ * Plugin classes should subclass `nose.plugins.Plugin`_.
+ * Plugins may implement any of the methods described in the class
+ PluginInterface in nose.plugins.base. Please note that this class is for
+ documentary purposes only; plugins may not subclass PluginInterface.
+.. _setuptools: http://peak.telecommunity.com/DevCenter/setuptools
+.. _nose.plugins.Plugin: http://python-nose.googlecode.com/svn/trunk/nose/plugins/base.py
+
Registering
===========
@@ -35,20 +35,20 @@
Defining options
================
-All plugins must implement the methods `add_options(self, parser, env)`
-and `configure(self, options, conf)`. Subclasses of nose.plugins.Plugin
+All plugins must implement the methods ``add_options(self, parser, env)``
+and ``configure(self, options, conf)``. Subclasses of nose.plugins.Plugin
that want the standard options should call the superclass methods.
nose uses optparse.OptionParser from the standard library to parse
-arguments. A plugin's add_options() method receives a parser
+arguments. A plugin's ``add_options()`` method receives a parser
instance. It's good form for a plugin to use that instance only to add
additional arguments that take only long arguments (--like-this). Most
of nose's built-in arguments get their default value from an environment
variable. This is a good practice because it allows options to be
utilized when run through some other means than the nosetests script.
-A plugin's configure() receives the parsed OptionParser options object,
-as well as the current config object. Plugins should configure their
+A plugin's ``configure()`` method receives the parsed ``OptionParser`` options
+object, as well as the current config object. Plugins should configure their
behavior based on the user-selected settings, and may raise exceptions
if the configured behavior is nonsensical.
@@ -56,55 +56,63 @@
=======
nose uses the logging classes from the standard library. To enable users
-to view debug messages easily, plugins should use logging.getLogger() to
-acquire a logger in the 'nose.plugins' namespace.
+to view debug messages easily, plugins should use ``logging.getLogger()`` to
+acquire a logger in the ``nose.plugins`` namespace.
Recipes
=======
* Writing a plugin that monitors or controls test result output
- Implement any or all of addError, addFailure, etc., to monitor test
+ Implement any or all of ``addError``, ``addFailure``, etc., to monitor test
results. If you also want to monitor output, implement
- setOutputStream and keep a reference to the output stream. If you
- want to prevent the builtin TextTestResult output, implement
- setOutputSteam and return a dummy stream and send your desired output
- to the real stream.
+ ``setOutputStream`` and keep a reference to the output stream. If you
+ want to prevent the builtin ``TextTestResult`` output, implement
+ ``setOutputSteam`` and *return a dummy stream*. The default output will go
+ to the dummy stream, while you send your desired output to the real stream.
- Example: examples/html_plugin/htmlplug.py
+ Example: `examples/html_plugin/htmlplug.py`_
* Writing a plugin that loads tests from files other than python modules
- Implement wantFile and loadTestsFromPath. In wantFile, return True
- for files that you want to examine for tests. In loadTestsFromPath,
+ Implement ``wantFile`` and ``loadTestsFromFile``. In ``wantFile``, return
+ True for files that you want to examine for tests. In ``loadTestsFromFile``,
for those files, return a TestSuite or other iterable containing
- TestCases. loadTestsFromPath may also be a generator.
+ TestCases. ``loadTestsFromFile`` may also be a generator.
- Example: nose.plugins.doctests
+ Example: `nose.plugins.doctests`_
* Writing a plugin that prints a report
Implement begin if you need to perform setup before testing
- begins. Implement report and output your report to the provided stream.
+ begins. Implement ``report`` and output your report to the provided stream.
- Examples: nose.plugins.cover, nose.plugins.profile, nose.plugins.missed
+ Examples: `nose.plugins.cover`_, `nose.plugins.profile`_
* Writing a plugin that selects or rejects tests
- Implement any or all want* methods. Return False to reject the test
+ Implement any or all ``want*`` methods. Return False to reject the test
candidate, True to accept it -- which means that the test candidate
will pass through the rest of the system, so you must be prepared to
load tests from it if tests can't be loaded by the core loader or
another plugin -- and None if you don't care.
- Examples: nose.plugins.attrib, nose.plugins.doctests
-
+ Examples: `nose.plugins.attrib`_, `nose.plugins.doctests`_
+
Examples
========
-See nose.plugins.attrib, nose.plugins.cover, nose.plugins.doctests and
-nose.plugins.profile for examples. Further examples may be found the
-examples directory in the nose source distribution.
+See `nose.plugins.attrib`_, `nose.plugins.cover`_, `nose.plugins.doctests`_
+and `nose.plugins.profile`_ for examples. Further examples may be found the
+examples_ directory in the nose source distribution.
+
+.. _examples/html_plugin/htmlplug.py: http://python-nose.googlecode.com/svn/trunk/examples/html_plugin/htmlplug.py
+.. _examples: http://python-nose.googlecode.com/svn/trunk/examples
+.. _nose.plugins.attrib: http://python-nose.googlecode.com/svn/trunk/nose/plugins/attrib.py
+.. _nose.plugins.cover: http://python-nose.googlecode.com/svn/trunk/nose/plugins/cover.py
+.. _nose.plugins.doctests: http://python-nose.googlecode.com/svn/trunk/nose/plugins/doctests.py
+.. _nose.plugins.profile: http://python-nose.googlecode.com/svn/trunk/nose/plugins/profile.py
+
Testing Plugins
===============
@@ -153,5 +161,3 @@
from nose.plugins.manager import *
from nose.plugins.plugintest import PluginTester
-
-
View
31 nose/plugins/attrib.py
@@ -26,6 +26,7 @@
* nosetests -A "(priority > 5) and not slow"
"""
+import logging
import os
import re
import sys
@@ -34,6 +35,7 @@
from nose.plugins.base import Plugin
from nose.util import tolist
+log = logging.getLogger('nose.plugins.attrib')
compat_24 = sys.version_info >= (2, 4)
class ContextHelper:
@@ -44,6 +46,29 @@ def __init__(self, obj):
def __getitem__(self, name):
return self.obj.get(name, False)
+
+class AttributeGetter:
+ """Helper for looking up attributes
+
+ First we check the method, and if the attribute is not present,
+ we check the method's class.
+ """
+ missing = object()
+
+ def __init__(self, cls, method):
+ self.cls = cls
+ self.method = method
+
+ def get(self, name, default=None):
+ log.debug('Get %s from %s.%s', name, self.cls, self.method)
+ val = self.method.__dict__.get(name, self.missing)
+ if val is self.missing:
+ log.debug('No attribute %s in method, getting from class',
+ name)
+ val = getattr(self.cls, name, default)
+ log.debug('Class attribute %s value: %s', name, val)
+ return val
+
class AttributeSelector(Plugin):
"""Selects test cases to be run based on their attributes.
"""
@@ -182,9 +207,5 @@ def wantFunction(self, function):
return self.validateAttrib(function.__dict__)
def wantMethod(self, method):
- # start with class attributes...
- cls = method.im_class
- attribs = cls.__dict__.copy()
- # method attributes override class attributes
- attribs.update(method.__dict__)
+ attribs = AttributeGetter(method.im_class, method)
return self.validateAttrib(attribs)
View
16 nose/plugins/base.py
@@ -109,16 +109,16 @@ class IPluginInterface(object):
`enabled` and `name`.
Plugins may implement any or all of the methods documented
- below. Please note that they `must not` subclass PluginInterface;
+ below. Please note that they *must not* subclass PluginInterface;
PluginInterface is a only description of the plugin API.
When plugins are called, the first plugin that implements a method
and returns a non-None value wins, and plugin processing ends. The
- only exceptions to are `loadTestsFromModule`, `loadTestsFromName`,
+ exceptions to this are `loadTestsFromModule`, `loadTestsFromName`,
and `loadTestsFromPath`, which allow multiple plugins to load and
return tests.
- In general, plugin methods correspond directly to the methods of
+ In general, plugin methods correspond directly to methods of
nose.selector.Selector, nose.loader.TestLoader and
nose.result.TextTestResult are called by those methods when they are
called. In some cases, the plugin hook doesn't neatly match the
@@ -131,19 +131,21 @@ class IPluginInterface(object):
Selecting and loading tests
===========================
- To alter test selection behavior, implement any necessary want*
+ To alter test selection behavior, implement any necessary `want*`
methods as outlined below. Keep in mind, though, that when your
- plugin returns True from a want* method, you will send the requested
+ plugin returns True from a `want*` method, you will send the requested
object through the normal test collection process. If the object
represents something from which normal tests can't be collected, you
must also implement a loader method to load the tests.
Examples:
+
* The builtin doctests plugin, for python 2.4 only, implements
`wantFile` to enable loading of doctests from files that are not
python modules. It also implements `loadTestsFromModule` to load
doctests from python modules, and `loadTestsFromPath` to load tests
from the non-module files selected by `wantFile`.
+
* The builtin attrib plugin implements `wantFunction` and
`wantMethod` so that it can reject tests that don't match the
specified attributes.
@@ -157,9 +159,11 @@ class IPluginInterface(object):
correspond to TextTestResult methods.
Examples:
+
* The builtin cover plugin implements `begin` and `report` to
capture and report code coverage metrics for all or selected modules
loaded during testing.
+
* The builtin profile plugin implements `begin`, `prepareTest` and
`report` to record and output profiling information. In this
case, the plugin's `prepareTest` method constructs a function that
@@ -632,7 +636,7 @@ def report(self, stream):
def setOutputStream(self, stream):
"""Called before test output begins. To direct test output to a
new stream, return a stream object, which must implement a
- write(msg) method. If you only want to note the stream, not
+ `write(msg)` method. If you only want to note the stream, not
capture or redirect it, then return None.
Parameters:
View
1  nose/plugins/cover.py
@@ -85,6 +85,7 @@ def begin(self):
if self.coverErase:
log.debug("Clearing previously collected coverage statistics")
coverage.erase()
+ coverage.exclude('#pragma[: ]+[nN][oO] [cC][oO][vV][eE][rR]')
coverage.start()
def report(self, stream):
View
39 nose/plugins/doctests.py
@@ -14,6 +14,8 @@
.. _doctest: http://docs.python.org/lib/module-doctest.html
"""
+from __future__ import generators
+
import doctest
import logging
import os
@@ -24,6 +26,35 @@
log = logging.getLogger(__name__)
+#
+# Doctest and coverage don't get along, so we need to create
+# a monkeypatch that will replace the part of doctest that
+# interferes with coverage reports.
+#
+# The monkeypatch is based on this zope patch:
+# http://svn.zope.org/Zope3/trunk/src/zope/testing/doctest.py?rev=28679&r1=28703&r2=28705
+#
+try:
+ _orp = doctest._OutputRedirectingPdb
+
+ class NoseOutputRedirectingPdb(_orp):
+ def __init__(self, out):
+ self.__debugger_used = False
+ _orp.__init__(self, out)
+
+ def set_trace(self):
+ self.__debugger_used = True
+ _orp.set_trace(self)
+
+ def set_continue(self):
+ # Calling set_continue unconditionally would break unit test
+ # coverage reporting, as Bdb.set_continue calls sys.settrace(None).
+ if self.__debugger_used:
+ _orp.set_continue(self)
+ doctest._OutputRedirectingPdb = NoseOutputRedirectingPdb
+except AttributeError:
+ # Python 2.3: no support
+ pass
class Doctest(Plugin):
"""
@@ -132,8 +163,10 @@ def wantFile(self, file):
# also want files that match my extension
if (self.extension
and anyp(file.endswith, self.extension)
- and (self.conf.exclude is None
- or not self.conf.exclude.search(file))):
+ and (not self.conf.exclude
+ or not filter(None,
+ [exc.search(file)
+ for exc in self.conf.exclude]))):
return True
return None
@@ -157,7 +190,7 @@ def address(self):
return test_address(self._nose_obj)
return test_address(resolve_name(self._dt_test.name))
- # Annoyingly, doctests loaded via find(obj) omit the module name
+ # doctests loaded via find(obj) omit the module name
# so we need to override id, __repr__ and shortDescription
# bonus: this will squash a 2.3 vs 2.4 incompatiblity
def id(self):
View
30 nose/plugins/prof.py
@@ -21,6 +21,8 @@ class Profile(Plugin):
"""
Use this plugin to run tests using the hotshot profiler.
"""
+ pfile = None
+ clean_stats_file = False
def options(self, parser, env=os.environ):
Plugin.options(self, parser, env)
parser.add_option('--profile-sort',action='store',dest='profile_sort',
@@ -38,6 +40,7 @@ def options(self, parser, env=os.environ):
"pstats.Stats for details")
def begin(self):
+ self._create_pfile()
self.prof = hotshot.Profile(self.pfile)
def configure(self, options, conf):
@@ -47,18 +50,18 @@ def configure(self, options, conf):
if options.profile_stats_file:
self.pfile = options.profile_stats_file
+ self.clean_stats_file = False
else:
- fileno, filename = tempfile.mkstemp()
- # close the open handle immediately, hotshot needs to open
- # the file itself
- os.close(fileno)
- self.pfile = filename
+ self.pfile = None
+ self.clean_stats_file = True
+ self.fileno = None
self.sort = options.profile_sort
self.restrict = tolist(options.profile_restrict)
def prepareTest(self, test):
log.debug('preparing test %s' % test)
def run_and_profile(result, prof=self.prof, test=test):
+ self._create_pfile()
prof.runcall(test, result)
return run_and_profile
@@ -77,3 +80,20 @@ def report(self, stream):
stats.print_stats()
finally:
sys.stdout = tmp
+
+ def finalize(self, result):
+ if self.clean_stats_file:
+ if self.fileno:
+ try:
+ os.close(self.fileno)
+ except OSError:
+ pass
+ try:
+ os.unlink(self.pfile)
+ except OSError:
+ pass
+ return None
+
+ def _create_pfile(self):
+ if not self.pfile:
+ self.fileno, self.pfile = tempfile.mkstemp()
View
88 nose/proxy.py
@@ -161,91 +161,3 @@ def set_shouldStop(self, shouldStop):
shouldStop = property(get_shouldStop, set_shouldStop, None,
"""Should the test run stop?""")
-
-# old
-
-# class ResultProxy(Result):
-# """Result proxy. Performs nose-specific result operations, such as
-# handling output capture, inspecting assertions and calling plugins,
-# then delegates to another result handler.
-# """
-# def __init__(self, result):
-# self.result = result
-
-# def addError(self, test, err):
-# log.debug('Proxy addError %s %s', test, err)
-# Result.addError(self, test, err)
-
-# # compose a new error object that includes captured output
-# if self.capt is not None and len(self.capt):
-# ec, ev, tb = err
-# ev = '\n'.join([str(ev) , ln('>> begin captured stdout <<'),
-# self.capt, ln('>> end captured stdout <<')])
-# err = (ec, ev, tb)
-# self.result.addError(test, err)
-
-# def addFailure(self, test, err):
-# log.debug('Proxy addFailure %s %s', test, err)
-# Result.addFailure(self, test, err)
-
-# # compose a new error object that includes captured output
-# # and assert introspection data
-# ec, ev, tb = err
-# if self.tbinfo is not None and len(self.tbinfo):
-# ev = '\n'.join([str(ev), self.tbinfo])
-# if self.capt is not None and len(self.capt):
-# ev = '\n'.join([str(ev) , ln('>> begin captured stdout <<'),
-# self.capt, ln('>> end captured stdout <<')])
-# err = (ec, ev, tb)
-# self.result.addFailure(test, err)
-
-# def addSuccess(self, test):
-# Result.addSuccess(self, test)
-# self.result.addSuccess(test)
-
-# def startTest(self, test):
-# Result.startTest(self, test)
-# self.result.startTest(test)
-
-# def stopTest(self, test):
-# Result.stopTest(self, test)
-# self.result.stopTest(test)
-
-# def _get_shouldStop(self):
-# return self.result.shouldStop
-
-# def _set_shouldStop(self, val):
-# self.result.shouldStop = val
-
-# shouldStop = property(_get_shouldStop, _set_shouldStop)
-
-
-# class TestProxy(unittest.TestCase):
-# """Test case that wraps the test result in a ResultProxy.
-# """
-# resultProxy = ResultProxy
-
-# def __init__(self, wrapped_test):
-# self.wrapped_test = wrapped_test
-# log.debug('%r.__init__', self)
-
-# def __call__(self, *arg, **kw):
-# log.debug('%r.__call__', self)
-# self.run(*arg, **kw)
-
-# def __repr__(self):
-# return "TestProxy for: %r" % self.wrapped_test
-
-# def __str__(self):
-# return str(self.wrapped_test)
-
-# def id(self):
-# return self.wrapped_test.id()
-
-# def run(self, result):
-# log.debug('TestProxy run test %s in proxy %s for result %s',
-# self, self.resultProxy, result)
-# self.wrapped_test(self.resultProxy(result))
-
-# def shortDescription(self):
-# return self.wrapped_test.shortDescription()
View
5 nose/selector.py
@@ -120,7 +120,10 @@ def wantFunction(self, function):
"""Is the function a test function?
"""
try:
- funcname = function.__name__
+ if hasattr(function, 'compat_func_name'):
+ funcname = function.compat_func_name
+ else:
+ funcname = function.__name__
except AttributeError:
# not a function
return False
View
8 nose/suite.py
@@ -1,3 +1,5 @@
+from __future__ import generators
+
import logging
import sys
import unittest
@@ -251,7 +253,7 @@ def teardownContext(self, context):
try_run(context, names)
# FIXME plugins.contextTeardown(context)
- # FIXME the wrapping has to move to the factory
+ # FIXME the wrapping has to move to the factory?
def _get_wrapped_tests(self):
for test in self._get_tests():
if isinstance(test, Test) or isinstance(test, unittest.TestSuite):
@@ -293,7 +295,6 @@ def __call__(self, tests):
suite of suites returned, organized into a stack with the
outermost suites belonging to the outermost contexts.
"""
-
log.debug("Create suite for %s", tests)
context = getattr(tests, 'context', None)
if context is None:
@@ -401,7 +402,6 @@ def mixedSuites(self, tests):
common.append(test)
found_common = True
break
- # no common ancestor found
if not found_common:
remain.append(test)
if common:
@@ -442,4 +442,4 @@ def __init__(*arg, **kw):
raise NotImplementedError(
"TestModule is not usable with nose 0.10. The class is present "
"in nose.suite for backwards compatibility purposes but it "
- "may not be used")
+ "may not be used.")
View
26 nose/tools.py
@@ -8,6 +8,8 @@
"""
import time
+__all__ = ['ok_', 'eq_', 'make_decorator', 'raises', 'timed', 'with_setup',
+ 'TimeExpired']
class TimeExpired(AssertionError):
pass
@@ -29,11 +31,16 @@ def make_decorator(func):
(namely, setup and teardown).
"""
def decorate(newfunc):
- name = func.__name__
+ if hasattr(func, 'compat_func_name'):
+ name = func.compat_func_name
+ else:
+ name = func.__name__
+ newfunc.__dict__ = func.__dict__
+ newfunc.__doc__ = func.__doc__
+ newfunc.__module__ = func.__module__
+ if not hasattr(newfunc, 'compat_co_firstlineno'):
+ newfunc.compat_co_firstlineno = func.func_code.co_firstlineno
try:
- newfunc.__doc__ = func.__doc__
- newfunc.__module__ = func.__module__
- newfunc.__dict__ = func.__dict__
newfunc.__name__ = name
except TypeError:
# can't set func name in 2.3
@@ -88,11 +95,14 @@ def newfunc(*arg, **kw):
return decorate
def with_setup(setup=None, teardown=None):
- """Decorator to add setup and/or teardown methods to a test function
+ """Decorator to add setup and/or teardown methods to a test function::
+
+ @with_setup(setup, teardown)
+ def test_something():
+ # ...
- @with_setup(setup, teardown)
- def test_something():
- # ...
+ Note that `with_setup` is useful *only* for test functions, not for test
+ methods or inside of TestCase subclasses.
"""
def decorate(func, setup=setup, teardown=teardown):
if setup:
View
247 nosetests.1
@@ -0,0 +1,247 @@
+.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.36.
+.TH NOSETESTS "1" "January 2007" "nosetests version 0.9.2" "User Commands"
+.SH NAME
+nosetests \- unit testing for Python software
+.SH SYNOPSIS
+\fBnosetests\fP [\fIoptions\fP] [\fInames\fP]
+.SH DESCRIPTION
+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 magic.
+
+nose collects tests automatically from python source files,
+directories and packages found in its working directory (which
+defaults to the current working directory). Any python source file,
+directory or package that matches the testMatch regular expression
+(by default: (?:^|[\eb_\e.\-])[Tt]est) will be collected as a test (or
+source for collection of tests). In addition, all other packages
+found in the working directory are examined for python source files
+or directories that match testMatch. Package discovery descends all
+the way down the tree, so package.tests and package.sub.tests and
+package.sub.sub2.tests will all be collected.
+
+Within a test directory or package, any python source file matching
+testMatch will be examined for test cases. Within a test file,
+functions and classes whose names match testMatch and TestCase
+subclasses with any name will be loaded and executed as tests. Tests
+may use the assert keyword or raise AssertionErrors to indicate test
+failure. TestCase subclasses may do the same or use the various
+TestCase methods available.
+
+Tests may raise nose.SkipTest to indicate that they should be
+skipped or nose.DeprecatedTest to indicate that they are
+deprecated. Skipped and deprecated tests do not count as failures,
+but details on them are printed at the end of the test run along
+with any failures and errors.
+
+.B Selecting Tests
+
+To specify which tests to run, pass test names on the command line:
+
+nosetests only_test_this.py
+
+Test names specified may be file or module names, and may optionally
+indicate the test case to run by separating the module or file name
+from the test case name with a colon. Filenames may be relative or
+absolute. Examples:
+
+nosetests test.module
+
+nosetests another.test:TestCase.test_method
+
+nosetests a.test:TestCase
+
+nosetests /path/to/test/file.py:test_function
+
+Note however that specifying a test name will *not* cause nose to run
+a test that it does not discover. Test names specified are compared
+against tests discovered, and only the requested tests are
+run. Setup and teardown methods are run at all stages. That means
+that if you run:
+
+nosetests some.tests.test_module:test_function
+
+And have defined setup or teardown methods in tests and test_module,
+those setup methods will run before the test_function test, and
+teardown after, just as if you were running all tests.
+
+You may also change the working directory where nose looks for tests,
+use the \fB\-w\fR switch:
+
+nosetests \fB\-w\fR /path/to/tests
+
+Further customization of test selection and loading is possible
+through the use of plugins.
+
+Test result output is identical to that of unittest, except for the
+additional features (output capture, assert introspection, and any plugins
+that control or produce output) detailed in the options below.
+.SH OPTIONS
+.TP
+\fB\-h\fR, \fB\-\-help\fR
+show this help message and exit
+.TP
+\fB\-V\fR, \fB\-\-version\fR
+Output nose version and exit
+.TP
+\fB\-v\fR, \fB\-\-verbose\fR
+Be more verbose. [NOSE_VERBOSE]
+.TP
+\fB\-\-verbosity\fR=\fIVERBOSITY\fR
+Set verbosity; \fB\-\-verbosity\fR=\fI2\fR is the same as \fB\-vv\fR
+.TP
+\fB\-l\fR DEBUG, \fB\-\-debug\fR=\fIDEBUG\fR
+Activate debug logging for one or more systems.
+Available debug loggers: nose, nose.importer,
+nose.inspector, nose.plugins, nose.result and
+nose.selector. Separate multiple names with a comma.
+.TP
+\fB\-\-debug\-log\fR=\fIDEBUG_LOG\fR
+Log debug messages to this file (default: sys.stderr)
+.HP
+\fB\-q\fR, \fB\-\-quiet\fR
+.TP
+\fB\-w\fR WHERE, \fB\-\-where\fR=\fIWHERE\fR
+Look for tests in this directory [NOSE_WHERE]
+.TP
+\fB\-e\fR EXCLUDE, \fB\-\-exclude\fR=\fIEXCLUDE\fR
+Don't run tests that match regular expression
+[NOSE_EXCLUDE]
+.TP
+\fB\-i\fR INCLUDE, \fB\-\-include\fR=\fIINCLUDE\fR
+Also run tests that match regular expression
+[NOSE_INCLUDE]
+.TP
+\fB\-m\fR TEST_MATCH, \fB\-\-match\fR=\fITEST_MATCH\fR, \fB\-\-testmatch\fR=\fITEST_MATCH\fR
+Use this regular expression to find tests
+[NOSE_TESTMATCH]
+.TP
+\fB\-s\fR, \fB\-\-nocapture\fR
+Don't capture stdout (any stdout output will be
+printed immediately) [NOSE_NOCAPTURE]
+.TP
+\fB\-d\fR, \fB\-\-detailed\-errors\fR
+Add detail to error output by attempting to evaluate
+failed asserts [NOSE_DETAILED_ERRORS]
+.TP
+\fB\-\-pdb\fR
+Drop into debugger on errors
+.TP
+\fB\-\-pdb\-failures\fR
+Drop into debugger on failures
+.TP
+\fB\-x\fR, \fB\-\-stop\fR
+Stop running tests after the first error or failure
+.TP
+\fB\-P\fR, \fB\-\-no\-path\-adjustment\fR
+Don't make any changes to sys.path when loading tests
+[NOSE_NOPATH]
+.TP
+\fB\-\-exe\fR
+Look for tests in python modules that are executable.
+Normal behavior is to exclude executable modules,
+since they may not be import\-safe [NOSE_INCLUDE_EXE]
+.TP
+\fB\-\-noexe\fR
+DO NOT look for tests in python modules that are
+executable. (The default on the windows platform is to
+do so.)
+.TP
+\fB\-\-with\-profile\fR
+Enable plugin Profile: Use this plugin to run tests
+using the hotshot profiler. [NOSE_WITH_PROFILE]
+.TP
+\fB\-\-profile\-sort\fR=\fIPROFILE_SORT\fR
+Set sort order for profiler output
+.TP
+\fB\-\-profile\-stats\-file\fR=\fIPROFILE_STATS_FILE\fR
+Profiler stats file; default is a new temp file on
+each run
+.TP
+\fB\-\-profile\-restrict\fR=\fIPROFILE_RESTRICT\fR
+Restrict profiler output. See help for pstats.Stats
+for details
+.TP
+\fB\-\-with\-missed\-tests\fR
+Enable plugin MissedTests: Enable to get a warning
+when tests specified on the command line are not found
+during the test run. [NOSE_WITH_MISSED\-TESTS]
+.TP
+\fB\-\-with\-isolation\fR
+Enable plugin IsolationPlugin: Activate the isolation
+plugin to isolate changes to external modules to a
+single test module or package. The isolation plugin
+resets the contents of sys.modules after each test
+module or package runs to its state before the test.
+PLEASE NOTE that this plugin may not be used with the
+coverage plugin. [NOSE_WITH_ISOLATION]
+.TP
+\fB\-\-with\-doctest\fR
+Enable plugin Doctest: Activate doctest plugin to
+find and run doctests in non\-test modules.
+[NOSE_WITH_DOCTEST]
+.TP
+\fB\-\-doctest\-tests\fR
+Also look for doctests in test modules
+[NOSE_DOCTEST_TESTS]
+.TP
+\fB\-\-doctest\-extension\fR=\fIDOCTESTEXTENSION\fR
+Also look for doctests in files with this extension
+[NOSE_DOCTEST_EXTENSION]
+.TP
+\fB\-\-with\-coverage\fR
+Enable plugin Coverage: If you have Ned Batchelder's
+coverage module installed, you may activate a coverage
+report. The coverage report will cover any python
+source module imported after the start of the test
+run, excluding modules that match testMatch. If you
+want to include those modules too, use the \fB\-\-covertests\fR switch, or set the NOSE_COVER_TESTS environment
+variable to a true value. To restrict the coverage
+report to modules from a particular package or
+packages, use the \fB\-\-cover\-packages\fR switch or the
+NOSE_COVER_PACKAGES environment variable.
+[NOSE_WITH_COVERAGE]
+.TP
+\fB\-\-cover\-package\fR=\fICOVER_PACKAGES\fR
+Restrict coverage output to selected packages
+[NOSE_COVER_PACKAGE]
+.TP
+\fB\-\-cover\-erase\fR
+Erase previously collected coverage statistics before
+run
+.TP
+\fB\-\-cover\-tests\fR
+Include test modules in coverage report
+[NOSE_COVER_TESTS]
+.TP
+\fB\-\-cover\-inclusive\fR
+Include all python files under working directory in
+coverage report. Useful for discovering holes in test
+coverage if not all files are imported by the test
+suite. [NOSE_COVER_INCLUSIVE]
+.TP
+\fB\-a\fR ATTR, \fB\-\-attr\fR=\fIATTR\fR
+Run only tests that have attributes specified by ATTR
+[NOSE_ATTR]
+.TP
+\fB\-A\fR EXPR, \fB\-\-eval\-attr\fR=\fIEXPR\fR
+Run only tests for whose attributes the Python
+expression EXPR evaluates to True [NOSE_EVAL_ATTR]
+.SH AUTHOR
+.B nose
+is written by Jason Pellerin. This manpage was adapted from the output
+of the
+.B help2man(1)
+program by Jason Pellerin, following the version made by Gustavo Noronha Silva for the Debian GNU/Linux system, but
+may be used by others.
+.SH COPYRIGHT
+Copyright (C) 2005-2007 Jason Pellerin
+
+This is free software. You may redistribute copies of it under the
+terms of the GNU Lesser General Public License
+<http://www.gnu.org/licenses/lgpl.html>. There is NO WARRANTY, to the
+extent permitted by law.
+.SH SEE ALSO
+The project website is at
+.B http://somethingaboutorange.com/mrl/projects/nose/
+.
View
6 scripts/mkindex.py
@@ -20,9 +20,9 @@
docs.update({'version': nose.__version__,
'date': time.ctime()})
-print "Tools..."
-tools = publish_parts(nose.tools.__doc__, writer_name='html')
-docs['tools'] = tools['body']
+#print "Tools..."
+#tools = publish_parts(nose.tools.__doc__, writer_name='html')
+#docs['tools'] = tools['body']
print "Commands..."
cmds = publish_parts(nose.commands.__doc__, writer_name='html')
View
19 scripts/mkrelease.py
@@ -4,14 +4,17 @@
# create and upload a release
import os
import nose
+import sys
from commands import getstatusoutput
success = 0
current = os.getcwd()
-here = os.path.dirname(os.path.dirname(__file__))
-svnroot = os.path.abspath(os.path.join(here, '..', '..', 'nose_svn'))
+here = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
+svnroot = os.path.abspath(os.path.dirname(here))
+branchroot = os.path.join(svnroot, 'branches')
+tagroot = os.path.join(svnroot, 'tags')
svntrunk = os.path.join(svnroot, 'trunk')
def runcmd(cmd):
@@ -31,6 +34,7 @@ def runcmd(cmd):
branch = 'branches/%s.%s.%s-stable' % (versioninfo[0],
versioninfo[1], versioninfo[2])
tag = 'tags/%s-release' % version
+
if os.path.isdir(tag):
raise Exception("Tag path %s already exists. Can't release same version "
"twice!")
@@ -69,11 +73,16 @@ def runcmd(cmd):
runcmd('svn rm setup.cfg --force') # remove dev tag from setup
# check in
-os.chdir(svnroot)
-print "cd %s" % svnroot
-runcmd("svn ci -m 'Release branch/tag for %s'" % version)
+os.chdir(branchroot)
+print "cd %s" % branchroot
+runcmd("svn ci -m 'Release branch for %s'" % version)
+
+os.chdir(tagroot)
+print "cd %s" % tagroot
+runcmd("svn ci -m 'Release tag for %s'" % version)
# make docs
+os.chdir(svnroot)
os.chdir(tag)
print "cd %s" % tag
View
316 scripts/mkwiki.py
@@ -1,18 +1,163 @@
#!/usr/bin/env python
+from commands import getstatusoutput
from docutils.core import publish_string, publish_parts
-import base64
+from docutils.nodes import SparseNodeVisitor
+from docutils.readers.standalone import Reader
+from docutils.writers import Writer
+import nose
import os
import pudge.browser
import re
import sys
import textwrap
import time
-from twill.commands import *
-from twill import get_browser
-import nose
+# constants
+success = 0
div = '\n----\n'
+warning = """
+*Do not edit above this line. Content above this line is automatically
+generated and edits above this line will be discarded.*
+
+= Comments =
+"""
+
+def ucfirst(s):
+ return s[0].upper() + s[1:].lower()
+
+def words(s):
+ return s.split(' ')
+
+def wiki_word(node):
+ print "Unknown ref %s" % node.astext()
+ node['refuri'] = ''.join(map(ucfirst, words(node.astext())))
+ del node['refname']
+ node.resolved = True
+ return True
+wiki_word.priority = 100
+
+class WWReader(Reader):
+ unknown_reference_resolvers = (wiki_word,)
+
+
+class WikiWriter(Writer):
+ def translate(self):
+ visitor = WikiVisitor(self.document)
+ self.document.walkabout(visitor)
+ self.output = visitor.astext()
+
+
+class WikiVisitor(SparseNodeVisitor):
+ def __init__(self, document):
+ SparseNodeVisitor.__init__(self, document)
+ self.list_depth = 0
+ self.list_item_prefix = None
+ self.indent = self.old_indent = ''
+ self.output = []
+ self.preformat = False
+
+ def astext(self):
+ return ''.join(self.output)
+
+ def visit_Text(self, node):
+ #print "Text", node
+ data = node.astext()
+ if not self.preformat:
+ data = data.lstrip('\n\r')
+ data = data.replace('\r', '')
+ data = data.replace('\n', ' ')
+ self.output.append(data)
+
+ def visit_bullet_list(self, node):
+ self.list_depth += 1
+ self.list_item_prefix = (' ' * self.list_depth) + '* '
+
+ def depart_bullet_list(self, node):
+ self.list_depth -= 1
+ if self.list_depth == 0:
+ self.list_item_prefix = None
+ else:
+ (' ' * self.list_depth) + '* '
+ self.output.append('\n\n')
+
+ def visit_list_item(self, node):
+ self.old_indent = self.indent
+ self.indent = self.list_item_prefix
+
+ def depart_list_item(self, node):
+ self.indent = self.old_indent
+
+ def visit_literal_block(self, node):
+ self.output.extend(['{{{', '\n'])
+ self.preformat = True
+
+ def depart_literal_block(self, node):
+ self.output.extend(['\n', '}}}', '\n\n'])
+ self.preformat = False
+
+ def visit_paragraph(self, node):
+ self.output.append(self.indent)
+
+ def depart_paragraph(self, node):
+ self.output.append('\n\n')
+ if self.indent == self.list_item_prefix:
+ # we're in a sub paragraph of a list item
+ self.indent = ' ' * self.list_depth
+
+ def visit_reference(self, node):
+ if node.has_key('refuri'):
+ href = node['refuri']
+ elif node.has_key('refid'):
+ href = '#' + node['refid']
+ else:
+ href = None
+ self.output.append('[' + href + ' ')
+
+ def depart_reference(self, node):
+ self.output.append(']')
+
+ def visit_subtitle(self, node):
+ self.output.append('=== ')
+
+ def depart_subtitle(self, node):
+ self.output.append(' ===\n\n')
+ self.list_depth = 0
+ self.indent = ''
+
+ def visit_title(self, node):
+ self.output.append('== ')
+
+ def depart_title(self, node):
+ self.output.append(' ==\n\n')
+ self.list_depth = 0
+ self.indent = ''
+
+ def visit_title_reference(self, node):
+ self.output.append("`")
+
+ def depart_title_reference(self, node):
+ self.output.append("`")
+
+ def visit_emphasis(self, node):
+ self.output.append('*')
+
+ def depart_emphasis(self, node):
+ self.output.append('*')
+
+ def visit_literal(self, node):
+ self.output.append('`')
+
+ def depart_literal(self, node):
+ self.output.append('`')
+
+
+def runcmd(cmd):
+ print cmd
+ (status,output) = getstatusoutput(cmd)
+ if status != success:
+ raise Exception(output)
+
def section(doc, name):
m = re.search(r'(%s\n%s.*?)\n[^\n-]{3,}\n-{3,}\n' %
@@ -21,25 +166,10 @@ def section(doc, name):
return m.groups()[0]
raise Exception('Section %s not found' % name)
+
def wikirst(doc):
- #
- # module -> page links (will be subbed into each page's string)
- #
- modlinks = { r'\bnose\.plugins\b': 'WritingPlugins'
-
-
- }
-
- # not working at all..
- #for k in modlinks:
- # doc = re.sub(k, '`' + modlinks[k] + '`:trac', doc)
-
- doc = '`This page is autogenerated. Please add comments only ' \
- 'beneath the horizontal rule at the bottom of the page. ' \
- 'Changes above that line will be lost when the page is '\
- 'regenerated.`\n\n' + doc
-
- return '{{{\n#!rst\n%s\n}}}\n' % doc
+ return publish_string(doc, reader=WWReader(), writer=WikiWriter())
+
def plugin_interface():
"""use pudge browser to generate interface docs
@@ -49,16 +179,18 @@ def plugin_interface():
m = b.modules()[0]
intf = list([ c for c in m.classes() if c.name ==
'IPluginInterface'])[0]
- doc = '{{{\n#!rst\n' + intf.doc() + '\n}}}\n'
+ doc = wikirst(intf.doc())
methods = [ m for m in intf.routines() if not m.name.startswith('_') ]
methods.sort(lambda a, b: cmp(a.name, b.name))
- doc = doc + '{{{\n#!html\n'
+ mdoc = []
for m in methods:
- doc = doc + '<b>' + m.name + m.formatargs() + '</b><br />'
- doc = doc + m.doc(html=1)
- doc = doc + '\n}}}\n'
+ mdoc.append('*%s%s*\n\n' % (m.name, m.formatargs()))
+ mdoc.append(' ' + m.doc().replace('\n', '\n '))
+ mdoc.append('\n\n')
+ doc = doc + ''.join(mdoc)
return doc
+
def example_plugin():
# FIXME dump whole example plugin code from setup.py and plug.py
# into python source sections
@@ -68,10 +200,35 @@ def example_plugin():
setup = file(os.path.join(exp, 'setup.py'), 'r').read()
plug = file(os.path.join(exp, 'plug.py'), 'r').read()
- wik = "'''%s:'''\n{{{\n#!python\n%s\n}}}\n"
+ wik = "*%s:*\n{{{\n%s\n}}}\n"
return wik % ('setup.py', setup) + wik % ('plug.py', plug)
-def mkwiki(url, realm, user, passwd):
+
+def tools():
+ top = wikirst(nose.tools.__doc__)
+ b = pudge.browser.Browser(['nose.tools'], None)
+ m = b.modules()[0]
+ funcs = [ (f.name, f.formatargs().replace('(self, ', '('), f.doc())
+ for f in m.routines() ]
+ funcs.sort()
+ mdoc = [top, '\n\n']
+ for name, args, doc in funcs:
+ mdoc.append("*%s%s*\n\n" % (name, args))
+ mdoc.append(' ' + doc.replace('\n', '\n '))
+ mdoc.append('\n\n')
+ return ''.join(mdoc)
+
+
+def usage():
+ doc = nose.core.TestProgram.__doc__.replace("\\", "\\\\")
+ parser = nose.core.get_parser(env={}, builtin_only=True, doc=doc)
+ out = '{{{\n' + \
+ parser.format_help().replace('mkwiki.py', 'nosetests') + \
+ '\n}}}\n'
+ return out
+
+
+def mkwiki(path):
#
# Pages to publish and the docstring(s) to load for that page
#
@@ -81,66 +238,95 @@ def mkwiki(url, realm, user, passwd):
'NoseFeatures': wikirst(section(nose.__doc__, 'Features')),
'WritingPlugins': wikirst(nose.plugins.__doc__),
'PluginInterface': plugin_interface(),
+ 'TestingTools': tools(),
+ 'FindingAndRunningTests': wikirst(
+ section(nose.__doc__, 'Finding and running tests')),
# FIXME finish example plugin doc... add some explanation
'ExamplePlugin': example_plugin(),
- 'NosetestsUsage': '\n{{{\n' +
- nose.configure(help=True).replace('mkwiki.py', 'nosetests') +
- '\n}}}\n'
+ 'NosetestsUsage': usage(),
}
-
- w = TracWiki(url, realm, user, passwd)
+ current = os.getcwd()
+ w = Wiki(path)
for page, doc in pages.items():
print "====== %s ======" % page
w.update_docs(page, doc)
print "====== %s ======" % page
+ os.chdir(current)
+
-class TracWiki(object):
+class Wiki(object):
doc_re = re.compile(r'(.*?)' + div, re.DOTALL)
- def __init__(self, url, realm, user, passwd):
- self.url = url
- self.b = get_browser()
- go(url)
- add_auth(realm, url, user, passwd)
- go('/login')
+ def __init__(self, path):
+ self.path = path
+ self.newpages = []
+ os.chdir(path)
+ runcmd('svn up')
+
+ def filename(self, page):
+ if not page.endswith('.wiki'):
+ page = page + '.wiki'
+ return page
def get_page(self, page):
- go('/wiki/%s?edit=yes' % page)
- self.edit = self.b.get_form('edit')
- return self.edit.get_value('text')
+ headers = []
+ content = []
+
+ try:
+ fh = file(self.filename(page), 'r')
+ in_header = True
+ for line in fh:
+ if in_header:
+ if line.startswith('#'):
+ headers.append(line)
+ else:
+ in_header = False
+ content.append(line)
+ else:
+ content.append(line)
+ fh.close()
+ return (headers, ''.join(content))
+ except IOError:
+ self.newpages.append(page)
+ return ''
- def set_docs(self, page_src, docs):
+ def set_docs(self, page, headers, page_src, docs):
wikified = docs + div
- if self.doc_re.search(page_src):
- print "! Updating doc section"
- new_src = self.doc_re.sub(wikified, page_src, 1)
+ if not page_src:
+ new_src = wikified + warning
+ print "! Adding new page"
else:
- print "! Adding new doc section"
- new_src = wikified + page_src
+ m = self.doc_re.search(page_src)
+ if m:
+ print "! Updating doc section"
+ new_src = self.doc_re.sub(wikified, page_src, 1)
+ else:
+ print "! Adding new doc section"
+ new_src = wikified + page_src
if new_src == page_src:
print "! No changes"
- return
- fv(re.compile('edit'), 'text', new_src)
- submit('save')
-
+ return
+ # Restore any headers (lines marked by # at start of file)
+ if headers:
+ new_src = ''.join(headers) + '\n' + new_src
+ fh = file(self.filename(page), 'w')
+ fh.write(new_src)
+ fh.close()
+
def update_docs(self, page, doc):
- current = self.get_page(page)
- self.set_docs(current, doc)
+ headers, current = self.get_page(page)
+ self.set_docs(page, headers, current, doc)
+ if page in self.newpages:
+ runcmd('svn add %s' % self.filename(page))
def main():
+ path = os.path.abspath(
+ os.path.join(os.path.dirname(__file__), '..', '..', 'wiki'))
+ mkwiki(path)
- try:
- url = sys.argv[1]
- except IndexError:
- url = 'https://nose.python-hosting.com'
- realm = os.environ.get('NOSE_WIKI_REALM')
- user = os.environ.get('NOSE_WIKI_USER')
- passwd = os.environ.get('NOSE_WIKI_PASSWD')
- mkwiki(url, realm, user, passwd)
-
if __name__ == '__main__':
main()
View
125 scripts/rst2wiki.py
@@ -0,0 +1,125 @@
+#!/usr/bin/env python
+
+import sys
+from docutils.nodes import SparseNodeVisitor, paragraph, title_reference, \
+ emphasis
+from docutils.writers import Writer
+from docutils.core import publish_string
+
+class WikiWriter(Writer):
+ def translate(self):
+ visitor = WikiVisitor(self.document)
+ self.document.walkabout(visitor)
+ self.output = visitor.astext()
+
+class WikiVisitor(SparseNodeVisitor):
+
+ def __init__(self, document):
+ SparseNodeVisitor.__init__(self, document)
+ self.list_depth = 0
+ self.list_item_prefix = None
+ self.indent = self.old_indent = ''
+ self.output = []
+ self.preformat = False
+
+ def astext(self):
+ return '\n>>>\n\n'+ ''.join(self.output) + '\n\n<<<\n'
+
+ def visit_Text(self, node):
+ #print "Text", node
+ data = node.astext()
+ if not self.preformat:
+ data = data.lstrip('\n\r')
+ data = data.replace('\r', '')
+ data = data.replace('\n', ' ')
+ self.output.append(data)
+
+ def visit_bullet_list(self, node):
+ self.list_depth += 1
+ self.list_item_prefix = (' ' * self.list_depth) + '* '
+
+ def depart_bullet_list(self, node):
+ self.list_depth -= 1
+ if self.list_depth == 0:
+ self.list_item_prefix = None
+ else:
+ (' ' * self.list_depth) + '* '
+ self.output.append('\n\n')
+
+ def visit_list_item(self, node):
+ self.old_indent = self.indent
+ self.indent = self.list_item_prefix
+
+ def depart_list_item(self, node):
+ self.indent = self.old_indent
+
+ def visit_literal_block(self, node):
+ self.output.extend(['{{{', '\n'])
+ self.preformat = True
+
+ def depart_literal_block(self, node):
+ self.output.extend(['\n', '}}}', '\n\n'])
+ self.preformat = False
+
+ def visit_paragraph(self, node):
+ self.output.append(self.indent)
+
+ def depart_paragraph(self, node):
+ self.output.append('\n\n')
+ if self.indent == self.list_item_prefix:
+ # we're in a sub paragraph of a list item
+ self.indent = ' ' * self.list_depth
+
+ def visit_reference(self, node):
+ if node.has_key('refuri'):
+ href = node['refuri']
+ elif node.has_key('refid'):
+ href = '#' + node['refid']
+ else:
+ href = None
+ self.output.append('[' + href + ' ')
+
+ def depart_reference(self, node):
+ self.output.append(']')
+
+ def visit_subtitle(self, node):
+ self.output.append('=== ')
+
+ def depart_subtitle(self, node):
+ self.output.append(' ===\n\n')
+ self.list_depth = 0
+ self.indent = ''
+
+ def visit_title(self, node):
+ self.output.append('== ')
+
+ def depart_title(self, node):
+ self.output.append(' ==\n\n')
+ self.list_depth = 0
+ self.indent = ''
+
+ def visit_title_reference(self, node):
+ self.output.append("`")
+
+ def depart_title_reference(self, node):
+ self.output.append("`")
+
+ def visit_emphasis(self, node):
+ self.output.append('*')
+
+ def depart_emphasis(self, node):
+ self.output.append('*')
+
+ def visit_literal(self, node):
+ self.output.append('`')
+
+ def depart_literal(self, node):
+ self.output.append('`')
+
+
+def main(source):
+ output = publish_string(source, writer=WikiWriter())
+ print output
+
+if __name__ == '__main__':
+ main(sys.stdin.read())
View
3  setup.cfg
@@ -11,3 +11,6 @@ with-doctest=1
;;pdb=1
;;pdb-failures=1
;;stop=1
+
+[bdist_rpm]
+doc_files = man/man1/nosetests.1
View
39 setup.py
@@ -27,28 +27,35 @@
author = 'Jason Pellerin',
author_email = 'jpellerin+nose@gmail.com',
description = ('A unittest extension offering automatic test suite '
- 'discovery, simplified test authoring, and output capture'),
- long_description = ('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 magic. '
- 'By default, nose will run tests in files or '
- 'directories under the current working directory '
- 'whose names include "test". nose also supports '
- 'doctest tests and may optionally provide a '
- 'test coverage report.\n\n'
- 'If you have recently reported a bug marked as fixed, '
- 'or have a craving for the very latest, you may want '
- 'the development version instead: '
- 'http://svn.nose.python-hosting.com/trunk#egg=nose-dev'
- ),
+ 'discovery and easy test authoring'),
+ long_description = \
+ """nose extends the test loading and running features of unittest, making
+ it easier to write, find and run tests.
+
+ By default, nose will run tests in files or directories under the current
+ working directory whose names include "test" or "Test" at a word boundary
+ (like "test_this" or "functional_test" or "TestClass" but not
+ "libtest"). Test output is similar to that of unittest, but also includes
+ captured stdout output from failing tests, for easy print-style debugging.
+
+ These features, and many more, are customizable through the use of
+ plugins. Plugins included with nose provide support for doctest, code
+ coverage and profiling, and flexible attribute-based test
+ selection. More information about writing plugins may be found on the
+ wiki, here: http://code.google.com/p/python-nose/wiki/WritingPlugins.
+
+ If you have recently reported a bug marked as fixed, or have a craving for
+ the very latest, you may want the development version instead:
+ http://python-nose.googlecode.com/svn/trunk#egg=nose-dev
+ """,
license = 'GNU LGPL',
keywords = 'test unittest doctest automatic discovery',
url = 'http://somethingaboutorange.com/mrl/projects/nose/',
download_url = \
'http://somethingaboutorange.com/mrl/projects/nose/nose-%s.tar.gz' \
% VERSION,
- package_data = { '': [ '*.txt' ] },
+ data_files = [('man/man1', ['nosetests.1'])],
+ package_data = {'': ['*.txt']},
classifiers = [
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
View
115 tickets.csv
@@ -0,0 +1,115 @@
+__color__,__group__,__style__,ticket,summary,component,status,resolution,version,severity,priority,owner,description,modified,_time,_reporter
+3,1.0,font-weight: bold,90,Improve logging config options,nose,new,None,,enhancement,normal,jpellerin,Logging (for nose itself and the packages it tests) config should be more accessible -- esp. it should be possible to configure logging with a standard logging config file. Attachment is a plugin from Oliver Rutherfurd that adds --log-config and --log-filename options. This should be adapted and made part of configure_logging in nose.core.,1158168669,1158168669,jpellerin
+3,1.0,font-weight: bold,85,Is it possible to have more control over TestProgram configuration when running the nose from within python code?,nose,assigned,None,0.9,enhancement,normal,jpellerin,I am trying to use nose with the NoseXML plugin. When I call: nose.run(argv=['--with-nosexml'_'--xml-report-file=some_file'])_ I get my NoseXML output in some_file. This is nice. On the other hand_ it would be nicer if I could specify a StringIO that the NoseXML could write to instead of a file in the filesystem. I have managed to do this by poking around inside the nose.core.TestProgram class and nose.core.configure function_ but my solution is not really acceptable for long-term use. I manually insert a StringIO into the configuration information after argv is parsed and before it is passed to the plugins. Please consider providing a different means for specifying configuration information to nose when it is run using nose.run(). I would be glad to help with this if it would be an acceptable change. And if I've missed the proper way to do something like this_ please let me know. Thanks_ Matthew Desmarais,1156804579,1156793693,q_canada-at-yahoo.com
+3,1.0,font-weight: bold,57,.noserc,nose,assigned,None,1.0,normal,normal,jpellerin,Support reading options from a .noserc file or other config file. Format should be the same as command line args (long form)_ minus the --.,1147630012,1147630001,jpellerin
+3,1.0,color: #777; background: #ddd; border-color: #ccc;,80,provide TestCase methods as functions.,nose,closed,worksforme,0.9,enhancement,normal,jpellerin,Hi First of all I'm new to nose and I like what I see_ I always complained about JUnit/pyUnit because it's too much troubles ... nose takes that away from me. but when I try to test for a method that should raises a certain type of exception I found out that the only way to do this is with TestCase_ at least to catch a certain specific type of test. So how abotu adding a reimplementation (basically transform the methods into functions of TestCase.* into module level nose functions? So we can implement this {{{ class TestMyApp(TestCase): def test_create(self): self.failUnlessRaises(NotImplementedError_ source.create) }}} as {{{ def test_create(): nose.failUnlessRaises(NotImplementedError_ source.create) }}} here is the original thread. http://tinyurl.com/mvssg,1154752873,1154742572,jorge.vargas
+3,1.0,color: #777; background: #ddd; border-color: #ccc;,24,Allow plugins to completely change test output,nose:plugins,closed,fixed,1.0,normal,normal,jpellerin,Currently watcher plugins can report() to add to test output_ but there should be a hook for plugins to take over and do all test output.,1143522249,1143169945,jpellerin
+2,0.9rc1,color: #777; background: #ddd; border-color: #ccc;,27,Missing units,nose,closed,fixed,0.9a1,major,high,jpellerin,Missing unittests for many core functions: * loader testsInModule * loader FunctionTestCase * loader MethodTestCase * LazySuite.run,1151027521,1143519866,jpellerin
+3,0.9b1,color: #777; background: #ddd; border-color: #ccc;,61,Attribute plugin 'OR' test doesn't work,nose:plugins,closed,fixed,0.9a1,normal,normal,jpellerin,nosetests -a tags=a -a tags=b should select tests that have a tags attribute with the value of 'a' or 'b' or a list containing one or both of those values_ but it doesn't.,1148515497,1148351284,jpellerin
+3,0.9b1,color: #777; background: #ddd; border-color: #ccc;,59,nose.tools.raises hides module of original test,nose,closed,fixed,0.9a1,minor,normal,jpellerin,When using nose.tools.raises_ the test reports look like: {{{ nose.tools.<testfunc> }}} Instead of: {{{ <testmod>.<testfunc> }}} raises needs to set the name or module of the wrapper it returns properly.,1148515476,1147897945,jpellerin
+2,0.9b1,color: #777; background: #ddd; border-color: #ccc;,58,ArrtibuteError running nosetests,nose:importer,closed,fixed,0.9a1,normal,high,jpellerin,I'm getting this when running nosetests. Not sure whats causing it_ but I thought someone might be able to point me in the right direction. I will attach the traceback.,1148515456,1147879026,casbon@gmail.com
+3,0.9a2,color: #777; background: #ddd; border-color: #ccc;,54,ignore all executable files?,nose,closed,fixed,0.9,normal,normal,jpellerin, * Is this desirable? (YES) * Is it possible to do_ dependably_ cross-platform? (YES),1147140636,1146622844,jpellerin
+3,0.9a2,color: #777; background: #ddd; border-color: #ccc;,51,nose.collector causes loop when running `setup.py test`,nose,closed,invalid,0.9a1,normal,normal,jpellerin,have a looksee here at my setup.py file: svn co http://svn.testtools.python-hosting.com/trunk --revision=186 testtools I'm using test_suite = "nose.collector" and when I run `setup.py test` with 0.9a1 it gets caught in a loop like so : running test running egg_info writing testtools.egg-info/PKG-INFO writing top-level names to testtools.egg-info/top_level.txt writing manifest file 'testtools.egg-info/SOURCES.txt' running build_ext At revision 186. running test running egg_info writing testtools.egg-info/PKG-INFO writing top-level names to testtools.egg-info/top_level.txt writing manifest file 'testtools.egg-info/SOURCES.txt' running build_ext At revision 186. ... but when I run `nosetests` everything goes smooth. I mentioned in the email that it was working on dev2_ but I meant it was working for other projects. I.E. running `python setup.py test` in etl/trunk/py-lib/ works just fine. I can't see offhand what is different.,1147140543,1146498659,support-forums4@farmdev.com
+3,0.9a2,color: #777; background: #ddd; border-color: #ccc;,53,plugin import errors kill test run,nose:plugins,closed,fixed,0.9,major,normal,jpellerin,Plugin import errors need to be reduced to warnings_ since the import happens before users have a chance to disable the plugin. Example: If profile module is not installed_ nosetests exits with exception without running any tests.,1147140412,1146507699,jpellerin
+3,0.9a2,color: #777; background: #ddd; border-color: #ccc;,52,profile plugin shadows builtin profile module,nose:plugin:profile,closed,fixed,0.9a1,major,normal,jpellerin,It needs a name change_ causes nosetests to fail to load on some platforms.,1147140384,1146507509,jpellerin
+3,0.9a2,color: #777; background: #ddd; border-color: #ccc;,56,wantFunction and wantMethod bugs in attr [patch],nose:plugins,closed,fixed,0.9,normal,normal,jpellerin,this might be better fixed in the loader since I think at least for the wantMethod bug_ it should not get something that's not a method. But this patches was necessary to allow a large ETL suite to run that I'm trying to use attributes in. a patch against branches/0.9-stable is to follow,1146939370,1146843133,Kumar McMillan <support-forums4@farmdev.com>
+3,0.9a2,color: #777; background: #ddd; border-color: #ccc;,55,bug in doctest plugin loadTestsFromPath [patch],nose:plugin:doctest,closed,fixed,0.9a1,normal,normal,jpellerin,we get an iteration error in the doctest plugin when looking at a directory filename (i.e. not a valid .py file). A patch is to follow ...,1146798517,1146669523,support-forums4@farmdev.com
+2,0.9a1,color: #777; background: #ddd; border-color: #ccc;,50,Update mkrelease,nose,closed,fixed,0.9,normal,high,jpellerin,Update mkrelease to make svn/svk branch and tag instead of bzr.,1146441331,1145838610,jpellerin
+4,0.9a1,color: #777; background: #ddd; border-color: #ccc;,4,doc -> wiki,nose,closed,fixed,0.9a1,normal,low,jpellerin,Add a script similiar to mkindex.py that posts doc updates to the right places in this wiki.,1146106486,1141872678,jpellerin
+1,0.9a1,color: #777; background: #ddd; border-color: #ccc;,49,Update docs for 0.9,nose,closed,fixed,0.9,normal,highest,jpellerin, * Update the CHANGELOG and NEWS files. * Update module_ package and class docstrings * Update TestProgram usage * Update mkindex_ make sure it is pulling all relevant info * Update hacking_ etc_ on index to include new svn repos information * Add to this ticket as I think of more doc updates that are needed,1146106433,1145836661,jpellerin
+3,0.9a1,color: #777; background: #ddd; border-color: #ccc;,37,setuptools integration phase 2: disable plugins,nose:plugins,closed,fixed,0.9,normal,normal,jpellerin,When run under setuptools_ should disable plugins that implement methods that won't get a chance to run (report_ finalize_ prepareTest_ setOutputStream).,1145935337,1144723989,jpellerin
+3,0.9a1,color: #777; background: #ddd; border-color: #ccc;,48,logging behavior: ignore root logger settings,nose,closed,fixed,0.9,normal,normal,jpellerin,Since nose is likely to be run in unstable environments where users are setting their root or other loggers to debug to debug their own code_ and those users are probably not interested in nose's debug info_ nose should explicitly override the root logger settings in the 'nose' domain. Don't use basicConfig_ but compose a handler and formatter and set the log level to whatever is appropriate for the selected verbosity level.,1145836506,1145667736,jpellerin
+3,0.9a1,color: #777; background: #ddd; border-color: #ccc;,46,super?,nose,closed,fixed,0.9,normal,normal,jpellerin,Check usage of super() vs direct __init__ calls. Ref: http://fuhm.net/super-harmful/,1145836488,1145372445,jpellerin
+3,0.9a1,color: #777; background: #ddd; border-color: #ccc;,44,disable attrib plugin eval option for versions < 2.4,nose:plugins,closed,fixed,0.9,normal,normal,jpellerin,eval() can't take an instance in 2.3_ so the attrib eval() option must be disabled in 2.3.,1145836452,1145329766,jpellerin
+3,0.9a1,color: #777; background: #ddd; border-color: #ccc;,45,Fix tests for 2.3,nose:selftest,closed,fixed,0.9,normal,normal,jpellerin,Many tests are failing under 2.3 due to incompatibile iteration_ etc.,1145496998,1145330134,jpellerin
+3,0.9a1,color: #777; background: #ddd; border-color: #ccc;,43,nosetests bad_file.py -> greedy loads,nose,closed,fixed,0.9,normal,normal,jpellerin,When given a bad file name_ nosetests loads tests from all modules instead of issuing a warning.,1145210494,1145160913,jpellerin
+3,0.9a1,color: #777; background: #ddd; border-color: #ccc;,42,nosetests relative/path.py -> no tests loaded,nose,closed,fixed,0.9,normal,normal,jpellerin,Test name resolution for relative filenames is wrong. The files are not loaded.,1145210478,1145160805,jpellerin
+3,0.9a1,color: #777; background: #ddd; border-color: #ccc;,41,profiler plugin is broken,nose:plugin:profile,closed,fixed,0.9,normal,normal,jpellerin,Trying to run with profiler enabled results in errors from the hotshot stats loader: {{{ Could not identify fileId 10 Could not identify fileId 10 Traceback (most recent call last): File "<stdin>"_ line 1_ in ? File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/hotshot/stats.py"_ line 12_ in load return StatsLoader(filename).load() File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/hotshot/stats.py"_ line 29_ in load for event in log: File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/hotshot/log.py"_ line 120_ in next filename = self._filemap[fileno] KeyError: 91 }}},1145210457,1145160589,jpellerin
+3,0.9a1,color: #777; background: #ddd; border-color: #ccc;,40,stop on first error,nose,closed,fixed,0.9a1,normal,normal,jpellerin,Suggestion from Kevin Dangoor: Add an option to stop running tests on the first failure.,1145210422,1144937337,jpellerin
+3,0.9a1,color: #777; background: #ddd; border-color: #ccc;,36,loader.loadTestsFromNames behavior,nose,closed,fixed,0.9,normal,normal,jpellerin,The test loader's loadTestsFromNames behavior isn't compatible with single-test-file unittest-style command lines_ eg: {{{ python unit_tests/test_loader.py TestNoseTestLoader.test_generate_func }}} It needs to be revised for compatibility with unittest.,1145210398,1144543740,jpellerin
+3,0.9a1,color: #777; background: #ddd; border-color: #ccc;,34,nose.main signature does not match unittest.main,nose,closed,fixed,0.9,normal,normal,jpellerin,nose.main should be usable interchangably with unittest.main.,1145210364,1144377521,jpellerin
+3,0.9a1,color: #777; background: #ddd; border-color: #ccc;,33,coverage plugin: option to erase before run,nose:plugin:coverage,closed,fixed,0.9,normal,normal,jpellerin,The coverage plugin should have an option to allow the user to erase accumulated stats before a test run.,1144886539,1144035280,jpellerin
+3,0.9a1,color: #777; background: #ddd; border-color: #ccc;,32,revise setuptools support_ phase 1,nose,closed,fixed,0.9,normal,normal,jpellerin,To support setuptools test command as best as possible without monkeypatching_ follow PJE's prescription: {{{ #!python class ResultProxy: def addError(self_ test_ err): # reformat err_ adding captured info # then calling addError() on the wrapped result def startTest(self_ test): # code to begin output capture and assertion tracking # then call startTest() on the wrapped result def stopTest(self_ test): # code to end output capture and assertion tracking # then call stopTest() on the wrapped result # ... etc. class TestProxy: def __call__(self_ result): self.wrapped_test(ResultProxy(result)) def shortDescription(self): return self.wrapped_test.shortDescription() }}} The test_suite hook is still better than the test_loader hook_ since test suite can be a function that does other setup; it should configure the system with a setting that deactivates any plugins that can't be supported under this scenario (that is_ any plugin that uses report_ finalize_ prepareTest or setOutputStream),1144723915,1143866267,jpellerin
+3,0.9a1,color: #777; background: #ddd; border-color: #ccc;,31,nose.tools,nose,closed,fixed,0.9,normal,normal,jpellerin,Create nose.tools module and move with_setup there. Also add: * @raises * @timed And try to think of some more useful_ general test-writing tools to add.,1144723893,1143816999,jpellerin
+3,0.9a1,color: #777; background: #ddd; border-color: #ccc;,14,test generators for methods do not work,nose,closed,fixed,0.8.7.1,normal,normal,jpellerin,Given the following testclass: class TestSomething(object): def setUp(cls): cls.x = 5 print "setting up" def test_1(self): assert self.x == 4 def test_2(self): assert self.x == 6 def test_3(self): for x in (1_2_7): yield self.check_x def check(self_arg): assert arg %7 ==0 Method test_3 does not function as a proper test generator. What should probably happen is: 1) test_3 generates three separate tests_ just like regular test generators 2) Each of the three tests created by test_3 should get setUp() called when they're called.,1144723873,1142702895,guest
+3,0.9a1,color: #777; background: #ddd; border-color: #ccc;,25,profiler: output controls,nose:plugin:profile,closed,fixed,0.9,normal,normal,jpellerin,Need controls and options for those controls for the profiler plugin. Including: * formatting options -- sort_ restrict func names_ % of list * prof data filename option (file to store profile data in during run) * print/no print report * print to report stream * output to file ,1144378756,1143170571,jpellerin
+2,0.9a1,color: #777; background: #ddd; border-color: #ccc;,10,document plugin interfaces,nose:plugins,closed,fixed,0.9a1,normal,high,jpellerin,Document the collector_ selector and watcher methods that plugins can implement and where they are called in the process.,1144378682,1142090806,jpellerin
+3,0.9a1,color: #777; background: #ddd; border-color: #ccc;,22,loading tests from classes: beware subclassing,nose,closed,fixed,0.9,normal,normal,jpellerin,The following case will currently result in wrong behavior: {{{ #!python class TestA: def test_a(self): pass class TestB(TestA): def test_b(self): pass }}} TestB will collect and run both test_a and test_b; it should only run