Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable unit tests for Python3.12 #1018

Merged
merged 3 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,25 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
airflow-version: ["2.4", "2.5", "2.6", "2.7", "2.8", "2.9"]
exclude:
- python-version: "3.11"
airflow-version: "2.4"
# Apache Airflow versions prior to 2.9.0 have not been tested with Python 3.12.
# Official support for Python 3.12 and the corresponding constraints.txt are available only for Apache Airflow >= 2.9.0.
# See: https://github.com/apache/airflow/tree/2.9.0?tab=readme-ov-file#requirements
# See: https://github.com/apache/airflow/tree/2.8.4?tab=readme-ov-file#requirements
- python-version: "3.12"
airflow-version: "2.4"
- python-version: "3.12"
airflow-version: "2.5"
- python-version: "3.12"
airflow-version: "2.6"
- python-version: "3.12"
airflow-version: "2.7"
- python-version: "3.12"
airflow-version: "2.8"
steps:
- uses: actions/checkout@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ dependencies = [
pre-install-commands = ["sh scripts/test/pre-install-airflow.sh {matrix:airflow} {matrix:python}"]

[[tool.hatch.envs.tests.matrix]]
python = ["3.8", "3.9", "3.10", "3.11"]
python = ["3.8", "3.9", "3.10", "3.11", "3.12"]
airflow = ["2.4", "2.5", "2.6", "2.7", "2.8", "2.9"]

[tool.hatch.envs.tests.overrides]
Expand Down
19 changes: 19 additions & 0 deletions tests/operators/test_base.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys
from unittest.mock import patch

import pytest
Expand All @@ -14,6 +15,10 @@
)


@pytest.mark.skipif(
(sys.version_info.major, sys.version_info.minor) == (3, 12),
reason="The error message for the abstract class instantiation seems to have changed between Python 3.11 and 3.12",
)
def test_dbt_base_operator_is_abstract():
"""Tests that the abstract base operator cannot be instantiated since the base_cmd is not defined."""
expected_error = (
Expand All @@ -23,6 +28,20 @@ def test_dbt_base_operator_is_abstract():
AbstractDbtBaseOperator()


@pytest.mark.skipif(
(sys.version_info.major, sys.version_info.minor) != (3, 12),
reason="The error message for the abstract class instantiation seems to have changed between Python 3.11 and 3.12",
)
def test_dbt_base_operator_is_abstract_py12():
"""Tests that the abstract base operator cannot be instantiated since the base_cmd is not defined."""
expected_error = (
"Can't instantiate abstract class AbstractDbtBaseOperator without an implementation for abstract methods "
"'base_cmd', 'build_and_run_cmd'"
)
with pytest.raises(TypeError, match=expected_error):
AbstractDbtBaseOperator()


@pytest.mark.parametrize("cmd_flags", [["--some-flag"], []])
@patch("cosmos.operators.base.AbstractDbtBaseOperator.build_and_run_cmd")
def test_dbt_base_operator_execute(mock_build_and_run_cmd, cmd_flags, monkeypatch):
Expand Down
Loading