-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Description
- a detailed description of the bug or problem you are having:
ExtendingProtocoland using it with mixin classes won't collect tests from mixins. - output of
pip listfrom the virtual environment you are using
attrs 22.1.0 Classes Without Boilerplate
iniconfig 1.1.1 iniconfig: brain-dead simple config-ini parsing
packaging 21.3 Core utilities for Python packages
pluggy 1.0.0 plugin and hook calling mechanisms for python
py 1.11.0 library with cross-python path, ini-parsing, io, code, log facilities
pyparsing 3.0.9 pyparsing module - Classes and methods to define and execute parsing grammars
pytest 7.1.3 pytest: simple powerful testing with Python
tomli 2.0.1 A lil' TOML parser- pytest and operating system versions:
pytest 7.1.2, ubuntu wayland 22.04, Python 3.10
- minimal example if possible:
File: test_foo.py
from typing import Protocol
class Proto(Protocol):
a: int = 2
b: int = 3
def parse(self) -> int:
...
class TestBase(Proto):
@classmethod
def add(cls, a, b):
return a + b
@classmethod
def subtract(cls, a, b):
return a - b
class SubtractTestCase(TestBase):
def parse(self) -> int:
return self.subtract(self.a, self.b)
class AddTestCase(TestBase):
def parse(self) -> int:
return self.add(self.a, self.b)
class OneTestMixin(Proto):
a = 3
b = 3
def test_parse(self):
assert self.parse() in (0, 6)
class TestOneAdd(AddTestCase, OneTestMixin):
...
class TestOneSubstract(SubtractTestCase, OneTestMixin):
...run py.test no test would be collected.
If you would omit Protocol from Proto everything will pass.
repo with the code:
https://github.com/nrbnlulu/pytest-protocol-issue
Metadata
Metadata
Assignees
Labels
No labels