Changeset 128
- Timestamp:
- Wed Nov 22 10:53:17 2006
- Files:
-
- trunk/unit_tests/test_tools.py (modified) (diff)
- trunk/nose/tools.py (modified) (diff)
- trunk/nose/loader.py (modified) (diff)
- trunk/nose/util.py (modified) (diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
trunk/unit_tests/test_tools.py
r127 r128 92 92 assert f2.teardown == 'teardown' 93 93 94 def test_nested_decorators(self): 95 from nose.tools import raises, timed, with_setup 96 97 def test(): 98 pass 99 100 def foo(): 101 pass 102 103 test = with_setup(foo, foo)(test) 104 test = timed(1.0)(test) 105 test = raises(TypeError)(test) 106 assert test.setup == foo 107 assert test.teardown == foo 108 109 def test_decorator_func_sorting(self): 110 from nose.tools import raises, timed, with_setup 111 from nose.util import func_lineno 112 113 def test1(): 114 pass 115 116 def test2(): 117 pass 118 119 def test3(): 120 pass 121 122 def foo(): 123 pass 124 125 test1_pos = func_lineno(test1) 126 test2_pos = func_lineno(test2) 127 test3_pos = func_lineno(test3) 128 129 test1 = raises(TypeError)(test1) 130 test2 = timed(1.0)(test2) 131 test3 = with_setup(foo)(test3) 132 133 self.assertEqual(func_lineno(test1), test1_pos) 134 self.assertEqual(func_lineno(test2), test2_pos) 135 self.assertEqual(func_lineno(test3), test3_pos) 136 94 137 def test_testcase_funcs(self): 95 138 import nose.tools -
trunk/nose/tools.py
r127 r128 63 63 newfunc.__module__ = func.__module__ 64 64 newfunc.__dict__ = func.__dict__ 65 if not hasattr(newfunc, 'compat_co_firstlineno'): 66 newfunc.compat_co_firstlineno = func.func_code.co_firstlineno 65 67 newfunc.__name__ = name 66 68 except TypeError: -
trunk/nose/loader.py
r121 r128 15 15 from nose.suite import LazySuite, TestClass, TestDir, TestModule, \ 16 16 GeneratorMethodTestSuite 17 from nose.util import is_generator, split_test_name, try_run 17 from nose.util import func_lineno, is_generator, split_test_name, try_run 17 17 18 18 log = logging.getLogger(__name__) … … 260 260 """ 261 261 try: 262 a_ln = a.func_code.co_firstlineno 263 b_ln = b.func_code.co_firstlineno 262 a_ln = func_lineno(a) 263 b_ln = func_lineno(b) 264 264 except AttributeError: 265 265 return 0 -
trunk/nose/util.py
r103 r128 75 75 76 76 77 def func_lineno(func): 78 """Get the line number of a function. First looks for 79 compat_co_firstlineno, then func_code.co_first_lineno. 80 """ 81 try: 82 return func.compat_co_firstlineno 83 except AttributeError: 84 return func.func_code.co_firstlineno 85 86 77 87 def is_generator(func): 78 88 try:
