Skip to content

Commit

Permalink
Merge branch 'main' into evan.li/ragas-ml-app
Browse files Browse the repository at this point in the history
  • Loading branch information
lievan authored Jan 17, 2025
2 parents 195cb4a + ef4c997 commit 38e1f62
Show file tree
Hide file tree
Showing 56 changed files with 1,540 additions and 1,373 deletions.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
import _pytest
import pytest

from ddtrace.contrib.pytest._retry_utils import RetryOutcomes
from ddtrace.contrib.pytest._retry_utils import _get_outcome_from_retry
from ddtrace.contrib.pytest._retry_utils import _get_retry_attempt_string
from ddtrace.contrib.pytest._retry_utils import set_retry_num
from ddtrace.contrib.pytest._types import _pytest_report_teststatus_return_type
from ddtrace.contrib.pytest._types import pytest_TestReport
from ddtrace.contrib.pytest._utils import PYTEST_STATUS
from ddtrace.contrib.pytest._utils import _get_test_id_from_item
from ddtrace.contrib.pytest._utils import _TestOutcome
from ddtrace.contrib.internal.pytest._retry_utils import RetryOutcomes
from ddtrace.contrib.internal.pytest._retry_utils import _get_outcome_from_retry
from ddtrace.contrib.internal.pytest._retry_utils import _get_retry_attempt_string
from ddtrace.contrib.internal.pytest._retry_utils import set_retry_num
from ddtrace.contrib.internal.pytest._types import _pytest_report_teststatus_return_type
from ddtrace.contrib.internal.pytest._types import pytest_TestReport
from ddtrace.contrib.internal.pytest._utils import PYTEST_STATUS
from ddtrace.contrib.internal.pytest._utils import _get_test_id_from_item
from ddtrace.contrib.internal.pytest._utils import _TestOutcome
from ddtrace.ext.test_visibility.api import TestStatus
from ddtrace.internal.logger import get_logger
from ddtrace.internal.test_visibility._internal_item_ids import InternalTestId
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

from ddtrace.contrib.pytest._utils import _get_test_id_from_item
from ddtrace.contrib.pytest_benchmark.constants import PLUGIN_METRICS_V2
from ddtrace.contrib.internal.pytest._utils import _get_test_id_from_item
from ddtrace.contrib.internal.pytest_benchmark.constants import PLUGIN_METRICS_V2
from ddtrace.internal.logger import get_logger
from ddtrace.internal.test_visibility._benchmark_mixin import BenchmarkDurationData
from ddtrace.internal.test_visibility.api import InternalTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
import _pytest
import pytest

from ddtrace.contrib.pytest._retry_utils import RetryOutcomes
from ddtrace.contrib.pytest._retry_utils import _get_outcome_from_retry
from ddtrace.contrib.pytest._retry_utils import _get_retry_attempt_string
from ddtrace.contrib.pytest._retry_utils import set_retry_num
from ddtrace.contrib.pytest._types import _pytest_report_teststatus_return_type
from ddtrace.contrib.pytest._types import pytest_TestReport
from ddtrace.contrib.pytest._utils import PYTEST_STATUS
from ddtrace.contrib.pytest._utils import _get_test_id_from_item
from ddtrace.contrib.pytest._utils import _TestOutcome
from ddtrace.contrib.internal.pytest._retry_utils import RetryOutcomes
from ddtrace.contrib.internal.pytest._retry_utils import _get_outcome_from_retry
from ddtrace.contrib.internal.pytest._retry_utils import _get_retry_attempt_string
from ddtrace.contrib.internal.pytest._retry_utils import set_retry_num
from ddtrace.contrib.internal.pytest._types import _pytest_report_teststatus_return_type
from ddtrace.contrib.internal.pytest._types import pytest_TestReport
from ddtrace.contrib.internal.pytest._utils import PYTEST_STATUS
from ddtrace.contrib.internal.pytest._utils import _get_test_id_from_item
from ddtrace.contrib.internal.pytest._utils import _TestOutcome
from ddtrace.ext.test_visibility.api import TestStatus
from ddtrace.internal.logger import get_logger
from ddtrace.internal.test_visibility._efd_mixins import EFDTestStatus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@
from ddtrace.contrib.internal.coverage.patch import unpatch as unpatch_coverage
from ddtrace.contrib.internal.coverage.utils import _is_coverage_invoked_by_coverage_run
from ddtrace.contrib.internal.coverage.utils import _is_coverage_patched
from ddtrace.contrib.pytest._utils import _extract_span
from ddtrace.contrib.pytest._utils import _is_enabled_early
from ddtrace.contrib.pytest._utils import _is_pytest_8_or_later
from ddtrace.contrib.pytest._utils import _is_test_unskippable
from ddtrace.contrib.pytest.constants import FRAMEWORK
from ddtrace.contrib.pytest.constants import KIND
from ddtrace.contrib.pytest.constants import XFAIL_REASON
from ddtrace.contrib.pytest.plugin import is_enabled
from ddtrace.contrib.unittest import unpatch as unpatch_unittest
from ddtrace.contrib.internal.pytest._utils import _extract_span
from ddtrace.contrib.internal.pytest._utils import _is_enabled_early
from ddtrace.contrib.internal.pytest._utils import _is_pytest_8_or_later
from ddtrace.contrib.internal.pytest._utils import _is_test_unskippable
from ddtrace.contrib.internal.pytest.constants import FRAMEWORK
from ddtrace.contrib.internal.pytest.constants import KIND
from ddtrace.contrib.internal.pytest.constants import XFAIL_REASON
from ddtrace.contrib.internal.pytest.plugin import is_enabled
from ddtrace.contrib.internal.unittest.patch import unpatch as unpatch_unittest
from ddtrace.ext import SpanTypes
from ddtrace.ext import test
from ddtrace.internal.ci_visibility import CIVisibility as _CIVisibility
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,38 @@

from ddtrace import DDTraceDeprecationWarning
from ddtrace import config as dd_config
from ddtrace import patch
from ddtrace._monkey import patch
from ddtrace.contrib.coverage import patch as patch_coverage
from ddtrace.contrib.internal.coverage.constants import PCT_COVERED_KEY
from ddtrace.contrib.internal.coverage.data import _coverage_data
from ddtrace.contrib.internal.coverage.patch import run_coverage_report
from ddtrace.contrib.internal.coverage.utils import _is_coverage_invoked_by_coverage_run
from ddtrace.contrib.internal.coverage.utils import _is_coverage_patched
from ddtrace.contrib.pytest._benchmark_utils import _set_benchmark_data_from_item
from ddtrace.contrib.pytest._plugin_v1 import _extract_reason
from ddtrace.contrib.pytest._plugin_v1 import _is_pytest_cov_enabled
from ddtrace.contrib.pytest._types import _pytest_report_teststatus_return_type
from ddtrace.contrib.pytest._types import pytest_CallInfo
from ddtrace.contrib.pytest._types import pytest_Config
from ddtrace.contrib.pytest._types import pytest_TestReport
from ddtrace.contrib.pytest._utils import PYTEST_STATUS
from ddtrace.contrib.pytest._utils import _get_module_path_from_item
from ddtrace.contrib.pytest._utils import _get_names_from_item
from ddtrace.contrib.pytest._utils import _get_session_command
from ddtrace.contrib.pytest._utils import _get_source_file_info
from ddtrace.contrib.pytest._utils import _get_test_id_from_item
from ddtrace.contrib.pytest._utils import _get_test_parameters_json
from ddtrace.contrib.pytest._utils import _is_enabled_early
from ddtrace.contrib.pytest._utils import _is_test_unskippable
from ddtrace.contrib.pytest._utils import _pytest_marked_to_skip
from ddtrace.contrib.pytest._utils import _pytest_version_supports_atr
from ddtrace.contrib.pytest._utils import _pytest_version_supports_efd
from ddtrace.contrib.pytest._utils import _pytest_version_supports_retries
from ddtrace.contrib.pytest._utils import _TestOutcome
from ddtrace.contrib.pytest.constants import FRAMEWORK
from ddtrace.contrib.pytest.constants import XFAIL_REASON
from ddtrace.contrib.pytest.plugin import is_enabled
from ddtrace.contrib.unittest import unpatch as unpatch_unittest
from ddtrace.contrib.internal.pytest._benchmark_utils import _set_benchmark_data_from_item
from ddtrace.contrib.internal.pytest._plugin_v1 import _extract_reason
from ddtrace.contrib.internal.pytest._plugin_v1 import _is_pytest_cov_enabled
from ddtrace.contrib.internal.pytest._types import _pytest_report_teststatus_return_type
from ddtrace.contrib.internal.pytest._types import pytest_CallInfo
from ddtrace.contrib.internal.pytest._types import pytest_Config
from ddtrace.contrib.internal.pytest._types import pytest_TestReport
from ddtrace.contrib.internal.pytest._utils import PYTEST_STATUS
from ddtrace.contrib.internal.pytest._utils import _get_module_path_from_item
from ddtrace.contrib.internal.pytest._utils import _get_names_from_item
from ddtrace.contrib.internal.pytest._utils import _get_session_command
from ddtrace.contrib.internal.pytest._utils import _get_source_file_info
from ddtrace.contrib.internal.pytest._utils import _get_test_id_from_item
from ddtrace.contrib.internal.pytest._utils import _get_test_parameters_json
from ddtrace.contrib.internal.pytest._utils import _is_enabled_early
from ddtrace.contrib.internal.pytest._utils import _is_test_unskippable
from ddtrace.contrib.internal.pytest._utils import _pytest_marked_to_skip
from ddtrace.contrib.internal.pytest._utils import _pytest_version_supports_atr
from ddtrace.contrib.internal.pytest._utils import _pytest_version_supports_efd
from ddtrace.contrib.internal.pytest._utils import _pytest_version_supports_retries
from ddtrace.contrib.internal.pytest._utils import _TestOutcome
from ddtrace.contrib.internal.pytest.constants import FRAMEWORK
from ddtrace.contrib.internal.pytest.constants import XFAIL_REASON
from ddtrace.contrib.internal.pytest.plugin import is_enabled
from ddtrace.contrib.internal.unittest.patch import unpatch as unpatch_unittest
from ddtrace.ext import test
from ddtrace.ext.test_visibility import ITR_SKIPPING_LEVEL
from ddtrace.ext.test_visibility.api import TestExcInfo
Expand All @@ -63,21 +63,21 @@


if _pytest_version_supports_retries():
from ddtrace.contrib.pytest._retry_utils import get_retry_num
from ddtrace.contrib.internal.pytest._retry_utils import get_retry_num

if _pytest_version_supports_efd():
from ddtrace.contrib.pytest._efd_utils import efd_get_failed_reports
from ddtrace.contrib.pytest._efd_utils import efd_get_teststatus
from ddtrace.contrib.pytest._efd_utils import efd_handle_retries
from ddtrace.contrib.pytest._efd_utils import efd_pytest_terminal_summary_post_yield
from ddtrace.contrib.internal.pytest._efd_utils import efd_get_failed_reports
from ddtrace.contrib.internal.pytest._efd_utils import efd_get_teststatus
from ddtrace.contrib.internal.pytest._efd_utils import efd_handle_retries
from ddtrace.contrib.internal.pytest._efd_utils import efd_pytest_terminal_summary_post_yield

if _pytest_version_supports_atr():
from ddtrace.contrib.pytest._atr_utils import atr_get_failed_reports
from ddtrace.contrib.pytest._atr_utils import atr_get_teststatus
from ddtrace.contrib.pytest._atr_utils import atr_handle_retries
from ddtrace.contrib.pytest._atr_utils import atr_pytest_terminal_summary_post_yield
from ddtrace.contrib.pytest._atr_utils import quarantine_atr_get_teststatus
from ddtrace.contrib.pytest._atr_utils import quarantine_pytest_terminal_summary_post_yield
from ddtrace.contrib.internal.pytest._atr_utils import atr_get_failed_reports
from ddtrace.contrib.internal.pytest._atr_utils import atr_get_teststatus
from ddtrace.contrib.internal.pytest._atr_utils import atr_handle_retries
from ddtrace.contrib.internal.pytest._atr_utils import atr_pytest_terminal_summary_post_yield
from ddtrace.contrib.internal.pytest._atr_utils import quarantine_atr_get_teststatus
from ddtrace.contrib.internal.pytest._atr_utils import quarantine_pytest_terminal_summary_post_yield

log = get_logger(__name__)

Expand Down Expand Up @@ -217,7 +217,7 @@ def pytest_configure(config: pytest_Config) -> None:

# pytest-bdd plugin support
if config.pluginmanager.hasplugin("pytest-bdd"):
from ddtrace.contrib.pytest._pytest_bdd_subplugin import _PytestBddSubPlugin
from ddtrace.contrib.internal.pytest._pytest_bdd_subplugin import _PytestBddSubPlugin

config.pluginmanager.register(_PytestBddSubPlugin(), "_datadog-pytest-bdd")
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@

import pytest

from ddtrace.contrib.pytest._utils import _get_test_id_from_item
from ddtrace.contrib.pytest_bdd import get_version
from ddtrace.contrib.pytest_bdd._plugin import _extract_span
from ddtrace.contrib.pytest_bdd._plugin import _get_step_func_args_json
from ddtrace.contrib.pytest_bdd._plugin import _store_span
from ddtrace.contrib.pytest_bdd.constants import FRAMEWORK
from ddtrace.contrib.pytest_bdd.constants import STEP_KIND
from ddtrace.contrib.internal.pytest._utils import _get_test_id_from_item
from ddtrace.contrib.internal.pytest_bdd._plugin import _extract_span
from ddtrace.contrib.internal.pytest_bdd._plugin import _get_step_func_args_json
from ddtrace.contrib.internal.pytest_bdd._plugin import _store_span
from ddtrace.contrib.internal.pytest_bdd.constants import FRAMEWORK
from ddtrace.contrib.internal.pytest_bdd.constants import STEP_KIND
from ddtrace.contrib.internal.pytest_bdd.patch import get_version
from ddtrace.ext import test
from ddtrace.internal.logger import get_logger
from ddtrace.internal.test_visibility.api import InternalTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from _pytest.runner import CallInfo
import pytest

from ddtrace.contrib.pytest._types import tmppath_result_key
from ddtrace.contrib.pytest._utils import _TestOutcome
from ddtrace.contrib.internal.pytest._types import tmppath_result_key
from ddtrace.contrib.internal.pytest._utils import _TestOutcome
from ddtrace.ext.test_visibility.api import TestExcInfo
from ddtrace.ext.test_visibility.api import TestStatus
from ddtrace.internal import core
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import typing as t

from ddtrace.contrib.pytest._utils import _get_pytest_version_tuple
from ddtrace.contrib.internal.pytest._utils import _get_pytest_version_tuple


if _get_pytest_version_tuple() >= (7, 0, 0):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

import pytest

from ddtrace.contrib.pytest.constants import ATR_MIN_SUPPORTED_VERSION
from ddtrace.contrib.pytest.constants import EFD_MIN_SUPPORTED_VERSION
from ddtrace.contrib.pytest.constants import ITR_MIN_SUPPORTED_VERSION
from ddtrace.contrib.pytest.constants import RETRIES_MIN_SUPPORTED_VERSION
from ddtrace.contrib.internal.pytest.constants import ATR_MIN_SUPPORTED_VERSION
from ddtrace.contrib.internal.pytest.constants import EFD_MIN_SUPPORTED_VERSION
from ddtrace.contrib.internal.pytest.constants import ITR_MIN_SUPPORTED_VERSION
from ddtrace.contrib.internal.pytest.constants import RETRIES_MIN_SUPPORTED_VERSION
from ddtrace.ext.test_visibility.api import TestExcInfo
from ddtrace.ext.test_visibility.api import TestModuleId
from ddtrace.ext.test_visibility.api import TestSourceFileInfo
Expand Down
11 changes: 11 additions & 0 deletions ddtrace/contrib/internal/pytest/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FRAMEWORK = "pytest"
KIND = "test"


# XFail Reason
XFAIL_REASON = "pytest.xfail.reason"

ITR_MIN_SUPPORTED_VERSION = (7, 2, 0)
RETRIES_MIN_SUPPORTED_VERSION = (7, 0, 0)
EFD_MIN_SUPPORTED_VERSION = RETRIES_MIN_SUPPORTED_VERSION
ATR_MIN_SUPPORTED_VERSION = RETRIES_MIN_SUPPORTED_VERSION
26 changes: 26 additions & 0 deletions ddtrace/contrib/internal/pytest/newhooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""pytest-ddtrace hooks.
These hooks are used to provide extra data used by the Datadog CI Visibility plugin.
For example: module, suite, and test names for a given item.
Note that these names will affect th display and reporting of tests in the Datadog UI, as well as information stored
the Intelligent Test Runner. Differing hook implementations may impact the behavior of Datadog CI Visibility products.
"""

import pytest


@pytest.hookspec(firstresult=True)
def pytest_ddtrace_get_item_module_name(item: pytest.Item) -> str:
"""Returns the module name to use when reporting CI Visibility results, should be unique"""


@pytest.hookspec(firstresult=True)
def pytest_ddtrace_get_item_suite_name(item: pytest.Item) -> str:
"""Returns the suite name to use when reporting CI Visibility result, should be unique"""


@pytest.hookspec(firstresult=True)
def pytest_ddtrace_get_item_test_name(item: pytest.Item) -> str:
"""Returns the test name to use when reporting CI Visibility result, should be unique"""
6 changes: 6 additions & 0 deletions ddtrace/contrib/internal/pytest/patch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Get version is imported from patch.py in _monkey.py
def get_version():
# type: () -> str
import pytest

return pytest.__version__
Loading

0 comments on commit 38e1f62

Please sign in to comment.