-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
parameterized_class doesn't remove test methods from the base class's superclasses #119
Comments
I've run into this exact issue as well. I've currently worked around it by adding a @parameterized_class(...)
class FooTests(FooTestMethods, unittest.TestCase):
@classmethod
def setUpClass(cls):
if cls == FooTests:
raise unittest.SkipTest("`parameterized_class` bug")
super().setUpClass() |
Currently struggling with this as well. The workaround from @JohnnyDeuss has been helpful but I'd prefer a more generic solution. class FooTestMethods
@classmethod
def setUpClass(cls, parameterized_cls):
if cls is parameterized_cls:
raise SkipTest("skipping test for non-parameterized class")
@parameterized_class(...)
class FooTests(FooTestMethods, unittest.TestCase):
@classmethod
def setUpClass(cls):
super().setUpClass(FooTests) |
@wolever I think the cleanest way to solve this is to change the API of What do you think? Footnotes
|
I feel to fix the issue all-together, we have to duplicate (create with indices) not only the decorated class, but also all custom MRO classes. In this case we can easily remove the base classes and not have that patch with removing Currently: Transformed into:
Instead it should be transformed into:
In this case the chain is not common and we can manipulate with it. What do you think guys? I just do not know if it is possible to achieve this |
Extend the fix for wolever#73 to include inherited methods: copy all test methods from the original class into generated classes and set them to None in the original class. This ensures that the original class does not run by itself. Fixes wolever#119
Extend the fix for wolever#73 to include inherited methods: copy all test methods from the original class into generated classes and set them to None in the original class. This ensures that the original class does not run by itself. Fixes wolever#119
If I have a parameterized test class whose test methods are inherited:
Then it appears that while #73 attempts to remove all the test* methods from the base class
FooTests
that it leaves in the module, it doesn't remove them from the whole MRO hierarchy. Therefore, I'm left with aFooTests
object with test methods that will be discovered and run, but they might assume the parameterized values will be set, when they actually aren't.I'm not totally sure what to do about this, maybe the base class's test methods should all be replaced with a noop method?
The text was updated successfully, but these errors were encountered: