Skip to content

Commit a42ad33

Browse files
chore: fix pytest warnings from dataclasses starting with Test (#477)
Co-authored-by: Aaron Steers <aj@airbyte.io> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent 289705d commit a42ad33

File tree

8 files changed

+46
-21
lines changed

8 files changed

+46
-21
lines changed

airbyte_cdk/connector_builder/connector_builder_handler.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
from dataclasses import asdict, dataclass, field
7-
from typing import Any, Dict, List, Mapping
7+
from typing import Any, ClassVar, Dict, List, Mapping
88

99
from airbyte_cdk.connector_builder.test_reader import TestReader
1010
from airbyte_cdk.models import (
@@ -37,6 +37,8 @@
3737

3838
@dataclass
3939
class TestLimits:
40+
__test__: ClassVar[bool] = False # Tell Pytest this is not a Pytest class, despite its name
41+
4042
max_records: int = field(default=DEFAULT_MAXIMUM_RECORDS)
4143
max_pages_per_slice: int = field(default=DEFAULT_MAXIMUM_NUMBER_OF_PAGES_PER_SLICE)
4244
max_slices: int = field(default=DEFAULT_MAXIMUM_NUMBER_OF_SLICES)

airbyte_cdk/connector_builder/test_reader/reader.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
import logging
7-
from typing import Any, Dict, Iterator, List, Mapping, Optional, Union
7+
from typing import Any, ClassVar, Dict, Iterator, List, Mapping, Optional, Union
88

99
from airbyte_cdk.connector_builder.models import (
1010
AuxiliaryRequest,
@@ -66,6 +66,8 @@ class TestReader:
6666
6767
"""
6868

69+
__test__: ClassVar[bool] = False # Tell Pytest this is not a Pytest class, despite its name
70+
6971
logger = logging.getLogger("airbyte.connector-builder")
7072

7173
def __init__(

pytest.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@ log_cli_format = %(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno
55
log_cli_date_format=%Y-%m-%d %H:%M:%S
66
filterwarnings =
77
ignore::airbyte_cdk.sources.source.ExperimentalClassWarning
8+
markers =
9+
slow: mark tests as slow
10+
asyncio: mark test as asyncio
11+
requires_creds: mark test as requiring credentials

unit_tests/sources/declarative/decoders/test_composite_decoder.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from http.server import BaseHTTPRequestHandler, HTTPServer
99
from io import BytesIO, StringIO
1010
from threading import Thread
11-
from typing import Iterable
11+
from typing import ClassVar, Iterable
1212
from unittest.mock import Mock, patch
1313

1414
import pytest
@@ -259,6 +259,8 @@ def test_composite_raw_decoder_csv_parser_values(requests_mock, encoding: str, d
259259

260260

261261
class TestServer(BaseHTTPRequestHandler):
262+
__test__: ClassVar[bool] = False # Tell Pytest this is not a Pytest class, despite its name
263+
262264
def do_GET(self) -> None:
263265
self.send_response(200)
264266
self.end_headers()

unit_tests/sources/declarative/parsers/testing_components.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44

55
from dataclasses import dataclass, field
6-
from typing import List, Optional
6+
from typing import ClassVar, List, Optional
77

88
from airbyte_cdk.sources.declarative.extractors import DpathExtractor
99
from airbyte_cdk.sources.declarative.partition_routers import SubstreamPartitionRouter
@@ -21,6 +21,8 @@ class TestingSomeComponent(DefaultErrorHandler):
2121
A basic test class with various field permutations used to test manifests with custom components
2222
"""
2323

24+
__test__: ClassVar[bool] = False # Tell Pytest this is not a Pytest class, despite its name
25+
2426
subcomponent_field_with_hint: DpathExtractor = field(
2527
default_factory=lambda: DpathExtractor(field_path=[], config={}, parameters={})
2628
)
@@ -37,5 +39,7 @@ class TestingCustomSubstreamPartitionRouter(SubstreamPartitionRouter):
3739
A test class based on a SubstreamPartitionRouter used for testing manifests that use custom components.
3840
"""
3941

42+
__test__: ClassVar[bool] = False # Tell Pytest this is not a Pytest class, despite its name
43+
4044
custom_field: str
4145
custom_pagination_strategy: PaginationStrategy

unit_tests/sources/declarative/test_yaml_declarative_source.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import logging
66
import os
77
import tempfile
8+
from typing import ClassVar
89

910
import pytest
1011
from yaml.parser import ParserError
@@ -133,6 +134,8 @@ def test_source_with_missing_reference_fails(self):
133134

134135

135136
class TestFileContent:
137+
__test__: ClassVar[bool] = False # Tell Pytest this is not a Pytest class, despite its name
138+
136139
def __init__(self, content):
137140
self.file = tempfile.NamedTemporaryFile(mode="w", delete=False)
138141

unit_tests/sources/file_based/scenarios/scenario_builder.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from abc import ABC, abstractmethod
55
from copy import deepcopy
66
from dataclasses import dataclass, field
7-
from typing import Any, Generic, List, Mapping, Optional, Set, Tuple, Type, TypeVar
7+
from typing import Any, ClassVar, Generic, List, Mapping, Optional, Set, Tuple, Type, TypeVar
88

99
from airbyte_cdk.models import (
1010
AirbyteAnalyticsTraceMessage,
@@ -42,6 +42,8 @@ def build(
4242

4343

4444
class TestScenario(Generic[SourceType]):
45+
__test__: ClassVar[bool] = False # Tell Pytest this is not a Pytest class, despite its name
46+
4547
def __init__(
4648
self,
4749
name: str,
@@ -238,21 +240,21 @@ def build(self) -> "TestScenario[SourceType]":
238240
state,
239241
)
240242
return TestScenario(
241-
self._name,
242-
self._config,
243-
source,
244-
self._expected_spec,
245-
self._expected_check_status,
246-
self._expected_catalog,
247-
self._expected_logs,
248-
self._expected_records,
249-
self._expected_check_error,
250-
self._expected_discover_error,
251-
self._expected_read_error,
252-
self._incremental_scenario_config,
253-
self._expected_analytics,
254-
self._log_levels,
255-
self._catalog,
243+
name=self._name,
244+
config=self._config,
245+
source=source,
246+
expected_spec=self._expected_spec,
247+
expected_check_status=self._expected_check_status,
248+
expected_catalog=self._expected_catalog,
249+
expected_logs=self._expected_logs,
250+
expected_records=self._expected_records,
251+
expected_check_error=self._expected_check_error,
252+
expected_discover_error=self._expected_discover_error,
253+
expected_read_error=self._expected_read_error,
254+
incremental_scenario_config=self._incremental_scenario_config,
255+
expected_analytics=self._expected_analytics,
256+
log_levels=self._log_levels,
257+
catalog=self._catalog,
256258
)
257259

258260
def _configured_catalog(self, sync_mode: SyncMode) -> Optional[Mapping[str, Any]]:

unit_tests/sources/file_based/test_file_based_stream_reader.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import logging
66
from datetime import datetime
77
from io import IOBase
8-
from typing import Any, Dict, Iterable, List, Mapping, Optional, Set
8+
from typing import Any, ClassVar, Dict, Iterable, List, Mapping, Optional, Set
99

1010
import pytest
1111
from pydantic.v1 import AnyUrl
@@ -62,6 +62,8 @@
6262

6363

6464
class TestStreamReader(AbstractFileBasedStreamReader):
65+
__test__: ClassVar[bool] = False # Tell Pytest this is not a Pytest class, despite its name
66+
6567
@property
6668
def config(self) -> Optional[AbstractFileBasedSpec]:
6769
return self._config
@@ -100,6 +102,10 @@ def identities_schema(self) -> Dict[str, Any]:
100102

101103

102104
class TestSpec(AbstractFileBasedSpec):
105+
__test__: ClassVar[bool] = (
106+
False # Prevent pytest from thinking that this is a test class, despite the name
107+
)
108+
103109
@classmethod
104110
def documentation_url(cls) -> AnyUrl:
105111
return AnyUrl(scheme="https", url="https://docs.airbyte.com/integrations/sources/test") # type: ignore

0 commit comments

Comments
 (0)