New submission from ivank <[email protected]>:
When using decorated tests:
{{{
#!python
from twisted.trial import unittest
print "Print works in this environment."
def a_decorator(fn):
print 'Decorating', fn
def newfunc(*args, **kwargs):
print "I am decorated."
fn(*args, **kwargs)
return newfunc
class TestA(unittest.TestCase):
def test_something(self):
self.assertEqual(1, 1)
test_something = a_decorator(test_something)
}}}
`trial decorated_test.TestA` works, but `trial decorated_test.TestA.test_something` does not:
{{{
# trial decorated_test.TestA.test_something
Print works in this environment.
Decorating <function test_something at 0x7f101729d5f0>
Traceback (most recent call last):
File "/usr/local/bin/trial", line 22, in <module>
run()
File "/opt/Python-latest/lib/python2.7/site-packages/twisted/scripts/trial.py", line 328, in run
suite = _getSuite(config)
File "/opt/Python-latest/lib/python2.7/site-packages/twisted/scripts/trial.py", line 286, in _getSuite
return loader.loadByNames(config['tests'], recurse)
File "/opt/Python-latest/lib/python2.7/site-packages/twisted/trial/runner.py", line 657, in loadByNames
for thing in set(things)]
File "/opt/Python-latest/lib/python2.7/site-packages/twisted/trial/runner.py", line 621, in loadAnything
return self.loadMethod(thing)
File "/opt/Python-latest/lib/python2.7/site-packages/twisted/trial/runner.py", line 524, in loadMethod
return self._makeCase(method.im_class, method.__name__)
File "/opt/Python-latest/lib/python2.7/site-packages/twisted/trial/runner.py", line 527, in _makeCase
return klass(methodName)
File "/opt/Python-latest/lib/python2.7/site-packages/twisted/trial/unittest.py", line 672, in __init__
super(TestCase, self).__init__(methodName)
File "/opt/Python-latest/lib/python2.7/unittest.py", line 363, in __init__
(self.__class__, methodName))
ValueError: no such test method in <class 'decorated_test.TestA'>: newfunc
}}}
----------
Type : enhancement
Component: trial
Keywords :
Priority : lowest
Nosy :
----------
http://twistedmatrix.com/trac/ticket/3909
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.