Skip to content

Commit 1bdf1cd

Browse files
SNOW-706773 adding back extras tests (#1372)
1 parent dcf10e8 commit 1bdf1cd

File tree

6 files changed

+54
-8
lines changed

6 files changed

+54
-8
lines changed

.github/workflows/build_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ jobs:
158158
- name: Install tox
159159
run: python -m pip install tox tox-external-wheels
160160
- name: Run tests
161-
run: python -m tox -e "py${PYTHON_VERSION/\./}-{unit,integ,pandas,sso}-ci"
161+
run: python -m tox -e "py${PYTHON_VERSION/\./}-{extras,unit,integ,pandas,sso}-ci"
162162
env:
163163
PYTHON_VERSION: ${{ matrix.python-version }}
164164
cloud_provider: ${{ matrix.cloud-provider }}

test/extras/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Extra tests that should run separately
2+
3+
## Running tests
4+
5+
These are tests that test weird edge cases when we need a standalone Python environment
6+
and process.
7+
8+
Run only these tests with `tox`, for example: `tox -e py38-extras` from the
9+
top directory.

test/extras/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#
2+
# Copyright (c) 2012-2021 Snowflake Computing Inc. All rights reserved.
3+
#

test/extras/run.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#
2+
# Copyright (c) 2012-2021 Snowflake Computing Inc. All rights reserved.
3+
#
4+
import pathlib
5+
import subprocess
6+
import sys
7+
8+
# This script run every Python file in this directory other than this
9+
# one in a subprocess and checks their exit codes
10+
11+
12+
file_ignore_list = ["run.py", "__init__.py"]
13+
14+
for test_file in pathlib.Path(__file__).parent.glob("*.py"):
15+
if test_file.name not in file_ignore_list:
16+
print(f"Running {test_file}")
17+
sub_process = subprocess.run(
18+
[
19+
sys.executable if sys.executable else "python",
20+
"-m",
21+
f"test.extras.{test_file.name[:-3]}",
22+
]
23+
)
24+
sub_process.check_returncode()

test/extras/simple_select1.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#
2+
# Copyright (c) 2012-2021 Snowflake Computing Inc. All rights reserved.
3+
#
4+
5+
from snowflake.connector import connect
6+
7+
from ..parameters import CONNECTION_PARAMETERS
8+
9+
with connect(**CONNECTION_PARAMETERS) as conn:
10+
with conn.cursor() as cur:
11+
assert cur.execute("select 1;").fetchall() == [
12+
(1,),
13+
]

tox.ini

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ source = src/snowflake/connector
1818
[tox]
1919
minversion = 3.7
2020
envlist = fix_lint,
21-
py{37,38,39,310}-{unit-parallel,integ,pandas,sso},
21+
py{37,38,39,310}-{extras,unit-parallel,integ,pandas,sso},
2222
coverage
2323
skip_missing_interpreters = true
2424
requires =
@@ -30,8 +30,6 @@ extras =
3030
development
3131
pandas: pandas
3232
sso: secure-local-storage
33-
deps =
34-
pip >= 19.3.1
3533
install_command = python -m pip install -U {opts} {packages}
3634
external_wheels =
3735
py37-ci: dist/*cp37*.whl
@@ -68,10 +66,11 @@ passenv =
6866
commands =
6967
# Test environments
7068
# Note: make sure to have a default env and all the other special ones
71-
!pandas-!sso-!lambda: {env:SNOWFLAKE_PYTEST_CMD} -m "{env:SNOWFLAKE_TEST_TYPE} and not sso and not pandas and not lambda" {posargs:} test
69+
!pandas-!sso-!lambda-!extras: {env:SNOWFLAKE_PYTEST_CMD} -m "{env:SNOWFLAKE_TEST_TYPE} and not sso and not pandas and not lambda" {posargs:} test
7270
pandas: {env:SNOWFLAKE_PYTEST_CMD} -m "{env:SNOWFLAKE_TEST_TYPE} and pandas" {posargs:} test
7371
sso: {env:SNOWFLAKE_PYTEST_CMD} -m "{env:SNOWFLAKE_TEST_TYPE} and sso" {posargs:} test
7472
lambda: {env:SNOWFLAKE_PYTEST_CMD} -m "{env:SNOWFLAKE_TEST_TYPE} and lambda" {posargs:} test
73+
extras: python -m test.extras.run {posargs:}
7574

7675
[testenv:olddriver]
7776
basepython = python3.7
@@ -97,7 +96,7 @@ commands =
9796
[testenv:coverage]
9897
description = [run locally after tests]: combine coverage data and create report
9998
; generates a diff coverage against origin/master (can be changed by setting DIFF_AGAINST env var)
100-
deps = {[testenv]deps}
99+
deps =
101100
coverage
102101
; diff_cover
103102
skip_install = True
@@ -132,7 +131,6 @@ description = format the code base to adhere to our styles, and complain about w
132131
passenv =
133132
PROGRAMDATA
134133
deps =
135-
{[testenv]deps}
136134
pre-commit >= 2.9.0
137135
skip_install = True
138136
commands = pre-commit run --all-files
@@ -141,7 +139,6 @@ commands = pre-commit run --all-files
141139
[testenv:dependency]
142140
description = Check if there is conflicting dependency
143141
deps =
144-
{[testenv]deps}
145142
pip-tools
146143
skip_install = True
147144
commands = pip-compile setup.py

0 commit comments

Comments
 (0)