Skip to content

Commit

Permalink
Adding Python 3.10 to test matrix (#146)
Browse files Browse the repository at this point in the history
* Adding Python 3.10 to test matrix

* Updating in more places and supressing warnings

* Adding mypy and upgrading
  • Loading branch information
leahwicz authored Jun 10, 2022
1 parent 0829bd3 commit 9f9a88e
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/scripts/integration-test-matrix.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = ({ context }) => {
const defaultPythonVersion = "3.8";
const supportedPythonVersions = ["3.7", "3.8", "3.9"];
const supportedPythonVersions = ["3.7", "3.8", "3.9", "3.10"];
const supportedAdapters = ["snowflake"];

// if PR, generate matrix based on files changed and PR labels
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.7, 3.8] # TODO: support unit testing for python 3.9 (https://github.com/dbt-labs/dbt/issues/3689)
python-version: ['3.7', '3.8', '3.9', '3.10']

env:
TOXENV: "unit"
Expand Down Expand Up @@ -172,7 +172,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.7, 3.8, 3.9]
python-version: ['3.7', '3.8', '3.9', '3.10']

steps:
- name: Set up Python ${{ matrix.python-version }}
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ repos:
alias: flake8-check
stages: [manual]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.782
rev: v0.942
hooks:
- id: mypy
# N.B.: Mypy is... a bit fragile.
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.MD
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ WARNING: The parameters in your `test.env` file must link to a valid Snowflake a
There are a few methods for running tests locally.

#### `tox`
`tox` automatically runs unit tests against several Python versions using its own virtualenvs. Run `tox -p` to run unit tests for Python 3.7, Python 3.8, Python 3.9, and `flake8` in parallel. Run `tox -e py37` to invoke tests on Python version 3.7 only (use py37, py38, or py39). Tox recipes are found in `tox.ini`.
`tox` automatically runs unit tests against several Python versions using its own virtualenvs. Run `tox -p` to run unit tests for Python 3.7, Python 3.8, Python 3.9, Python 3.10, and `flake8` in parallel. Run `tox -e py37` to invoke tests on Python version 3.7 only (use py37, py38, py39, or py310). Tox recipes are found in `tox.ini`.

#### `pytest`
You may run a specific test or group of tests using `pytest` directly. Activate a Python virtualenv active with dev dependencies installed. Then, run tests like so:
Expand Down
3 changes: 3 additions & 0 deletions dbt/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from pkgutil import extend_path

__path__ = extend_path(__path__, __name__)
6 changes: 4 additions & 2 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-core&subdirectory=core
git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-tests-adapter&subdirectory=tests/adapter

black==21.12b0
black==22.3.0
click~=8.0.4
bumpversion
flake8
flaky
freezegun==0.3.12
ipdb
mypy==0.782
mypy==0.942
pip-tools
pre-commit
pytest
Expand All @@ -20,5 +20,7 @@ pytest-csv
pytest-xdist
pytz
tox>=3.13
types-pytz
types-requests
twine
wheel
2 changes: 2 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[mypy]
namespace_packages = True
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def _get_dbt_core_version():
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
],
python_requires=">=3.7",
)
8 changes: 8 additions & 0 deletions tests/integration/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import tempfile
import traceback
import unittest
import warnings
from contextlib import contextmanager
from datetime import datetime
from functools import wraps
Expand Down Expand Up @@ -251,6 +252,13 @@ def _generate_test_root_dir(self):
return normalize(tempfile.mkdtemp(prefix='dbt-int-test-'))

def setUp(self):
# Logbook warnings are ignored so we don't have to fork logbook to support python 3.10.
# This _only_ works for tests in `test/integration`.
warnings.filterwarnings(
"ignore",
category=DeprecationWarning,
module="logbook"
)
self.dbt_core_install_root = os.path.dirname(dbt.__file__)
log_manager.reset_handlers()
self.initial_dir = INITIAL_ROOT
Expand Down
6 changes: 3 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[tox]
skipsdist = True
envlist = py37,py38,py39
envlist = py37,py38,py39,py310

[testenv:{unit,py37,py38,py39,py}]
[testenv:{unit,py37,py38,py39,py310,py}]
description = unit testing
skip_install = true
passenv = DBT_* PYTEST_ADDOPTS
Expand All @@ -11,7 +11,7 @@ deps =
-rdev-requirements.txt
-e.

[testenv:{integration,py37,py38,py39,py}-{snowflake}]
[testenv:{integration,py37,py38,py39,py310,py}-{snowflake}]
description = adapter plugin integration testing
skip_install = true
passenv = DBT_* SNOWFLAKE_TEST_* PYTEST_ADDOPTS
Expand Down

0 comments on commit 9f9a88e

Please sign in to comment.