Skip to content

Commit 12a4d10

Browse files
committed
fix(tests): fix test classes discovery warnings
Pytest checks all classes starting with 'Test' for unit/integration/all tests, but some classes start with Test but are not meant for pytest. Leaving 'Test' as the default classname for discovery is still needed though, since almost all unit tests are organized that way. Check https://docs.pytest.org/en/8.3.x/example/pythoncollection.html
1 parent da32f90 commit 12a4d10

File tree

5 files changed

+18
-0
lines changed

5 files changed

+18
-0
lines changed

backend/kernelCI_app/models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ class Meta:
137137

138138

139139
class Tests(models.Model):
140+
# Disables automatic pytest test discovery for this class
141+
__test__ = False
142+
140143
class UnitPrefix(models.TextChoices):
141144
METRIC = "metric"
142145
BINARY = "binary"

backend/kernelCI_app/tests/factories/test_factory.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
class TestFactory(DjangoModelFactory):
1414
"""Factory for creating Test instances with realistic test data."""
1515

16+
# Disables automatic pytest test discovery for this class
17+
__test__ = False
18+
1619
class Meta:
1720
model = Tests
1821

backend/kernelCI_app/typeModels/commonDetails.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828

2929

3030
class TestArchSummaryItem(BaseModel):
31+
# Disables automatic pytest test discovery for this class
32+
__test__ = False
33+
3134
arch: str
3235
compiler: str
3336
status: StatusCount
@@ -91,6 +94,9 @@ def to_dict(cls, value) -> Optional[dict]:
9194

9295

9396
class TestSummary(BaseModel):
97+
# Disables automatic pytest test discovery for this class
98+
__test__ = False
99+
94100
status: StatusCount
95101
origins: dict[str, StatusCount]
96102
architectures: list[TestArchSummaryItem]

backend/kernelCI_app/typeModels/testDetails.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ class TestStatusHistoryResponse(BaseModel):
8383

8484

8585
class TestStatusHistoryRequest(BaseModel):
86+
# Disables automatic pytest test discovery for this class
87+
__test__ = False
88+
8689
path: Annotated[str, Field(description=DocStrings.STATUS_HISTORY_PATH_DESCRIPTION)]
8790
origin: Annotated[
8891
str,

backend/kernelCI_app/typeModels/treeListing.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818

1919

2020
class TestStatusCount(BaseModel):
21+
# Disables automatic pytest test discovery for this class
22+
__test__ = False
23+
2124
pass_count: int = Field(alias="pass")
2225
error_count: int = Field(alias="error")
2326
fail_count: int = Field(alias="fail")

0 commit comments

Comments
 (0)