diff --git a/airbyte_cdk/connector_builder/connector_builder_handler.py b/airbyte_cdk/connector_builder/connector_builder_handler.py index 27929dfa2..6b6b31111 100644 --- a/airbyte_cdk/connector_builder/connector_builder_handler.py +++ b/airbyte_cdk/connector_builder/connector_builder_handler.py @@ -4,7 +4,7 @@ from dataclasses import asdict, dataclass, field -from typing import Any, Dict, List, Mapping +from typing import Any, ClassVar, Dict, List, Mapping from airbyte_cdk.connector_builder.test_reader import TestReader from airbyte_cdk.models import ( @@ -37,6 +37,8 @@ @dataclass class TestLimits: + __test__: ClassVar[bool] = False # Tell Pytest this is not a Pytest class, despite its name + max_records: int = field(default=DEFAULT_MAXIMUM_RECORDS) max_pages_per_slice: int = field(default=DEFAULT_MAXIMUM_NUMBER_OF_PAGES_PER_SLICE) max_slices: int = field(default=DEFAULT_MAXIMUM_NUMBER_OF_SLICES) diff --git a/airbyte_cdk/connector_builder/test_reader/reader.py b/airbyte_cdk/connector_builder/test_reader/reader.py index b776811eb..a125047b4 100644 --- a/airbyte_cdk/connector_builder/test_reader/reader.py +++ b/airbyte_cdk/connector_builder/test_reader/reader.py @@ -4,7 +4,7 @@ import logging -from typing import Any, Dict, Iterator, List, Mapping, Optional, Union +from typing import Any, ClassVar, Dict, Iterator, List, Mapping, Optional, Union from airbyte_cdk.connector_builder.models import ( AuxiliaryRequest, @@ -66,6 +66,8 @@ class TestReader: """ + __test__: ClassVar[bool] = False # Tell Pytest this is not a Pytest class, despite its name + logger = logging.getLogger("airbyte.connector-builder") def __init__( diff --git a/pytest.ini b/pytest.ini index 6a5cafc1f..d6b4b4683 100644 --- a/pytest.ini +++ b/pytest.ini @@ -5,3 +5,7 @@ log_cli_format = %(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno log_cli_date_format=%Y-%m-%d %H:%M:%S filterwarnings = ignore::airbyte_cdk.sources.source.ExperimentalClassWarning +markers = + slow: mark tests as slow + asyncio: mark test as asyncio + requires_creds: mark test as requiring credentials diff --git a/unit_tests/sources/declarative/decoders/test_composite_decoder.py b/unit_tests/sources/declarative/decoders/test_composite_decoder.py index 02c0993b6..cd0a562ae 100644 --- a/unit_tests/sources/declarative/decoders/test_composite_decoder.py +++ b/unit_tests/sources/declarative/decoders/test_composite_decoder.py @@ -8,7 +8,7 @@ from http.server import BaseHTTPRequestHandler, HTTPServer from io import BytesIO, StringIO from threading import Thread -from typing import Iterable +from typing import ClassVar, Iterable from unittest.mock import Mock, patch import pytest @@ -259,6 +259,8 @@ def test_composite_raw_decoder_csv_parser_values(requests_mock, encoding: str, d class TestServer(BaseHTTPRequestHandler): + __test__: ClassVar[bool] = False # Tell Pytest this is not a Pytest class, despite its name + def do_GET(self) -> None: self.send_response(200) self.end_headers() diff --git a/unit_tests/sources/declarative/parsers/testing_components.py b/unit_tests/sources/declarative/parsers/testing_components.py index 0d49e8627..ab9ae5346 100644 --- a/unit_tests/sources/declarative/parsers/testing_components.py +++ b/unit_tests/sources/declarative/parsers/testing_components.py @@ -3,7 +3,7 @@ # from dataclasses import dataclass, field -from typing import List, Optional +from typing import ClassVar, List, Optional from airbyte_cdk.sources.declarative.extractors import DpathExtractor from airbyte_cdk.sources.declarative.partition_routers import SubstreamPartitionRouter @@ -21,6 +21,8 @@ class TestingSomeComponent(DefaultErrorHandler): A basic test class with various field permutations used to test manifests with custom components """ + __test__: ClassVar[bool] = False # Tell Pytest this is not a Pytest class, despite its name + subcomponent_field_with_hint: DpathExtractor = field( default_factory=lambda: DpathExtractor(field_path=[], config={}, parameters={}) ) @@ -37,5 +39,7 @@ class TestingCustomSubstreamPartitionRouter(SubstreamPartitionRouter): A test class based on a SubstreamPartitionRouter used for testing manifests that use custom components. """ + __test__: ClassVar[bool] = False # Tell Pytest this is not a Pytest class, despite its name + custom_field: str custom_pagination_strategy: PaginationStrategy diff --git a/unit_tests/sources/declarative/test_yaml_declarative_source.py b/unit_tests/sources/declarative/test_yaml_declarative_source.py index 67f198eb2..846547eec 100644 --- a/unit_tests/sources/declarative/test_yaml_declarative_source.py +++ b/unit_tests/sources/declarative/test_yaml_declarative_source.py @@ -5,6 +5,7 @@ import logging import os import tempfile +from typing import ClassVar import pytest from yaml.parser import ParserError @@ -133,6 +134,8 @@ def test_source_with_missing_reference_fails(self): class TestFileContent: + __test__: ClassVar[bool] = False # Tell Pytest this is not a Pytest class, despite its name + def __init__(self, content): self.file = tempfile.NamedTemporaryFile(mode="w", delete=False) diff --git a/unit_tests/sources/file_based/scenarios/scenario_builder.py b/unit_tests/sources/file_based/scenarios/scenario_builder.py index da8c7ba87..93e8f952a 100644 --- a/unit_tests/sources/file_based/scenarios/scenario_builder.py +++ b/unit_tests/sources/file_based/scenarios/scenario_builder.py @@ -4,7 +4,7 @@ from abc import ABC, abstractmethod from copy import deepcopy from dataclasses import dataclass, field -from typing import Any, Generic, List, Mapping, Optional, Set, Tuple, Type, TypeVar +from typing import Any, ClassVar, Generic, List, Mapping, Optional, Set, Tuple, Type, TypeVar from airbyte_cdk.models import ( AirbyteAnalyticsTraceMessage, @@ -42,6 +42,8 @@ def build( class TestScenario(Generic[SourceType]): + __test__: ClassVar[bool] = False # Tell Pytest this is not a Pytest class, despite its name + def __init__( self, name: str, @@ -238,21 +240,21 @@ def build(self) -> "TestScenario[SourceType]": state, ) return TestScenario( - self._name, - self._config, - source, - self._expected_spec, - self._expected_check_status, - self._expected_catalog, - self._expected_logs, - self._expected_records, - self._expected_check_error, - self._expected_discover_error, - self._expected_read_error, - self._incremental_scenario_config, - self._expected_analytics, - self._log_levels, - self._catalog, + name=self._name, + config=self._config, + source=source, + expected_spec=self._expected_spec, + expected_check_status=self._expected_check_status, + expected_catalog=self._expected_catalog, + expected_logs=self._expected_logs, + expected_records=self._expected_records, + expected_check_error=self._expected_check_error, + expected_discover_error=self._expected_discover_error, + expected_read_error=self._expected_read_error, + incremental_scenario_config=self._incremental_scenario_config, + expected_analytics=self._expected_analytics, + log_levels=self._log_levels, + catalog=self._catalog, ) def _configured_catalog(self, sync_mode: SyncMode) -> Optional[Mapping[str, Any]]: diff --git a/unit_tests/sources/file_based/test_file_based_stream_reader.py b/unit_tests/sources/file_based/test_file_based_stream_reader.py index 4a9d4e349..ace2999e0 100644 --- a/unit_tests/sources/file_based/test_file_based_stream_reader.py +++ b/unit_tests/sources/file_based/test_file_based_stream_reader.py @@ -5,7 +5,7 @@ import logging from datetime import datetime from io import IOBase -from typing import Any, Dict, Iterable, List, Mapping, Optional, Set +from typing import Any, ClassVar, Dict, Iterable, List, Mapping, Optional, Set import pytest from pydantic.v1 import AnyUrl @@ -62,6 +62,8 @@ class TestStreamReader(AbstractFileBasedStreamReader): + __test__: ClassVar[bool] = False # Tell Pytest this is not a Pytest class, despite its name + @property def config(self) -> Optional[AbstractFileBasedSpec]: return self._config @@ -100,6 +102,10 @@ def identities_schema(self) -> Dict[str, Any]: class TestSpec(AbstractFileBasedSpec): + __test__: ClassVar[bool] = ( + False # Prevent pytest from thinking that this is a test class, despite the name + ) + @classmethod def documentation_url(cls) -> AnyUrl: return AnyUrl(scheme="https", url="https://docs.airbyte.com/integrations/sources/test") # type: ignore