--- nose-0.10.4.orig/nose/loader.py +++ nose-0.10.4/nose/loader.py @@ -284,6 +284,8 @@ test = getattr(module, item, None) # print "Check %s (%s) in %s" % (item, test, module.__name__) if isclass(test): + if test.__name__ is None: + raise ValueError("Test class %r doesn't have a __name__ attribute" % test) if self.selector.wantClass(test): test_classes.append(test) elif isfunction(test) and self.selector.wantFunction(test): --- nose-0.10.4.orig/nose/case.py +++ nose-0.10.4/nose/case.py @@ -5,6 +5,7 @@ import logging import sys import unittest +import inspect from nose.config import Config from nose.failure import Failure # for backwards compatibility from nose.util import resolve_name, test_address, try_run @@ -323,8 +324,14 @@ self.test = test self.arg = arg self.descriptor = descriptor - self.cls = method.im_class - self.inst = self.cls() + if inspect.isclass(method.im_self): + self.cls = method.im_self + else: + self.cls = method.im_class + try: + self.inst = self.cls() + except TypeError, e: + raise ValueError("Could not instantiate class to test method %s: %s" % (self.method, e)) if self.test is None: method_name = self.method.__name__ self.test = getattr(self.inst, method_name) @@ -360,10 +367,10 @@ """Get context (class) of this test""") def setUp(self): - try_run(self.inst, ('setup', 'setUp')) + try_run(self.inst, ('setup', 'setUp', 'setup_method'), method=self.method) def tearDown(self): - try_run(self.inst, ('teardown', 'tearDown')) + try_run(self.inst, ('teardown', 'tearDown', 'teardown_method'), method=self.method) def _descriptors(self): """Get the descriptors of the test method: the method and --- nose-0.10.4.orig/nose/tools.py +++ nose-0.10.4/nose/tools.py @@ -42,10 +42,14 @@ name = func.compat_func_name else: name = func.__name__ - newfunc.__dict__ = func.__dict__ + try: + newfunc.__dict__ = func.__dict__ + except AttributeError: + for attr in dir(func): + newfunc.__dict__[attr] = getattr(func, attr) newfunc.__doc__ = func.__doc__ newfunc.__module__ = func.__module__ - if not hasattr(newfunc, 'compat_co_firstlineno'): + if not hasattr(newfunc, 'compat_co_firstlineno') and hasattr(func, "func_code"): newfunc.compat_co_firstlineno = func.func_code.co_firstlineno try: newfunc.__name__ = name @@ -85,6 +89,7 @@ else: message = "%s() did not raise %s" % (name, valid) raise AssertionError(message) + return True newfunc = make_decorator(func)(newfunc) return newfunc return decorate --- nose-0.10.4.orig/nose/util.py +++ nose-0.10.4/nose/util.py @@ -421,7 +421,7 @@ test_address.__test__ = False # do not collect -def try_run(obj, names): +def try_run(obj, names, method=None): """Given a list of possible method names, try to run them with the provided object. Keep going until something works. Used to run setup/teardown methods for module, package, and function tests. @@ -449,8 +449,12 @@ if len(args): log.debug("call fixture %s.%s(%s)", obj, name, obj) return func(obj) - log.debug("call fixture %s.%s", obj, name) - return func() + if name.endswith("_method"): + log.debug("call fixture %s.%s(%s)", obj, name, method) + return func(method) + else: + log.debug("call fixture %s.%s", obj, name) + return func() def src(filename): --- nose-0.10.4.orig/debian/rules +++ nose-0.10.4/debian/rules @@ -0,0 +1,14 @@ +#!/usr/bin/make -f + +DEB_PYTHON_SYSTEM=pysupport + +include /usr/share/cdbs/1/rules/buildcore.mk +include /usr/share/cdbs/1/rules/debhelper.mk +include /usr/share/cdbs/1/class/python-distutils.mk + +DEB_PYTHON_INSTALL_ARGS_ALL += --single-version-externally-managed + +binary-post-install/$(DEB_PYTHON_MODULE_PACKAGE):: + # the manpage is already being installed at the correct place + # remove the incorrect path + rm -rf debian/$(DEB_PYTHON_MODULE_PACKAGE)/usr/man --- nose-0.10.4.orig/debian/pyversions +++ nose-0.10.4/debian/pyversions @@ -0,0 +1 @@ +2.3- --- nose-0.10.4.orig/debian/copyright +++ nose-0.10.4/debian/copyright @@ -0,0 +1,27 @@ +This package was debianized by Gustavo Noronha Silva on +Sun, 07 May 2006 22:54:10 -0300. + +It was downloaded from http://somethingaboutorange.com/mrl/projects/nose/ + +Copyright: + +Copyright (C) 2005-2006 Jason Pellerin + +License: + + 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 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 + + On Debian systems, the LGPL version 2 license can be found at + /usr/share/common-licenses/LGPL-2. --- nose-0.10.4.orig/debian/pycompat +++ nose-0.10.4/debian/pycompat @@ -0,0 +1 @@ +2 --- nose-0.10.4.orig/debian/examples +++ nose-0.10.4/debian/examples @@ -0,0 +1 @@ +examples/* --- nose-0.10.4.orig/debian/docs +++ nose-0.10.4/debian/docs @@ -0,0 +1 @@ +README.txt --- nose-0.10.4.orig/debian/control +++ nose-0.10.4/debian/control @@ -0,0 +1,20 @@ +Source: nose +Section: python +Priority: optional +Maintainer: Gustavo Noronha Silva +Uploaders: Debian Python Modules Team +Build-Depends: python-dev (>= 2.3.5-7), python-setuptools (>= 0.6a9-1), debhelper (>= 5.0.37.2), cdbs (>= 0.4.42), python-support (>= 0.6.4) +Homepage: http://somethingaboutorange.com/mrl/projects/nose/ +XS-Python-Version: >= 2.3 +Vcs-Svn: svn://svn.debian.org/python-modules/packages/nose/trunk/ +Vcs-Browser: http://svn.debian.org/wsvn/python-modules/packages/nose/?op=log +Standards-Version: 3.7.2 + +Package: python-nose +Architecture: all +Depends: ${python:Depends}, python-setuptools (>= 0.6a9-1) +XB-Python-Version: ${python:Versions} +Description: test discovery and running for Python's unittest + 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 --- nose-0.10.4.orig/debian/changelog +++ nose-0.10.4/debian/changelog @@ -0,0 +1,103 @@ +nose (0.10.4-ppa3) intrepid; urgency=low + + * Built on Intrepid + + -- David Fraser Mon, 15 Dec 2008 15:30:31 +0200 + +nose (0.10.4-ppa2) hardy; urgency=low + + * Remove unneeded sections of py.test compatibility patch + * Add test for setup_method + * Add link to patch submission + + -- David Fraser Thu, 09 Oct 2008 11:45:00 +0200 + +nose (0.10.4-ppa1) hardy; urgency=low + + * Upgrade to 0.10.4 + * Include patch for py.test compatibility + + -- David Fraser Thu, 09 Oct 2008 09:58:00 +0200 + +nose (0.10.0-1) unstable; urgency=low + + [ Piotr Ożarowski ] + * Vcs-Browser and Homepage fields added + * XS-Vcs-Svn field renamed to Vcs-Svn + + [ Gustavo Noronha Silva ] + * New upstream release (Closes: #449072) + + -- Gustavo Noronha Silva Sat, 17 Nov 2007 03:31:08 -0200 + +nose (0.9.3-1) unstable; urgency=low + + * New upstream release + + -- Gustavo Noronha Silva Wed, 27 Jun 2007 20:57:42 -0300 + +nose (0.9.2-3) unstable; urgency=low + + [ Piotr Ożarowski ] + * New python-support handles egg's directory name correctly + - bump python-support required version + - remove mv part from debian/rules + (Closes: #423978) + + -- Gustavo Noronha Silva Sat, 19 May 2007 17:22:13 -0300 + +nose (0.9.2-2) unstable; urgency=low + + * Uploading to unstable + + -- Gustavo Noronha Silva Sun, 15 Apr 2007 14:28:01 -0300 + +nose (0.9.2-1) experimental; urgency=low + + * New upstream release + * debian/rules: + - remove the incorrect path in which upstream is installing + the manpage + * debian/manpages, debian/nosetests.1: + - have the upstream manpage be installed, instead of the one I provide + (it is the one upstream is providing now, but updated) + + -- Gustavo Noronha Silva Thu, 15 Feb 2007 00:30:17 -0200 + +nose (0.9.1-1) experimental; urgency=low + + [ Piotr Ozarowski ] + * New upstream release + * debian/control: + - moved python-dev to Build-Depends: (to satisfy lintian) + - added XS-Vcs-Svn field + * debian/rules: + - simplified a little bit (`pyversions -vd' instead of sed) + * Added debian/watch file + * Bumped debhelper compatibility from 4 to 5 + + -- Gustavo Noronha Silva Sat, 13 Jan 2007 19:52:32 -0200 + +nose (0.9.0-2) unstable; urgency=low + + * debian/control: + - added python-setuptools to Depends (Closes: #395287) + - added XS-Python-Version + * debian/docs: + - added, now install README.txt documentation (addresses #395289) + * debian/examples: + - added; install the examples provided, as well + * debian/nosetests.1, debian/manpages: + - added; manpage generated by help2man and adapted to add some important + information (Closes: #395289) + + -- Gustavo Noronha Silva Thu, 26 Oct 2006 22:47:27 -0300 + +nose (0.9.0-1) unstable; urgency=low + + * Initial Release (Closes: #366786) + - thanks to Arnaud Fontaine for implementing the new + python policy + + -- Gustavo Noronha Silva Sun, 7 May 2006 22:49:58 -0300 + --- nose-0.10.4.orig/debian/compat +++ nose-0.10.4/debian/compat @@ -0,0 +1 @@ +5 --- nose-0.10.4.orig/debian/manpages +++ nose-0.10.4/debian/manpages @@ -0,0 +1 @@ +nosetests.1 --- nose-0.10.4.orig/debian/watch +++ nose-0.10.4/debian/watch @@ -0,0 +1,2 @@ +version=3 +http://somethingaboutorange.com/mrl/projects/nose/nose-(.*)\.tar\.gz debian uupdate --- nose-0.10.4.orig/debian/patches/10-pytest-compatibility.patch +++ nose-0.10.4/debian/patches/10-pytest-compatibility.patch @@ -0,0 +1,69 @@ +Changes API from setup_method(self) to setup_method(self, method) +for compatibility with py.test (and likewise for teardown_method) +See http://code.google.com/p/python-nose/issues/detail?id=210 +--- nose-0.10.4/nose/case.py 2008-04-02 04:44:16.000000000 +0200 ++++ nose-0.10.4/nose/case.py 2008-10-09 10:02:45.000000000 +0200 +@@ -360,10 +360,10 @@ + """Get context (class) of this test""") + + def setUp(self): +- try_run(self.inst, ('setup', 'setUp')) ++ try_run(self.inst, ('setup', 'setUp', 'setup_method'), method=self.method) + + def tearDown(self): +- try_run(self.inst, ('teardown', 'tearDown')) ++ try_run(self.inst, ('teardown', 'tearDown', 'teardown_method'), method=self.method) + + def _descriptors(self): + """Get the descriptors of the test method: the method and +--- nose-0.10.4/nose/util.py 2008-04-30 21:32:14.000000000 +0200 ++++ nose-0.10.4/nose/util.py 2008-10-09 10:02:45.000000000 +0200 +@@ -421,7 +421,7 @@ + test_address.__test__ = False # do not collect + + +-def try_run(obj, names): ++def try_run(obj, names, method=None): + """Given a list of possible method names, try to run them with the + provided object. Keep going until something works. Used to run + setup/teardown methods for module, package, and function tests. +@@ -449,8 +449,12 @@ + if len(args): + log.debug("call fixture %s.%s(%s)", obj, name, obj) + return func(obj) +- log.debug("call fixture %s.%s", obj, name) +- return func() ++ if name.endswith("_method"): ++ log.debug("call fixture %s.%s(%s)", obj, name, method) ++ return func(method) ++ else: ++ log.debug("call fixture %s.%s", obj, name) ++ return func() + + + def src(filename): +--- nose-0.10.4/unit_tests/test_cases.py 2008-03-06 17:24:27.000000000 +0200 ++++ nose-0.10.4/unit_tests/test_cases.py 2008-10-09 10:28:47.000000000 +0200 +@@ -80,7 +80,21 @@ + case = nose.case.MethodTestCase(TestClassFailingTest.test_func) + case(res) + self.assertEqual(called, ['setup', 'test', 'teardown']) +- ++ ++ class TestClassSetupMethod(object): ++ def setup_method(self, method): ++ called.append('setup_method %s' % (method.__name__)) ++ def teardown_method(self, method): ++ called.append('teardown_method %s' % (method.__name__)) ++ def test_func(self): ++ called.append('test') ++ raise Exception("failed") ++ ++ called[:] = [] ++ case = nose.case.MethodTestCase(TestClassSetupMethod.test_func) ++ case(res) ++ self.assertEqual(called, ['setup_method test_func', 'test', 'teardown_method test_func']) ++ + def test_function_test_case_fixtures(self): + from nose.tools import with_setup + res = unittest.TestResult() --- nose-0.10.4.orig/nose.egg-info/SOURCES.txt +++ nose-0.10.4/nose.egg-info/SOURCES.txt @@ -304,4 +304,4 @@ unit_tests/support/other/file.txt unit_tests/support/pkgorg/lib/modernity.py unit_tests/support/pkgorg/tests/test_mod.py -unit_tests/support/test-dir/test.py +unit_tests/support/test-dir/test.py \ No newline at end of file