TestwithScenarios incompatible with nose 1.1.2
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
testscenarios |
Triaged
|
Low
|
Unassigned |
Bug Description
I tried using TestScenarios with nosetests by inheriting from TestWithScenarios.
According to the pypi entry: http://
"(which support these hooks like nose, trial, tribunal) will still run your scenarios. (Of course, if you are using the subclassing approach this is already a surety).".
It at least sounds like subclassing should be supported by all test runners that support the 'unittest' api.
However, nosetests fails with:
-------
Traceback (most recent call last):
File "C:\Python26\
self.
File "C:\Python26\
test(result)
AssertionError: ResultProxy for Test(<u1db.
It looks like the real object id() is changing. (not the test.id() but id(test)), and apparently nosetests decided that is not ok. Looking at nose.proxy.
def assertMyTest(self, test):
# The test I was called with must be my .test or my
# .test's .test. or my .test.test's .case
case = getattr(self.test, 'test', None)
assert (test is self.test
or test is case
or test is getattr(case, '_nose_case', None)), (
% (self.test, id(self.test), test, id(test)))
I don't know why it requires that, but it seems that the way TestScenarios is multiplying its tests during run and then passing the results to the ResultProxy object is forbidden by nose. I tried hacking testtools to set new.test = orig_test or .case or, etc. But it looks like you have to set orig_test.test = new_test. And that doesn't make much sense in the general case, since one test will get farmed out to N scenario tests.
For now, I've just switched from "nosetests" to "python -m testtools.run discover". But it does seem like the two codebases need to find a way to get along :).
You need to multiply_scenarios before nose sees the tests, because nose makes untrue assumptions about the unittest protocol.