diff --git a/active_directory/tests/test_active_directory.py b/active_directory/tests/test_active_directory.py deleted file mode 100644 index 4db327b084fbc..0000000000000 --- a/active_directory/tests/test_active_directory.py +++ /dev/null @@ -1,34 +0,0 @@ -# (C) Datadog, Inc. 2010-present -# All rights reserved -# Licensed under Simplified BSD License (see LICENSE) -import pytest -from datadog_test_libs.win.pdh_mocks import initialize_pdh_tests, pdh_mocks_fixture # noqa: F401 - -from datadog_checks.active_directory import ActiveDirectoryCheck -from datadog_checks.active_directory.metrics import DEFAULT_COUNTERS -from datadog_checks.base.stubs.aggregator import AggregatorStub # noqa: F401 -from datadog_checks.dev.testing import requires_py2 -from datadog_checks.dev.utils import get_metadata_metrics - -from .common import CHECK_NAME, MINIMAL_INSTANCE - -pytestmark = [requires_py2, pytest.mark.usefixtures('pdh_mocks_fixture')] - - -@pytest.fixture(autouse=True) -def setup_check(): - initialize_pdh_tests() - - -def test_basic_check(aggregator, dd_run_check): - # type: (AggregatorStub) -> None - instance = MINIMAL_INSTANCE - check = ActiveDirectoryCheck(CHECK_NAME, {}, [instance]) - dd_run_check(check) - - for metric_def in DEFAULT_COUNTERS: - metric = metric_def[3] - aggregator.assert_metric(metric, tags=None, count=1) - - aggregator.assert_all_metrics_covered() - aggregator.assert_metrics_using_metadata(get_metadata_metrics()) diff --git a/active_directory/tests/test_unit.py b/active_directory/tests/test_unit.py index 66351740a51af..97aad334c3805 100644 --- a/active_directory/tests/test_unit.py +++ b/active_directory/tests/test_unit.py @@ -4,13 +4,10 @@ from datadog_checks.active_directory import ActiveDirectoryCheck from datadog_checks.active_directory.metrics import DEFAULT_COUNTERS from datadog_checks.base.constants import ServiceCheck -from datadog_checks.dev.testing import requires_py3 from datadog_checks.dev.utils import get_metadata_metrics from .common import PERFORMANCE_OBJECTS -pytestmark = [requires_py3] - def test(aggregator, dd_default_hostname, dd_run_check, mock_performance_objects): mock_performance_objects(PERFORMANCE_OBJECTS) diff --git a/aerospike/tests/test_aerospike.py b/aerospike/tests/test_aerospike.py index b10878bbd7916..ecd3a0a688e4a 100644 --- a/aerospike/tests/test_aerospike.py +++ b/aerospike/tests/test_aerospike.py @@ -8,7 +8,6 @@ from datadog_checks.aerospike import AerospikeCheck from datadog_checks.base import AgentCheck -from datadog_checks.dev.testing import requires_py3 from datadog_checks.dev.utils import get_metadata_metrics from .common import ( @@ -70,7 +69,6 @@ def test_e2e(dd_agent_check, instance): aggregator.assert_metrics_using_metadata(get_metadata_metrics()) -@requires_py3 @pytest.mark.e2e def test_openmetrics_e2e(dd_agent_check, instance_openmetrics_v2): version_parts = [int(p) for p in VERSION.split('.')] @@ -93,7 +91,6 @@ def test_openmetrics_e2e(dd_agent_check, instance_openmetrics_v2): aggregator.assert_metrics_using_metadata(get_metadata_metrics(), check_submission_type=True) -@requires_py3 @pytest.mark.integration def test_metrics_warning(dd_run_check, instance_openmetrics_v2): instance_openmetrics_v2['metrics'] = ['migrate_rx_objs', 'migrate_tx_objs'] diff --git a/aerospike/tests/test_unit_openmetricsv2.py b/aerospike/tests/test_unit_openmetricsv2.py index f12312b46ba2c..d82f4607ff7d8 100644 --- a/aerospike/tests/test_unit_openmetricsv2.py +++ b/aerospike/tests/test_unit_openmetricsv2.py @@ -6,12 +6,11 @@ import pytest from datadog_checks.aerospike import AerospikeCheck -from datadog_checks.dev.testing import requires_py3 from datadog_checks.dev.utils import get_metadata_metrics from .common import EXPECTED_PROMETHEUS_METRICS, EXPECTED_PROMETHEUS_METRICS_5_6, HERE, PROMETHEUS_XDR_METRICS -pytestmark = [pytest.mark.unit, requires_py3] +pytestmark = [pytest.mark.unit] def get_fixture_path(filename): diff --git a/aspdotnet/tests/test_unit.py b/aspdotnet/tests/test_unit.py index c660f6efe6d20..af6dcb44eb89e 100644 --- a/aspdotnet/tests/test_unit.py +++ b/aspdotnet/tests/test_unit.py @@ -3,13 +3,10 @@ # Licensed under a 3-clause BSD style license (see LICENSE) from datadog_checks.aspdotnet import AspdotnetCheck from datadog_checks.base.constants import ServiceCheck -from datadog_checks.dev.testing import requires_py3 from datadog_checks.dev.utils import get_metadata_metrics from .common import ASP_APP_INSTANCES, ASP_APP_METRICS, ASP_METRICS, PERFORMANCE_OBJECTS -pytestmark = [requires_py3] - def test(aggregator, dd_default_hostname, dd_run_check, mock_performance_objects): mock_performance_objects(PERFORMANCE_OBJECTS) diff --git a/cockroachdb/tests/test_bench.py b/cockroachdb/tests/test_bench.py index f975b198ff7a5..da082936da0de 100644 --- a/cockroachdb/tests/test_bench.py +++ b/cockroachdb/tests/test_bench.py @@ -4,9 +4,8 @@ import pytest from datadog_checks.cockroachdb import CockroachdbCheck -from datadog_checks.dev.testing import requires_py3 -pytestmark = [pytest.mark.usefixtures('dd_environment'), requires_py3] +pytestmark = [pytest.mark.usefixtures('dd_environment')] def test_run(benchmark, dd_run_check, instance): diff --git a/cockroachdb/tests/test_e2e.py b/cockroachdb/tests/test_e2e.py index 9f2c7689b6c1d..480b8c226a1df 100644 --- a/cockroachdb/tests/test_e2e.py +++ b/cockroachdb/tests/test_e2e.py @@ -1,12 +1,10 @@ # (C) Datadog, Inc. 2021-present # All rights reserved # Licensed under a 3-clause BSD style license (see LICENSE) -from datadog_checks.dev.testing import requires_py3 from .common import assert_metrics -@requires_py3 def test_metrics(dd_agent_check, instance): aggregator = dd_agent_check(instance, rate=True) assert_metrics(aggregator) diff --git a/cockroachdb/tests/test_integration.py b/cockroachdb/tests/test_integration.py index ec75d2f2e7e28..cd018dcfa8254 100644 --- a/cockroachdb/tests/test_integration.py +++ b/cockroachdb/tests/test_integration.py @@ -5,12 +5,11 @@ from datadog_checks.base.constants import ServiceCheck from datadog_checks.cockroachdb import CockroachdbCheck -from datadog_checks.dev.testing import requires_py3 from datadog_checks.dev.utils import assert_service_checks, get_metadata_metrics from .common import COCKROACHDB_VERSION, assert_metrics -pytestmark = [pytest.mark.usefixtures('dd_environment'), requires_py3] +pytestmark = [pytest.mark.usefixtures('dd_environment')] def test_metrics(aggregator, instance, dd_run_check): diff --git a/cockroachdb/tests/test_unit.py b/cockroachdb/tests/test_unit.py index bb87ed749ebc6..88d3ea262017d 100644 --- a/cockroachdb/tests/test_unit.py +++ b/cockroachdb/tests/test_unit.py @@ -6,7 +6,6 @@ from datadog_checks.base.constants import ServiceCheck from datadog_checks.cockroachdb import CockroachdbCheck from datadog_checks.cockroachdb.metrics import METRIC_MAP, OMV2_METRIC_MAP -from datadog_checks.dev.testing import requires_py3 from datadog_checks.dev.utils import assert_service_checks, get_metadata_metrics from .common import ( @@ -23,8 +22,6 @@ get_fixture_path, ) -pytestmark = [requires_py3] - # The test below is designed to collect metrics that are not exposed in our e2e environment. # To collect security metrics, we need to enable TLS and provide certificates. In the future, diff --git a/datadog_checks_base/tests/base/checks/logs/crawler/test_base.py b/datadog_checks_base/tests/base/checks/logs/crawler/test_base.py index cc7a6aabfc740..504cdeb906b38 100644 --- a/datadog_checks_base/tests/base/checks/logs/crawler/test_base.py +++ b/datadog_checks_base/tests/base/checks/logs/crawler/test_base.py @@ -1,9 +1,6 @@ # (C) Datadog, Inc. 2024-present # All rights reserved # Licensed under a 3-clause BSD style license (see LICENSE) -from datadog_checks.dev.testing import requires_py3 - -pytestmark = [requires_py3] # TODO: Remove lazy imports and `.format` calls when we drop support for Python 2 diff --git a/datadog_checks_base/tests/base/checks/openmetrics/test_legacy/test_bench.py b/datadog_checks_base/tests/base/checks/openmetrics/test_legacy/test_bench.py index 73ca9e423c233..c540f7d47d8e7 100644 --- a/datadog_checks_base/tests/base/checks/openmetrics/test_legacy/test_bench.py +++ b/datadog_checks_base/tests/base/checks/openmetrics/test_legacy/test_bench.py @@ -7,12 +7,9 @@ from datadog_checks.base import OpenMetricsBaseCheck from datadog_checks.dev import get_here -from datadog_checks.dev.testing import requires_py3 from ..bench_utils import AMAZON_MSK_JMX_METRICS_MAP, AMAZON_MSK_JMX_METRICS_OVERRIDES -pytestmark = [requires_py3] - HERE = get_here() FIXTURE_PATH = os.path.abspath(os.path.join(os.path.dirname(HERE), '..', '..', '..', 'fixtures', 'prometheus')) diff --git a/datadog_checks_base/tests/base/checks/openmetrics/test_legacy/test_compat_scraper.py b/datadog_checks_base/tests/base/checks/openmetrics/test_legacy/test_compat_scraper.py index c5ade8a74c461..b053495cb8f25 100644 --- a/datadog_checks_base/tests/base/checks/openmetrics/test_legacy/test_compat_scraper.py +++ b/datadog_checks_base/tests/base/checks/openmetrics/test_legacy/test_compat_scraper.py @@ -3,12 +3,8 @@ # Licensed under a 3-clause BSD style license (see LICENSE) import pytest -from datadog_checks.dev.testing import requires_py3 - from .utils import get_legacy_check -pytestmark = [requires_py3] - class TestRawMetricPrefix: def test_not_string(self, dd_run_check): diff --git a/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_bench.py b/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_bench.py index e1c03e0ac08fc..678651f28f5ce 100644 --- a/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_bench.py +++ b/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_bench.py @@ -7,12 +7,9 @@ from datadog_checks.base import OpenMetricsBaseCheckV2 from datadog_checks.dev import get_here -from datadog_checks.dev.testing import requires_py3 from ..bench_utils import AMAZON_MSK_JMX_METRICS_MAP, AMAZON_MSK_JMX_METRICS_OVERRIDES -pytestmark = [requires_py3] - HERE = get_here() FIXTURE_PATH = os.path.abspath(os.path.join(os.path.dirname(HERE), '..', '..', '..', 'fixtures', 'prometheus')) diff --git a/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_config.py b/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_config.py index 029d7757c2454..0f3f6b7812e68 100644 --- a/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_config.py +++ b/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_config.py @@ -3,12 +3,8 @@ # Licensed under a 3-clause BSD style license (see LICENSE) import pytest -from datadog_checks.dev.testing import requires_py3 - from .utils import get_check -pytestmark = [requires_py3] - class TestPrometheusEndpoint: def test_not_string(self, dd_run_check): diff --git a/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_first_scrape_handler.py b/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_first_scrape_handler.py index 059fe10591942..1a710a8243bf9 100644 --- a/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_first_scrape_handler.py +++ b/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_first_scrape_handler.py @@ -4,13 +4,9 @@ import pytest from datadog_checks.base.stubs import datadog_agent -from datadog_checks.dev.testing import requires_py3 from .utils import get_check -pytestmark = [requires_py3] - - test_use_process_start_time_data = """\ # HELP go_memstats_alloc_bytes_total Total number of bytes allocated, even if freed. # TYPE go_memstats_alloc_bytes_total counter diff --git a/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_interface.py b/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_interface.py index 2e9ff176bd35d..d6071cf0226e5 100644 --- a/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_interface.py +++ b/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_interface.py @@ -3,12 +3,9 @@ # Licensed under a 3-clause BSD style license (see LICENSE) from datadog_checks.base import OpenMetricsBaseCheckV2 from datadog_checks.base.constants import ServiceCheck -from datadog_checks.dev.testing import requires_py3 from .utils import get_check -pytestmark = [requires_py3] - def test_default_config(aggregator, dd_run_check, mock_http_response): class Check(OpenMetricsBaseCheckV2): diff --git a/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_options.py b/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_options.py index 597aeda01a1b3..6ac560760069e 100644 --- a/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_options.py +++ b/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_options.py @@ -5,12 +5,9 @@ from mock import Mock from datadog_checks.base.constants import ServiceCheck -from datadog_checks.dev.testing import requires_py3 from .utils import get_check -pytestmark = [requires_py3] - class TestNamespace: def test(self, aggregator, dd_run_check, mock_http_response): diff --git a/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_counter.py b/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_counter.py index 714f882d7d274..922ee631c6304 100644 --- a/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_counter.py +++ b/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_counter.py @@ -1,14 +1,9 @@ # (C) Datadog, Inc. 2020-present # All rights reserved # Licensed under a 3-clause BSD style license (see LICENSE) -from datadog_checks.dev.testing import requires_py3 from ..utils import get_check -pytestmark = [ - requires_py3, -] - def test_basic(aggregator, dd_run_check, mock_http_response): """ diff --git a/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_counter_gauge.py b/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_counter_gauge.py index e78ffe785a5cb..ae1a6a36203b8 100644 --- a/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_counter_gauge.py +++ b/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_counter_gauge.py @@ -1,14 +1,9 @@ # (C) Datadog, Inc. 2020-present # All rights reserved # Licensed under a 3-clause BSD style license (see LICENSE) -from datadog_checks.dev.testing import requires_py3 from ..utils import get_check -pytestmark = [ - requires_py3, -] - def test(aggregator, dd_run_check, mock_http_response): mock_http_response( diff --git a/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_gauge.py b/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_gauge.py index a6e9abeadb1e8..bf0398e5d5347 100644 --- a/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_gauge.py +++ b/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_gauge.py @@ -1,14 +1,9 @@ # (C) Datadog, Inc. 2020-present # All rights reserved # Licensed under a 3-clause BSD style license (see LICENSE) -from datadog_checks.dev.testing import requires_py3 from ..utils import get_check -pytestmark = [ - requires_py3, -] - def test_basic(aggregator, dd_run_check, mock_http_response): mock_http_response( diff --git a/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_histogram.py b/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_histogram.py index 38785892e6c90..fc0bfd0ff76a7 100644 --- a/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_histogram.py +++ b/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_histogram.py @@ -1,14 +1,9 @@ # (C) Datadog, Inc. 2020-present # All rights reserved # Licensed under a 3-clause BSD style license (see LICENSE) -from datadog_checks.dev.testing import requires_py3 from ..utils import get_check -pytestmark = [ - requires_py3, -] - def assert_metric_counts(aggregator, payload): num_bucket_metrics = 0 diff --git a/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_metadata.py b/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_metadata.py index b18a9971a6d43..de5228d6ec77b 100644 --- a/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_metadata.py +++ b/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_metadata.py @@ -1,14 +1,9 @@ # (C) Datadog, Inc. 2020-present # All rights reserved # Licensed under a 3-clause BSD style license (see LICENSE) -from datadog_checks.dev.testing import requires_py3 from ..utils import get_check -pytestmark = [ - requires_py3, -] - def test_basic(aggregator, datadog_agent, dd_run_check, mock_http_response): mock_http_response( diff --git a/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_native_dynamic.py b/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_native_dynamic.py index cc3e34b668f05..3ef2462a8a6d5 100644 --- a/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_native_dynamic.py +++ b/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_native_dynamic.py @@ -1,14 +1,9 @@ # (C) Datadog, Inc. 2021-present # All rights reserved # Licensed under a 3-clause BSD style license (see LICENSE) -from datadog_checks.dev.testing import requires_py3 from ..utils import get_check -pytestmark = [ - requires_py3, -] - def test_basic(aggregator, dd_run_check, mock_http_response): mock_http_response( diff --git a/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_rate.py b/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_rate.py index dc253f82bcb69..d5912078a05a6 100644 --- a/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_rate.py +++ b/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_rate.py @@ -1,14 +1,9 @@ # (C) Datadog, Inc. 2020-present # All rights reserved # Licensed under a 3-clause BSD style license (see LICENSE) -from datadog_checks.dev.testing import requires_py3 from ..utils import get_check -pytestmark = [ - requires_py3, -] - def test(aggregator, dd_run_check, mock_http_response): mock_http_response( diff --git a/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_service_check.py b/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_service_check.py index 51d15ee69965c..d1764ac84d423 100644 --- a/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_service_check.py +++ b/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_service_check.py @@ -2,14 +2,9 @@ # All rights reserved # Licensed under a 3-clause BSD style license (see LICENSE) from datadog_checks.base.constants import ServiceCheck -from datadog_checks.dev.testing import requires_py3 from ..utils import get_check -pytestmark = [ - requires_py3, -] - def test_known(aggregator, dd_run_check, mock_http_response): mock_http_response( diff --git a/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_summary.py b/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_summary.py index 2a941c065a50b..37e5b79ebae2c 100644 --- a/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_summary.py +++ b/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_summary.py @@ -1,14 +1,9 @@ # (C) Datadog, Inc. 2020-present # All rights reserved # Licensed under a 3-clause BSD style license (see LICENSE) -from datadog_checks.dev.testing import requires_py3 from ..utils import get_check -pytestmark = [ - requires_py3, -] - def assert_metric_counts(aggregator, payload): num_quantile_metrics = 0 diff --git a/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_temporal_percent.py b/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_temporal_percent.py index 49eeeb6ca3841..23140edb50b29 100644 --- a/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_temporal_percent.py +++ b/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_temporal_percent.py @@ -1,14 +1,9 @@ # (C) Datadog, Inc. 2020-present # All rights reserved # Licensed under a 3-clause BSD style license (see LICENSE) -from datadog_checks.dev.testing import requires_py3 from ..utils import get_check -pytestmark = [ - requires_py3, -] - def test_named(aggregator, dd_run_check, mock_http_response): mock_http_response( diff --git a/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_time_elapsed.py b/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_time_elapsed.py index 4366fb51c0f85..f23c446eaa229 100644 --- a/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_time_elapsed.py +++ b/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_time_elapsed.py @@ -2,14 +2,9 @@ # All rights reserved # Licensed under a 3-clause BSD style license (see LICENSE) from datadog_checks.base.utils.time import get_timestamp -from datadog_checks.dev.testing import requires_py3 from ..utils import get_check -pytestmark = [ - requires_py3, -] - def test(aggregator, dd_run_check, mock_http_response): mock_http_response( diff --git a/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_type_override.py b/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_type_override.py index ca79de6b0e176..a1fa39e6bfedc 100644 --- a/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_type_override.py +++ b/datadog_checks_base/tests/base/checks/openmetrics/test_v2/test_transformers/test_type_override.py @@ -3,12 +3,8 @@ # Licensed under a 3-clause BSD style license (see LICENSE) import pytest -from datadog_checks.dev.testing import requires_py3 - from ..utils import get_check -pytestmark = [requires_py3] - @pytest.mark.parametrize( 'metric_type', diff --git a/datadog_checks_base/tests/base/checks/test_agent_check.py b/datadog_checks_base/tests/base/checks/test_agent_check.py index 244a041582b26..aa478ceca3e17 100644 --- a/datadog_checks_base/tests/base/checks/test_agent_check.py +++ b/datadog_checks_base/tests/base/checks/test_agent_check.py @@ -13,7 +13,6 @@ from datadog_checks.base import AgentCheck, to_native_string from datadog_checks.base import __version__ as base_package_version -from datadog_checks.dev.testing import requires_py3 def test_instance(): @@ -1068,7 +1067,6 @@ def check(self, _): assert check.initialize.call_count == 2 -@requires_py3 def test_load_configuration_models(dd_run_check, mocker): instance = {'endpoint': 'url', 'tags': ['foo:bar'], 'proxy': {'http': 'http://1.2.3.4:9000'}} init_config = {'proxy': {'https': 'https://1.2.3.4:4242'}} @@ -1111,7 +1109,6 @@ def __init__(self, **kwargs): pass -@requires_py3 @pytest.mark.parametrize( "check_instance_config, default_instance_config, log_lines, unknown_options", [ diff --git a/datadog_checks_base/tests/base/checks/windows/perf_counters/test_aggregation.py b/datadog_checks_base/tests/base/checks/windows/perf_counters/test_aggregation.py index 9e8731b030593..d9967d61fef73 100644 --- a/datadog_checks_base/tests/base/checks/windows/perf_counters/test_aggregation.py +++ b/datadog_checks_base/tests/base/checks/windows/perf_counters/test_aggregation.py @@ -1,11 +1,11 @@ # (C) Datadog, Inc. 2021-present # All rights reserved # Licensed under a 3-clause BSD style license (see LICENSE) -from datadog_checks.dev.testing import requires_py3, requires_windows +from datadog_checks.dev.testing import requires_windows from .utils import GLOBAL_TAGS, get_check -pytestmark = [requires_py3, requires_windows] +pytestmark = [requires_windows] def test_single_instance(aggregator, dd_run_check, mock_performance_objects): diff --git a/datadog_checks_base/tests/base/checks/windows/perf_counters/test_config.py b/datadog_checks_base/tests/base/checks/windows/perf_counters/test_config.py index 3344b237efe41..d03346346b373 100644 --- a/datadog_checks_base/tests/base/checks/windows/perf_counters/test_config.py +++ b/datadog_checks_base/tests/base/checks/windows/perf_counters/test_config.py @@ -5,11 +5,11 @@ import pytest -from datadog_checks.dev.testing import requires_py3, requires_windows +from datadog_checks.dev.testing import requires_windows from .utils import get_check -pytestmark = [requires_py3, requires_windows] +pytestmark = [requires_windows] @pytest.fixture(autouse=True) diff --git a/datadog_checks_base/tests/base/checks/windows/perf_counters/test_filter.py b/datadog_checks_base/tests/base/checks/windows/perf_counters/test_filter.py index 71939b239bee7..443d3fdbee576 100644 --- a/datadog_checks_base/tests/base/checks/windows/perf_counters/test_filter.py +++ b/datadog_checks_base/tests/base/checks/windows/perf_counters/test_filter.py @@ -1,11 +1,11 @@ # (C) Datadog, Inc. 2021-present # All rights reserved # Licensed under a 3-clause BSD style license (see LICENSE) -from datadog_checks.dev.testing import requires_py3, requires_windows +from datadog_checks.dev.testing import requires_windows from .utils import GLOBAL_TAGS, get_check -pytestmark = [requires_py3, requires_windows] +pytestmark = [requires_windows] def test_include(aggregator, dd_run_check, mock_performance_objects): diff --git a/datadog_checks_base/tests/base/checks/windows/perf_counters/test_health.py b/datadog_checks_base/tests/base/checks/windows/perf_counters/test_health.py index 8d619380498e0..90d9764224a69 100644 --- a/datadog_checks_base/tests/base/checks/windows/perf_counters/test_health.py +++ b/datadog_checks_base/tests/base/checks/windows/perf_counters/test_health.py @@ -4,11 +4,11 @@ import logging from datadog_checks.base.constants import ServiceCheck -from datadog_checks.dev.testing import requires_py3, requires_windows +from datadog_checks.dev.testing import requires_windows from .utils import GLOBAL_TAGS, get_check -pytestmark = [requires_py3, requires_windows] +pytestmark = [requires_windows] def test_disable(aggregator, dd_run_check, mock_performance_objects): diff --git a/datadog_checks_base/tests/base/checks/windows/perf_counters/test_integration.py b/datadog_checks_base/tests/base/checks/windows/perf_counters/test_integration.py index 34a589f04c5c2..35b6ada26b9d2 100644 --- a/datadog_checks_base/tests/base/checks/windows/perf_counters/test_integration.py +++ b/datadog_checks_base/tests/base/checks/windows/perf_counters/test_integration.py @@ -6,11 +6,11 @@ import mock from datadog_checks.base.constants import ServiceCheck -from datadog_checks.dev.testing import requires_py3, requires_windows +from datadog_checks.dev.testing import requires_windows from .utils import SERVER, get_check -pytestmark = [requires_py3, requires_windows] +pytestmark = [requires_windows] def test(aggregator, dd_run_check): diff --git a/datadog_checks_base/tests/base/checks/windows/perf_counters/test_legacy_support.py b/datadog_checks_base/tests/base/checks/windows/perf_counters/test_legacy_support.py index 1c8a96c36cf90..69b186d047ed9 100644 --- a/datadog_checks_base/tests/base/checks/windows/perf_counters/test_legacy_support.py +++ b/datadog_checks_base/tests/base/checks/windows/perf_counters/test_legacy_support.py @@ -4,7 +4,7 @@ import logging from datadog_checks.base.constants import ServiceCheck -from datadog_checks.dev.testing import requires_py3, requires_windows +from datadog_checks.dev.testing import requires_windows from .utils import GLOBAL_TAGS, SERVER @@ -14,7 +14,7 @@ except Exception: PerfCountersBaseCheckWithLegacySupport = object -pytestmark = [requires_py3, requires_windows] +pytestmark = [requires_windows] class CustomCheck(PerfCountersBaseCheckWithLegacySupport): diff --git a/datadog_checks_base/tests/base/checks/windows/perf_counters/test_localization.py b/datadog_checks_base/tests/base/checks/windows/perf_counters/test_localization.py index e3e9b384bec05..cdb417185adb0 100644 --- a/datadog_checks_base/tests/base/checks/windows/perf_counters/test_localization.py +++ b/datadog_checks_base/tests/base/checks/windows/perf_counters/test_localization.py @@ -4,11 +4,11 @@ import mock from datadog_checks.base.constants import ServiceCheck -from datadog_checks.dev.testing import requires_py3, requires_windows +from datadog_checks.dev.testing import requires_windows from .utils import GLOBAL_TAGS, SERVER, get_check -pytestmark = [requires_py3, requires_windows] +pytestmark = [requires_windows] def test_default(aggregator, dd_run_check, mock_performance_objects): diff --git a/datadog_checks_base/tests/base/checks/windows/perf_counters/test_refresh.py b/datadog_checks_base/tests/base/checks/windows/perf_counters/test_refresh.py index 146dcce4f64db..df0b1e9c0eacb 100644 --- a/datadog_checks_base/tests/base/checks/windows/perf_counters/test_refresh.py +++ b/datadog_checks_base/tests/base/checks/windows/perf_counters/test_refresh.py @@ -1,11 +1,11 @@ # (C) Datadog, Inc. 2021-present # All rights reserved # Licensed under a 3-clause BSD style license (see LICENSE) -from datadog_checks.dev.testing import requires_py3, requires_windows +from datadog_checks.dev.testing import requires_windows from .utils import GLOBAL_TAGS, get_check -pytestmark = [requires_py3, requires_windows] +pytestmark = [requires_windows] def test_detection(aggregator, dd_run_check, mock_performance_objects): diff --git a/datadog_checks_base/tests/base/checks/windows/perf_counters/test_subclass.py b/datadog_checks_base/tests/base/checks/windows/perf_counters/test_subclass.py index 01da8468ea4f2..38b5e367e98a0 100644 --- a/datadog_checks_base/tests/base/checks/windows/perf_counters/test_subclass.py +++ b/datadog_checks_base/tests/base/checks/windows/perf_counters/test_subclass.py @@ -2,7 +2,7 @@ # All rights reserved # Licensed under a 3-clause BSD style license (see LICENSE) from datadog_checks.base.constants import ServiceCheck -from datadog_checks.dev.testing import requires_py3, requires_windows +from datadog_checks.dev.testing import requires_windows from .utils import GLOBAL_TAGS, SERVER @@ -14,7 +14,7 @@ PerfCountersBaseCheck = object PerfObject = object -pytestmark = [requires_py3, requires_windows] +pytestmark = [requires_windows] class CustomCheck(PerfCountersBaseCheck): diff --git a/datadog_checks_base/tests/base/checks/windows/perf_counters/transformers/test_count.py b/datadog_checks_base/tests/base/checks/windows/perf_counters/transformers/test_count.py index d8c6fe4d7e604..d00026bc25558 100644 --- a/datadog_checks_base/tests/base/checks/windows/perf_counters/transformers/test_count.py +++ b/datadog_checks_base/tests/base/checks/windows/perf_counters/transformers/test_count.py @@ -1,11 +1,11 @@ # (C) Datadog, Inc. 2021-present # All rights reserved # Licensed under a 3-clause BSD style license (see LICENSE) -from datadog_checks.dev.testing import requires_py3, requires_windows +from datadog_checks.dev.testing import requires_windows from ..utils import GLOBAL_TAGS, get_check -pytestmark = [requires_py3, requires_windows] +pytestmark = [requires_windows] def test(aggregator, dd_run_check, mock_performance_objects): diff --git a/datadog_checks_base/tests/base/checks/windows/perf_counters/transformers/test_gauge.py b/datadog_checks_base/tests/base/checks/windows/perf_counters/transformers/test_gauge.py index cf47ca5777107..a7c10e4ac7647 100644 --- a/datadog_checks_base/tests/base/checks/windows/perf_counters/transformers/test_gauge.py +++ b/datadog_checks_base/tests/base/checks/windows/perf_counters/transformers/test_gauge.py @@ -1,11 +1,11 @@ # (C) Datadog, Inc. 2021-present # All rights reserved # Licensed under a 3-clause BSD style license (see LICENSE) -from datadog_checks.dev.testing import requires_py3, requires_windows +from datadog_checks.dev.testing import requires_windows from ..utils import GLOBAL_TAGS, get_check -pytestmark = [requires_py3, requires_windows] +pytestmark = [requires_windows] def test_explicit(aggregator, dd_run_check, mock_performance_objects): diff --git a/datadog_checks_base/tests/base/checks/windows/perf_counters/transformers/test_monotonic_count.py b/datadog_checks_base/tests/base/checks/windows/perf_counters/transformers/test_monotonic_count.py index 288b9789666c2..c66b2635fcfee 100644 --- a/datadog_checks_base/tests/base/checks/windows/perf_counters/transformers/test_monotonic_count.py +++ b/datadog_checks_base/tests/base/checks/windows/perf_counters/transformers/test_monotonic_count.py @@ -1,11 +1,11 @@ # (C) Datadog, Inc. 2021-present # All rights reserved # Licensed under a 3-clause BSD style license (see LICENSE) -from datadog_checks.dev.testing import requires_py3, requires_windows +from datadog_checks.dev.testing import requires_windows from ..utils import GLOBAL_TAGS, get_check -pytestmark = [requires_py3, requires_windows] +pytestmark = [requires_windows] def test(aggregator, dd_run_check, mock_performance_objects): diff --git a/datadog_checks_base/tests/base/checks/windows/perf_counters/transformers/test_rate.py b/datadog_checks_base/tests/base/checks/windows/perf_counters/transformers/test_rate.py index 323bfc2eb1a41..3a0957b43ce6d 100644 --- a/datadog_checks_base/tests/base/checks/windows/perf_counters/transformers/test_rate.py +++ b/datadog_checks_base/tests/base/checks/windows/perf_counters/transformers/test_rate.py @@ -1,11 +1,11 @@ # (C) Datadog, Inc. 2021-present # All rights reserved # Licensed under a 3-clause BSD style license (see LICENSE) -from datadog_checks.dev.testing import requires_py3, requires_windows +from datadog_checks.dev.testing import requires_windows from ..utils import GLOBAL_TAGS, get_check -pytestmark = [requires_py3, requires_windows] +pytestmark = [requires_windows] def test(aggregator, dd_run_check, mock_performance_objects): diff --git a/datadog_checks_base/tests/base/checks/windows/perf_counters/transformers/test_service_check.py b/datadog_checks_base/tests/base/checks/windows/perf_counters/transformers/test_service_check.py index 69c2402d6401e..12815bfecc6f1 100644 --- a/datadog_checks_base/tests/base/checks/windows/perf_counters/transformers/test_service_check.py +++ b/datadog_checks_base/tests/base/checks/windows/perf_counters/transformers/test_service_check.py @@ -2,11 +2,11 @@ # All rights reserved # Licensed under a 3-clause BSD style license (see LICENSE) from datadog_checks.base.constants import ServiceCheck -from datadog_checks.dev.testing import requires_py3, requires_windows +from datadog_checks.dev.testing import requires_windows from ..utils import GLOBAL_TAGS, get_check -pytestmark = [requires_py3, requires_windows] +pytestmark = [requires_windows] def test_known(aggregator, dd_run_check, mock_performance_objects): diff --git a/datadog_checks_base/tests/base/checks/windows/perf_counters/transformers/test_temporal_percent.py b/datadog_checks_base/tests/base/checks/windows/perf_counters/transformers/test_temporal_percent.py index f666fc681d9bd..59e772960bd71 100644 --- a/datadog_checks_base/tests/base/checks/windows/perf_counters/transformers/test_temporal_percent.py +++ b/datadog_checks_base/tests/base/checks/windows/perf_counters/transformers/test_temporal_percent.py @@ -1,11 +1,11 @@ # (C) Datadog, Inc. 2021-present # All rights reserved # Licensed under a 3-clause BSD style license (see LICENSE) -from datadog_checks.dev.testing import requires_py3, requires_windows +from datadog_checks.dev.testing import requires_windows from ..utils import GLOBAL_TAGS, get_check -pytestmark = [requires_py3, requires_windows] +pytestmark = [requires_windows] def test_named(aggregator, dd_run_check, mock_performance_objects): diff --git a/datadog_checks_base/tests/base/checks/windows/perf_counters/transformers/test_time_elapsed.py b/datadog_checks_base/tests/base/checks/windows/perf_counters/transformers/test_time_elapsed.py index 4380dc4e5024b..7b191063f1ea1 100644 --- a/datadog_checks_base/tests/base/checks/windows/perf_counters/transformers/test_time_elapsed.py +++ b/datadog_checks_base/tests/base/checks/windows/perf_counters/transformers/test_time_elapsed.py @@ -2,11 +2,11 @@ # All rights reserved # Licensed under a 3-clause BSD style license (see LICENSE) from datadog_checks.base.utils.time import get_timestamp -from datadog_checks.dev.testing import requires_py3, requires_windows +from datadog_checks.dev.testing import requires_windows from ..utils import GLOBAL_TAGS, get_check -pytestmark = [requires_py3, requires_windows] +pytestmark = [requires_windows] def test(aggregator, dd_run_check, mock_performance_objects): diff --git a/datadog_checks_base/tests/base/utils/replay/test_check.py b/datadog_checks_base/tests/base/utils/replay/test_check.py index 2723d4b7dc4ec..7866db15ad5de 100644 --- a/datadog_checks_base/tests/base/utils/replay/test_check.py +++ b/datadog_checks_base/tests/base/utils/replay/test_check.py @@ -7,9 +7,6 @@ from datadog_checks.base import AgentCheck from datadog_checks.base.constants import ServiceCheck -from datadog_checks.dev.testing import requires_py3 - -pytestmark = [requires_py3] class ReplayCheck(AgentCheck): diff --git a/datadog_checks_base/tests/models/test_interface.py b/datadog_checks_base/tests/models/test_interface.py index 3d189482e715a..781dcf4e0aa14 100644 --- a/datadog_checks_base/tests/models/test_interface.py +++ b/datadog_checks_base/tests/models/test_interface.py @@ -5,15 +5,12 @@ from six import PY3 from datadog_checks.base import AgentCheck -from datadog_checks.dev.testing import requires_py3 if PY3: from .config_models import ConfigMixin else: ConfigMixin = object -pytestmark = [requires_py3] - class Check(AgentCheck, ConfigMixin): def check(self, _): diff --git a/datadog_checks_base/tests/models/test_types.py b/datadog_checks_base/tests/models/test_types.py index c4ccc0f07b745..c0747072930c0 100644 --- a/datadog_checks_base/tests/models/test_types.py +++ b/datadog_checks_base/tests/models/test_types.py @@ -1,9 +1,6 @@ # (C) Datadog, Inc. 2021-present # All rights reserved # Licensed under a 3-clause BSD style license (see LICENSE) -from datadog_checks.dev.testing import requires_py3 - -pytestmark = [requires_py3] def test_make_immutable(): diff --git a/datadog_checks_dev/datadog_checks/dev/conditions.py b/datadog_checks_dev/datadog_checks/dev/conditions.py index 85d8ea474bc9d..d4c228c259780 100644 --- a/datadog_checks_dev/datadog_checks/dev/conditions.py +++ b/datadog_checks_dev/datadog_checks/dev/conditions.py @@ -6,9 +6,7 @@ import time from contextlib import closing from typing import Callable, Dict, List, Tuple, Union # noqa: F401 - -from six import string_types -from six.moves.urllib.request import urlopen +from urllib.request import urlopen from .errors import RetryError from .structures import LazyFunction @@ -69,7 +67,7 @@ def __init__( wait=1, # type: int send_request=None, ): - self.endpoints = [endpoints] if isinstance(endpoints, string_types) else endpoints + self.endpoints = [endpoints] if isinstance(endpoints, str) else endpoints self.timeout = timeout self.attempts = attempts self.wait = wait @@ -131,12 +129,10 @@ def __init__( if not (self.stdout or self.stderr): raise ValueError('Must capture stdout, stderr, or both.') - if isinstance(patterns, string_types): + if isinstance(patterns, str): patterns = [patterns] - self.patterns = [ - re.compile(pattern, re.M) if isinstance(pattern, string_types) else pattern for pattern in patterns - ] + self.patterns = [re.compile(pattern, re.M) if isinstance(pattern, str) else pattern for pattern in patterns] if matches == 'all': self.matches = len(patterns) diff --git a/datadog_checks_dev/datadog_checks/dev/docker.py b/datadog_checks_dev/datadog_checks/dev/docker.py index 044f05b9848f2..cf62dfd4c66aa 100644 --- a/datadog_checks_dev/datadog_checks/dev/docker.py +++ b/datadog_checks_dev/datadog_checks/dev/docker.py @@ -4,9 +4,7 @@ import os from contextlib import contextmanager from typing import Iterator # noqa: F401 - -from six import string_types -from six.moves.urllib.parse import urlparse +from urllib.parse import urlparse from .conditions import CheckDockerLogs from .env import environment_run, get_state, save_state @@ -168,7 +166,7 @@ def docker_run( raise TypeError('You must select either a compose file or a custom setup callable, not both.') if compose_file is not None: - if not isinstance(compose_file, string_types): + if not isinstance(compose_file, str): raise TypeError('The path to the compose file is not a string: {}'.format(repr(compose_file))) set_up = ComposeFileUp(compose_file, build=build, service_name=service_name) diff --git a/datadog_checks_dev/datadog_checks/dev/fs.py b/datadog_checks_dev/datadog_checks/dev/fs.py index c715d2ed466ff..aab0ca507ff35 100644 --- a/datadog_checks_dev/datadog_checks/dev/fs.py +++ b/datadog_checks_dev/datadog_checks/dev/fs.py @@ -11,31 +11,19 @@ from contextlib import contextmanager from io import open from tempfile import mkdtemp - -from six import PY3, text_type -from six.moves.urllib.request import urlopen +from urllib.request import urlopen from .structures import EnvVars -if PY3: - - def write_file(file, contents, encoding='utf-8'): - with open(file, 'w', encoding=encoding) as f: - f.write(contents) - def write_file_lines(file, lines, encoding='utf-8'): - with open(file, 'w', encoding=encoding) as f: - f.writelines(lines) - -else: +def write_file(file, contents, encoding='utf-8'): + with open(file, 'w', encoding=encoding) as f: + f.write(contents) - def write_file(file, contents, encoding='utf-8'): - with open(file, 'w', encoding=encoding) as f: - f.write(text_type(contents)) - def write_file_lines(file, lines, encoding='utf-8'): - with open(file, 'w', encoding=encoding) as f: - f.writelines(text_type(line) for line in lines) +def write_file_lines(file, lines, encoding='utf-8'): + with open(file, 'w', encoding=encoding) as f: + f.writelines(lines) def dir_exists(d): diff --git a/datadog_checks_dev/datadog_checks/dev/kind.py b/datadog_checks_dev/datadog_checks/dev/kind.py index 3bd61ab8ef85d..f0a7cda5d13f5 100644 --- a/datadog_checks_dev/datadog_checks/dev/kind.py +++ b/datadog_checks_dev/datadog_checks/dev/kind.py @@ -2,9 +2,9 @@ # All rights reserved # Licensed under a 3-clause BSD style license (see LICENSE) from contextlib import contextmanager +from shutil import which import pytest -from six import PY3 from .env import environment_run from .fs import create_file, file_exists, path_join @@ -12,11 +12,6 @@ from .subprocess import run_command from .utils import get_active_env, get_current_check_name -if PY3: - from shutil import which -else: - from shutilwhich import which - @contextmanager def kind_run( diff --git a/datadog_checks_dev/datadog_checks/dev/plugin/pytest.py b/datadog_checks_dev/datadog_checks/dev/plugin/pytest.py index 2345e6013cf57..f9eaaf19b38a0 100644 --- a/datadog_checks_dev/datadog_checks/dev/plugin/pytest.py +++ b/datadog_checks_dev/datadog_checks/dev/plugin/pytest.py @@ -6,14 +6,12 @@ import json import os import re -import warnings from base64 import urlsafe_b64encode from collections import namedtuple # Not using dataclasses for Py2 compatibility from io import open from typing import Dict, List, Optional, Tuple # noqa: F401 import pytest -from six import PY2, ensure_text from .._env import ( E2E_FIXTURE_NAME, @@ -138,7 +136,7 @@ def dd_environment_runner(request): # Exit testing and pass data back up to command if E2E_RESULT_FILE in os.environ: with open(os.environ[E2E_RESULT_FILE], 'w', encoding='utf-8') as f: - f.write(ensure_text(json.dumps(data))) + f.write(json.dumps(data)) # Rather than exiting we skip every test to avoid the following output: # !!!!!!!!!! _pytest.outcomes.Exit: !!!!!!!!!! @@ -391,18 +389,6 @@ def pytest_configure(config): def pytest_addoption(parser): parser.addoption("--run-latest-metrics", action="store_true", default=False, help="run check_metrics tests") - if PY2: - # Add dummy memray options to make it possible to run memray with `ddev test --memray ` - # in both py2 and 3 environments. In py2 the option is simply ignored, see pytest_collection_modifyitems. - # In py3 the option enables the memray plugin. - parser.addoption("--memray", action="store_true", default=False, help="Dummy parameter for memray") - parser.addoption( - "--hide-memray-summary", - action="store_true", - default=False, - help="Dummy parameter for memray to hide the summary", - ) - def pytest_collection_modifyitems(config, items): # at test collection time, this function gets called by pytest, see: @@ -412,20 +398,12 @@ def pytest_collection_modifyitems(config, items): # --run-check-metrics given in cli: do not skip slow tests return - if PY2: - for option in ("--memray",): - if config.getoption(option): - warnings.warn( # noqa: B028 - "`{}` option ignored as it's not supported for py2 environments.".format(option) - ) # noqa: B028, E501 - skip_latest_metrics = pytest.mark.skip(reason="need --run-latest-metrics option to run") for item in items: if "latest_metrics" in item.keywords: item.add_marker(skip_latest_metrics) - # In Python 2 we're using a much older version of pytest where the Item interface is different. - item_path = item.fspath if PY2 else item.path + item_path = item.path if item_path is None: continue for ttype in TEST_TYPES: diff --git a/datadog_checks_dev/datadog_checks/dev/ssh_tunnel.py b/datadog_checks_dev/datadog_checks/dev/ssh_tunnel.py index 77f8f7449053a..b5340b09a7d11 100644 --- a/datadog_checks_dev/datadog_checks/dev/ssh_tunnel.py +++ b/datadog_checks_dev/datadog_checks/dev/ssh_tunnel.py @@ -4,21 +4,16 @@ from __future__ import absolute_import import os +import subprocess from contextlib import contextmanager import psutil -from six import PY3 from .conditions import WaitForPortListening from .env import environment_run from .structures import LazyFunction, TempDir from .utils import ON_WINDOWS, find_free_port, get_ip -if PY3: - import subprocess -else: - import subprocess32 as subprocess - PID_FILE = 'ssh.pid' diff --git a/datadog_checks_dev/datadog_checks/dev/subprocess.py b/datadog_checks_dev/datadog_checks/dev/subprocess.py index 01d3afe513459..9dd7aae87b2d8 100644 --- a/datadog_checks_dev/datadog_checks/dev/subprocess.py +++ b/datadog_checks_dev/datadog_checks/dev/subprocess.py @@ -8,8 +8,6 @@ from subprocess import Popen from tempfile import TemporaryFile -from six import string_types - from .errors import SubprocessError from .utils import NEED_SHELL, ON_WINDOWS, mock_context_manager @@ -42,7 +40,7 @@ def run_command(command, capture=None, check=False, encoding='utf-8', shell=Fals if shell == 'detect': shell = NEED_SHELL - if isinstance(command, string_types) and not ON_WINDOWS: + if isinstance(command, str) and not ON_WINDOWS: command = shlex.split(command) if capture: diff --git a/datadog_checks_dev/datadog_checks/dev/terraform.py b/datadog_checks_dev/datadog_checks/dev/terraform.py index 11a59fc8c23a5..7720b1a1d1702 100644 --- a/datadog_checks_dev/datadog_checks/dev/terraform.py +++ b/datadog_checks_dev/datadog_checks/dev/terraform.py @@ -8,18 +8,12 @@ from contextlib import contextmanager import pytest -from six import PY3 from .env import environment_run from .fs import chdir, copy_dir_contents, copy_path, get_here, path_join from .structures import LazyFunction, TempDir from .subprocess import run_command -if PY3: - from shutil import which -else: - from shutilwhich import which - TEMPLATES_DIR = path_join(get_here(), 'tooling', 'templates', 'terraform') @@ -57,7 +51,7 @@ def terraform_run(directory, sleep=None, endpoints=None, conditions=None, env_va wrappers (list[callable]): A list of context managers to use during execution """ - if not which('terraform'): + if not shutil.which('terraform'): pytest.skip('Terraform not available') set_up = TerraformUp(directory) diff --git a/datadog_checks_dev/datadog_checks/dev/testing.py b/datadog_checks_dev/datadog_checks/dev/testing.py index 090cff1c9296b..437e873aaccd2 100644 --- a/datadog_checks_dev/datadog_checks/dev/testing.py +++ b/datadog_checks_dev/datadog_checks/dev/testing.py @@ -5,13 +5,9 @@ """ This module contains test annotations """ import pytest -from six import PY2 from .utils import ON_MACOS, ON_WINDOWS requires_windows = pytest.mark.skipif(not ON_WINDOWS, reason='Requires Windows') requires_linux = pytest.mark.skipif(ON_MACOS or ON_WINDOWS, reason='Requires Linux') requires_unix = pytest.mark.skipif(ON_WINDOWS, reason='Requires Linux or macOS') - -requires_py2 = pytest.mark.skipif(not PY2, reason='Test only available on Python 2') -requires_py3 = pytest.mark.skipif(PY2, reason='Test only available on Python 3') diff --git a/datadog_checks_dev/datadog_checks/dev/utils.py b/datadog_checks_dev/datadog_checks/dev/utils.py index 71602de528ba4..d4ffd2ce66361 100644 --- a/datadog_checks_dev/datadog_checks/dev/utils.py +++ b/datadog_checks_dev/datadog_checks/dev/utils.py @@ -13,9 +13,9 @@ import socket from contextlib import closing, contextmanager from io import open +from urllib.request import urlopen import yaml -from six.moves.urllib.request import urlopen from .ci import running_on_ci, running_on_gh_actions, running_on_windows_ci # noqa: F401 from .fs import basepath, file_exists, get_parent_dir, path_join, read_file diff --git a/datadog_checks_dev/pyproject.toml b/datadog_checks_dev/pyproject.toml index e9e8f703c9281..9df85c415a22b 100644 --- a/datadog_checks_dev/pyproject.toml +++ b/datadog_checks_dev/pyproject.toml @@ -43,7 +43,6 @@ dependencies = [ "pytest-mock", "pyyaml>=5.4.1", "requests>=2.22.0", - "six", "tenacity", ] dynamic = [ diff --git a/dotnetclr/tests/e2e_test.py b/dotnetclr/tests/e2e_test.py index 11526f7935d7c..f75b1ab2ce7c4 100644 --- a/dotnetclr/tests/e2e_test.py +++ b/dotnetclr/tests/e2e_test.py @@ -3,15 +3,12 @@ # Licensed under a 3-clause BSD style license (see LICENSE) import pytest -from datadog_checks.dev.testing import requires_py3 - from .common import MINIMAL_INSTANCE pytestmark = pytest.mark.e2e @pytest.mark.flaky -@requires_py3 def test(dd_agent_check): from datadog_checks.dotnetclr.check import DotnetclrCheckV2 diff --git a/dotnetclr/tests/test_dotnetclr.py b/dotnetclr/tests/test_dotnetclr.py deleted file mode 100644 index 0bfd9dc8e063c..0000000000000 --- a/dotnetclr/tests/test_dotnetclr.py +++ /dev/null @@ -1,32 +0,0 @@ -# (C) Datadog, Inc. 2010-present -# All rights reserved -# Licensed under Simplified BSD License (see LICENSE) -import pytest -from datadog_test_libs.win.pdh_mocks import initialize_pdh_tests, pdh_mocks_fixture # noqa: F401 - -from datadog_checks.dev.testing import requires_py2 -from datadog_checks.dotnetclr import DotnetclrCheck -from datadog_checks.dotnetclr.dotnetclr import DEFAULT_COUNTERS - -from .common import INSTANCES, MINIMAL_INSTANCE - -pytestmark = [requires_py2, pytest.mark.usefixtures('pdh_mocks_fixture')] - - -@pytest.fixture(autouse=True) -def setup_check(): - initialize_pdh_tests() - - -@pytest.mark.integration -def test_basic_check(aggregator, dd_run_check): - instance = MINIMAL_INSTANCE - c = DotnetclrCheck('dotnetclr', {}, [instance]) - dd_run_check(c) - - for metric_def in DEFAULT_COUNTERS: - metric = metric_def[3] - for inst in INSTANCES: - aggregator.assert_metric(metric, tags=["instance:%s" % inst], count=1) - - assert aggregator.metrics_asserted_pct == 100.0 diff --git a/dotnetclr/tests/test_unit.py b/dotnetclr/tests/test_unit.py index 1b0ae0615793f..326a0a3fd67d0 100644 --- a/dotnetclr/tests/test_unit.py +++ b/dotnetclr/tests/test_unit.py @@ -2,15 +2,12 @@ # All rights reserved # Licensed under a 3-clause BSD style license (see LICENSE) from datadog_checks.base.constants import ServiceCheck -from datadog_checks.dev.testing import requires_py3 from datadog_checks.dev.utils import get_metadata_metrics from datadog_checks.dotnetclr import DotnetclrCheck from datadog_checks.dotnetclr.metrics import METRICS_CONFIG from .common import PERFORMANCE_OBJECTS -pytestmark = [requires_py3] - def test(aggregator, dd_default_hostname, dd_run_check, mock_performance_objects): mock_performance_objects(PERFORMANCE_OBJECTS) diff --git a/envoy/tests/test_unit.py b/envoy/tests/test_unit.py index 03e68cc15f498..dfa88c05efa24 100644 --- a/envoy/tests/test_unit.py +++ b/envoy/tests/test_unit.py @@ -4,8 +4,7 @@ import mock import pytest -from datadog_checks.base import AgentCheck, ConfigurationError -from datadog_checks.dev.testing import requires_py2, requires_py3 +from datadog_checks.base import AgentCheck from datadog_checks.dev.utils import get_metadata_metrics from datadog_checks.envoy.metrics import PROMETHEUS_METRICS_MAP @@ -35,13 +34,6 @@ def test_unique_metrics(): duplicated_metrics.add(value) -@requires_py2 -def test_check_with_py2(aggregator, dd_run_check, check, mock_http_response): - with pytest.raises(ConfigurationError, match="This version of the integration is only available when using py3."): - check(DEFAULT_INSTANCE) - - -@requires_py3 def test_check(aggregator, dd_run_check, check, mock_http_response): mock_http_response(file_path=get_fixture_path('./openmetrics/openmetrics.txt')) @@ -70,7 +62,6 @@ def test_check(aggregator, dd_run_check, check, mock_http_response): aggregator.assert_metrics_using_metadata(get_metadata_metrics()) -@requires_py3 def test_collect_metadata(datadog_agent, fixture_path, mock_http_response, check, default_instance): c = check(default_instance) c.check_id = 'test:123' @@ -92,7 +83,6 @@ def test_collect_metadata(datadog_agent, fixture_path, mock_http_response, check datadog_agent.assert_metadata_count(len(version_metadata)) -@requires_py3 def test_collect_metadata_with_invalid_base_url( datadog_agent, fixture_path, mock_http_response, check, default_instance ): @@ -106,7 +96,6 @@ def test_collect_metadata_with_invalid_base_url( c.log.debug.assert_called_with('Skipping server info collection due to malformed url: %s', b'') -@requires_py3 @pytest.mark.parametrize( 'fixture_file', [ @@ -139,7 +128,6 @@ def test_local_rate_limit_metrics(aggregator, dd_run_check, check, mock_http_res aggregator.assert_metrics_using_metadata(get_metadata_metrics()) -@requires_py3 def test_tags_in_ssl_metrics(aggregator, dd_run_check, check, mock_http_response): mock_http_response(file_path=get_fixture_path('./openmetrics/openmetrics_ssl_metrics.txt')) @@ -157,7 +145,6 @@ def test_tags_in_ssl_metrics(aggregator, dd_run_check, check, mock_http_response aggregator.assert_metrics_using_metadata(get_metadata_metrics()) -@requires_py3 def test_collect_metadata_with_disabled_collect_server_info( datadog_agent, fixture_path, mock_http_response, check, default_instance ): diff --git a/exchange_server/tests/test_e2e.py b/exchange_server/tests/test_e2e.py index a1f9e988c91d9..86f1713554682 100644 --- a/exchange_server/tests/test_e2e.py +++ b/exchange_server/tests/test_e2e.py @@ -5,7 +5,6 @@ import pytest from datadog_checks.base import AgentCheck -from datadog_checks.dev.testing import requires_py3 from datadog_checks.exchange_server.metrics import METRICS_CONFIG @@ -24,7 +23,6 @@ def get_exchange_server_metrics(): @pytest.mark.e2e -@requires_py3 def test_e2e_py3(dd_agent_check, aggregator, instance): aggregator = dd_agent_check(instance) aggregator.assert_service_check('exchange.windows.perf.health', AgentCheck.OK) diff --git a/exchange_server/tests/test_exchange_server.py b/exchange_server/tests/test_exchange_server.py deleted file mode 100644 index 28058889c5348..0000000000000 --- a/exchange_server/tests/test_exchange_server.py +++ /dev/null @@ -1,36 +0,0 @@ -# (C) Datadog, Inc. 2010-present -# All rights reserved -# Licensed under Simplified BSD License (see LICENSE) -import pytest -from datadog_test_libs.win.pdh_mocks import initialize_pdh_tests, pdh_mocks_fixture # noqa: F401 - -from datadog_checks.dev.testing import requires_py2 -from datadog_checks.exchange_server import ExchangeCheck -from datadog_checks.exchange_server.metrics import DEFAULT_COUNTERS - -from .common import CHECK_NAME, METRIC_INSTANCES, MINIMAL_INSTANCE - -pytestmark = [requires_py2, pytest.mark.usefixtures('pdh_mocks_fixture')] - - -@pytest.fixture(autouse=True) -def setup_check(): - initialize_pdh_tests() - - -@pytest.mark.integration -def test_basic_check(aggregator, dd_run_check): - instance = MINIMAL_INSTANCE - c = ExchangeCheck(CHECK_NAME, {}, [instance]) - dd_run_check(c) - - for metric_def in DEFAULT_COUNTERS: - metric = metric_def[3] - instances = METRIC_INSTANCES.get(metric) - if instances is not None: - for inst in instances: - aggregator.assert_metric(metric, tags=["instance:%s" % inst], count=1) - else: - aggregator.assert_metric(metric, tags=None, count=1) - - assert aggregator.metrics_asserted_pct == 100.0 diff --git a/exchange_server/tests/test_unit.py b/exchange_server/tests/test_unit.py index 472009f084ebf..cef790828bb29 100644 --- a/exchange_server/tests/test_unit.py +++ b/exchange_server/tests/test_unit.py @@ -2,15 +2,12 @@ # All rights reserved # Licensed under a 3-clause BSD style license (see LICENSE) from datadog_checks.base.constants import ServiceCheck -from datadog_checks.dev.testing import requires_py3 from datadog_checks.dev.utils import get_metadata_metrics from datadog_checks.exchange_server import ExchangeCheck from datadog_checks.exchange_server.metrics import METRICS_CONFIG from .common import PERFORMANCE_OBJECTS -pytestmark = [requires_py3] - def test(aggregator, dd_default_hostname, dd_run_check, mock_performance_objects): mock_performance_objects(PERFORMANCE_OBJECTS) diff --git a/gitlab/tests/test_integration.py b/gitlab/tests/test_integration.py index 0a1ade703cb80..5aa2531a27b1e 100644 --- a/gitlab/tests/test_integration.py +++ b/gitlab/tests/test_integration.py @@ -5,7 +5,6 @@ import pytest from requests.exceptions import ConnectionError -from datadog_checks.dev.testing import requires_py3 from datadog_checks.gitlab import GitlabCheck from .common import ( @@ -30,7 +29,6 @@ def test_check(dd_run_check, aggregator, gitlab_check, get_config, use_openmetri assert_check(aggregator, METRICS_TO_TEST_V2 if use_openmetrics else METRICS_TO_TEST, use_openmetrics) -@requires_py3 def test_check_gitaly(dd_run_check, aggregator, gitlab_check, get_config): from datadog_checks.gitlab.gitlab_v2 import GitlabCheckV2 @@ -70,7 +68,6 @@ def test_connection_failure(aggregator, gitlab_check, get_bad_config): ) -@requires_py3 def test_connection_failure_openmetrics(dd_run_check, aggregator, gitlab_check, get_bad_config): check = gitlab_check(get_bad_config(True)) diff --git a/gitlab/tests/test_unit.py b/gitlab/tests/test_unit.py index 8acbb2295edbf..b0b6bd8f12cab 100644 --- a/gitlab/tests/test_unit.py +++ b/gitlab/tests/test_unit.py @@ -4,8 +4,7 @@ import pytest from mock.mock import MagicMock -from datadog_checks.base import AgentCheck, ConfigurationError -from datadog_checks.dev.testing import requires_py2, requires_py3 +from datadog_checks.base import AgentCheck from datadog_checks.dev.utils import get_metadata_metrics from datadog_checks.gitlab.common import get_gitlab_version @@ -33,7 +32,6 @@ def test_check(dd_run_check, aggregator, mock_data, gitlab_check, get_config, us aggregator.assert_metrics_using_metadata(get_metadata_metrics()) -@requires_py3 def test_check_gitaly(dd_run_check, aggregator, mock_data, gitlab_check, get_config): from datadog_checks.gitlab.gitlab_v2 import GitlabCheckV2 @@ -56,14 +54,6 @@ def test_check_gitaly(dd_run_check, aggregator, mock_data, gitlab_check, get_con ) -@requires_py2 -def test_openmetrics_with_python2(gitlab_check, get_config): - with pytest.raises( - ConfigurationError, match="This version of the integration is only available when using Python 3." - ): - gitlab_check(get_config(True)) - - @pytest.mark.parametrize( "raw_version", [ @@ -88,7 +78,6 @@ def test_get_gitlab_version_without_token(): assert version is None -@requires_py3 def test_no_gitlab_url(dd_run_check, aggregator, mock_data, gitlab_check, get_config): config = get_config(True) del config['instances'][0]['gitlab_url'] @@ -97,7 +86,6 @@ def test_no_gitlab_url(dd_run_check, aggregator, mock_data, gitlab_check, get_co aggregator.assert_service_check('gitlab.openmetrics.health', status=AgentCheck.OK) -@requires_py3 def test_parse_readiness_service_checks_with_invalid_payload( dd_run_check, aggregator, mock_data, gitlab_check, get_config ): @@ -159,7 +147,6 @@ def test_parse_readiness_service_checks_with_invalid_payload( ), ], ) -@requires_py3 def test_parse_readiness_service_checks( dd_run_check, aggregator, mock_data, gitlab_check, get_config, service_check, expected_redis_status ): diff --git a/hyperv/tests/test_hyperv.py b/hyperv/tests/test_hyperv.py index 112b26f560b6f..6d9abfe749977 100644 --- a/hyperv/tests/test_hyperv.py +++ b/hyperv/tests/test_hyperv.py @@ -4,12 +4,10 @@ import pytest from datadog_checks.base.constants import ServiceCheck -from datadog_checks.dev.testing import requires_py2, requires_py3 from datadog_checks.hyperv import HypervCheck from datadog_checks.hyperv.metrics import DEFAULT_COUNTERS -@requires_py3 def test_check(aggregator, dd_default_hostname, dd_run_check): check = HypervCheck('hyperv', {}, [{}]) check.hostname = dd_default_hostname @@ -24,14 +22,6 @@ def test_check(aggregator, dd_default_hostname, dd_run_check): _assert_metrics(aggregator) -@requires_py2 -def test_check_legacy(aggregator, instance_refresh, dd_run_check): - check = HypervCheck('hyperv', {}, [instance_refresh]) - dd_run_check(check) - - _assert_metrics(aggregator) - - @pytest.mark.e2e def test_check_e2e(dd_agent_check, instance_refresh): aggregator = dd_agent_check(instance_refresh) diff --git a/ibm_mq/tests/test_ibm_mq_int.py b/ibm_mq/tests/test_ibm_mq_int.py index 72c2655eebc8e..51927607394ad 100644 --- a/ibm_mq/tests/test_ibm_mq_int.py +++ b/ibm_mq/tests/test_ibm_mq_int.py @@ -10,7 +10,6 @@ from datadog_checks.base import AgentCheck from datadog_checks.base.utils.time import ensure_aware_datetime -from datadog_checks.dev.testing import requires_py3 from datadog_checks.dev.utils import get_metadata_metrics from . import common @@ -412,7 +411,6 @@ def test_channel_status_no_duplicates(aggregator, get_check, instance, dd_run_ch aggregator.assert_service_check("ibm_mq.channel.status", check.OK, tags=tags, count=1) -@requires_py3 def test_queue_manager_process_not_found(aggregator, get_check, instance, dd_run_check): class ProcessMock(object): @property @@ -441,7 +439,6 @@ def info(self): aggregator.assert_all_metrics_covered() -@requires_py3 def test_queue_manager_process_found(aggregator, get_check, instance, dd_run_check): class ProcessMock(object): @property @@ -468,7 +465,6 @@ def info(self): assert_all_metrics(aggregator) -@requires_py3 def test_queue_manager_process_found_cleanup(get_check, instance, dd_run_check): class ProcessMock(object): @property diff --git a/ibm_mq/tests/test_ibm_mq_unit.py b/ibm_mq/tests/test_ibm_mq_unit.py index ac9f4ef87437c..9e1d7d4cf27be 100644 --- a/ibm_mq/tests/test_ibm_mq_unit.py +++ b/ibm_mq/tests/test_ibm_mq_unit.py @@ -5,7 +5,6 @@ import pytest from datadog_checks.base import AgentCheck, ConfigurationError -from datadog_checks.dev.testing import requires_py3 from .common import skip_windows_ci @@ -265,7 +264,6 @@ def test_ssl_check_normal_connection_before_ssl_connection(instance_ssl_dummy): get_ssl_connection.assert_called_with(config, logger) -@requires_py3 def test_queue_manager_process_direct_ssl(instance): from datadog_checks.ibm_mq.config import IBMMQConfig diff --git a/iis/tests/test_unit.py b/iis/tests/test_unit.py index bced243c6e474..1f7d4b855f98c 100644 --- a/iis/tests/test_unit.py +++ b/iis/tests/test_unit.py @@ -2,15 +2,12 @@ # All rights reserved # Licensed under a 3-clause BSD style license (see LICENSE) from datadog_checks.base.constants import ServiceCheck -from datadog_checks.dev.testing import requires_py3 from datadog_checks.dev.utils import get_metadata_metrics from datadog_checks.iis import IIS from datadog_checks.iis.service_check import IIS_APPLICATION_POOL_STATE from .common import DEFAULT_COUNTERS, PERFORMANCE_OBJECTS -pytestmark = [requires_py3] - def get_metrics_data(): app_pool_metrics_data = [] diff --git a/openstack/tests/test_openstack.py b/openstack/tests/test_openstack.py index b44a1dea155b4..aef61e93d9069 100644 --- a/openstack/tests/test_openstack.py +++ b/openstack/tests/test_openstack.py @@ -9,7 +9,6 @@ import pytest from datadog_checks.base import AgentCheck -from datadog_checks.dev.testing import requires_py3 from datadog_checks.openstack.openstack import ( IncompleteAuthScope, IncompleteConfig, @@ -302,7 +301,6 @@ def test_cache_between_runs(self, *args): assert 'server_newly_added' in cached_servers -@requires_py3 @pytest.mark.parametrize( 'init_config, instances, exception', [ diff --git a/tls/tests/test_remote.py b/tls/tests/test_remote.py index c2364f61fc129..bce911e5f3017 100644 --- a/tls/tests/test_remote.py +++ b/tls/tests/test_remote.py @@ -5,7 +5,6 @@ import pytest from datadog_checks.base import ConfigurationError -from datadog_checks.dev.testing import requires_py3 from datadog_checks.tls.const import ( SERVICE_CHECK_CAN_CONNECT, SERVICE_CHECK_EXPIRATION, @@ -338,7 +337,6 @@ def test_mysql_ok(aggregator, instance_remote_mysql_valid): aggregator.assert_all_metrics_covered() -@requires_py3 def test_valid_version_with_critical_certificate_validation_and_critial_certificate_expiration( aggregator, instance_remote_ok ): @@ -370,7 +368,6 @@ def test_valid_version_with_critical_certificate_validation_and_critial_certific aggregator.assert_all_metrics_covered() -@requires_py3 def test_valid_version_and_critical_certificate_validation_due_to_socket_exception(aggregator, instance_remote_ok): c = TLSCheck('tls', {}, [instance_remote_ok]) check = TLSRemoteCheck(agent_check=c) @@ -399,7 +396,6 @@ def test_valid_version_and_critical_certificate_validation_due_to_socket_excepti aggregator.assert_all_metrics_covered() -@requires_py3 def test_valid_version_and_critical_certificate_validation_due_to_parsing_error(aggregator, instance_remote_ok): c = TLSCheck('tls', {}, [instance_remote_ok]) check = TLSRemoteCheck(agent_check=c)