Skip to content

Commit

Permalink
Enable unit tests for Python3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
pankajastro committed Jun 3, 2024
1 parent 6ceb7f2 commit 2c04cd6
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,21 @@ 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"
- 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

0 comments on commit 2c04cd6

Please sign in to comment.