Skip to content

Commit

Permalink
Fix Non-DB test calculation for main builds (apache#41499)
Browse files Browse the repository at this point in the history
Pytest has a weird behaviour that it will not collect tests
from parent folder when subfolder of it is specified after the
parent folder. This caused some non-db tests from providers folder
have been skipped during main build.

The issue in Pytest 8.2 (used to work before) is tracked at
pytest-dev/pytest#12605
  • Loading branch information
potiuk authored Aug 15, 2024
1 parent 666183f commit d489826
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
14 changes: 11 additions & 3 deletions dev/breeze/src/airflow_breeze/utils/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ def generate_args_for_pytest(
args.extend(get_excluded_provider_args(python_version))
if use_xdist:
args.extend(["-n", str(parallelism) if parallelism else "auto"])
# We have to disabke coverage for Python 3.12 because of the issue with coverage that takes too long, despite
# We have to disable coverage for Python 3.12 because of the issue with coverage that takes too long, despite
# Using experimental support for Python 3.12 PEP 669. The coverage.py is not yet fully compatible with the
# full scope of PEP-669. That will be fully done when https://github.com/nedbat/coveragepy/issues/1746 is
# resolve for now we are disabling coverage for Python 3.12, and it causes slower execution and occasional
Expand Down Expand Up @@ -417,5 +417,13 @@ def convert_parallel_types_to_folders(
python_version=python_version,
)
)
# leave only folders, strip --pytest-args
return [arg for arg in args if arg.startswith("test")]
# leave only folders, strip --pytest-args that exclude some folders with `-' prefix
folders = [arg for arg in args if arg.startswith("test")]
# remove specific provider sub-folders if "tests/providers" is already in the list
# This workarounds pytest issues where it will only run tests from specific subfolders
# if both parent and child folders are in the list
# The issue in Pytest (changed behaviour in Pytest 8.2 is tracked here
# https://github.com/pytest-dev/pytest/issues/12605
if "tests/providers" in folders:
folders = [folder for folder in folders if not folder.startswith("tests/providers/")]
return folders
13 changes: 13 additions & 0 deletions dev/breeze/tests/test_pytest_args_for_test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,19 @@ def test_pytest_args_for_helm_test_types(helm_test_package: str, pytest_args: li
],
True,
),
(
"Core Providers[-amazon,google] Providers[amazon] Providers[google]",
[
"tests/core",
"tests/executors",
"tests/jobs",
"tests/models",
"tests/ti_deps",
"tests/utils",
"tests/providers",
],
False,
),
],
)
def test_folders_for_parallel_test_types(
Expand Down

0 comments on commit d489826

Please sign in to comment.