Skip to content

Commit 0c7be09

Browse files
committed
fix: address failing tests with pandas 1.5.0
test: add a test session with prerelease versions of dependencies
1 parent 373b71c commit 0c7be09

File tree

4 files changed

+237
-1
lines changed

4 files changed

+237
-1
lines changed

.github/workflows/compliance.yml

+21
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,24 @@ jobs:
2525
COVERAGE_FILE: .coverage-compliance-${{ matrix.python }}
2626
run: |
2727
nox -s compliance
28+
compliance-prerelease:
29+
runs-on: ubuntu-latest
30+
strategy:
31+
matrix:
32+
python: ['3.10']
33+
steps:
34+
- name: Checkout
35+
uses: actions/checkout@v3
36+
- name: Setup Python
37+
uses: actions/setup-python@v3
38+
with:
39+
python-version: ${{ matrix.python }}
40+
- name: Install nox
41+
run: |
42+
python -m pip install --upgrade setuptools pip wheel
43+
python -m pip install nox
44+
- name: Run compliance prerelease tests
45+
env:
46+
COVERAGE_FILE: .coverage-compliance-prerelease-${{ matrix.python }}
47+
run: |
48+
nox -s compliance_prerelease
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
on:
2+
pull_request:
3+
branches:
4+
- main
5+
name: unittest-prerelease
6+
jobs:
7+
unit:
8+
runs-on: ubuntu-latest
9+
strategy:
10+
matrix:
11+
python: ['3.10']
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v3
15+
- name: Setup Python
16+
uses: actions/setup-python@v3
17+
with:
18+
python-version: ${{ matrix.python }}
19+
- name: Install nox
20+
run: |
21+
python -m pip install --upgrade setuptools pip wheel
22+
python -m pip install nox
23+
- name: Run unit tests
24+
env:
25+
COVERAGE_FILE: .coverage-prerelease-${{ matrix.python }}
26+
run: |
27+
nox -s unit_prerelease
28+
- name: Upload coverage results
29+
uses: actions/upload-artifact@v3
30+
with:
31+
name: coverage-artifacts
32+
path: .coverage-${{ matrix.python }}

noxfile.py

+89
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from __future__ import absolute_import
2020
import os
2121
import pathlib
22+
import re
2223
import shutil
2324

2425
import nox
@@ -112,18 +113,106 @@ def default(session, tests_path):
112113
)
113114

114115

116+
def prerelease(session, tests_path):
117+
constraints_path = str(
118+
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
119+
)
120+
121+
# PyArrow prerelease packages are published to an alternative PyPI host.
122+
# https://arrow.apache.org/docs/python/install.html#installing-nightly-packages
123+
session.install(
124+
"--extra-index-url",
125+
"https://pypi.fury.io/arrow-nightlies/",
126+
"--prefer-binary",
127+
"--pre",
128+
"--upgrade",
129+
"pyarrow",
130+
)
131+
session.install(
132+
"--extra-index-url",
133+
"https://pypi.anaconda.org/scipy-wheels-nightly/simple",
134+
"--prefer-binary",
135+
"--pre",
136+
"--upgrade",
137+
"pandas",
138+
)
139+
session.install(
140+
"mock",
141+
"asyncmock",
142+
"pytest",
143+
"pytest-cov",
144+
"pytest-asyncio",
145+
"-c",
146+
constraints_path,
147+
)
148+
149+
# Because we test minimum dependency versions on the minimum Python
150+
# version, the first version we test with in the unit tests sessions has a
151+
# constraints file containing all dependencies and extras.
152+
with open(
153+
CURRENT_DIRECTORY
154+
/ "testing"
155+
/ f"constraints-{UNIT_TEST_PYTHON_VERSIONS[0]}.txt",
156+
encoding="utf-8",
157+
) as constraints_file:
158+
constraints_text = constraints_file.read()
159+
160+
# Ignore leading whitespace and comment lines.
161+
deps = [
162+
match.group(1)
163+
for match in re.finditer(
164+
r"^\s*(\S+)(?===\S+)", constraints_text, flags=re.MULTILINE
165+
)
166+
]
167+
168+
# We use --no-deps to ensure that pre-release versions aren't overwritten
169+
# by the version ranges in setup.py.
170+
session.install(*deps)
171+
session.install("--no-deps", "-e", ".")
172+
173+
# Print out prerelease package versions.
174+
session.run("python", "-m", "pip", "freeze")
175+
176+
# Run py.test against the unit tests.
177+
session.run(
178+
"py.test",
179+
"--quiet",
180+
f"--junitxml=prerelease_unit_{session.python}_sponge_log.xml",
181+
"--cov=db_dtypes",
182+
"--cov=tests/unit",
183+
"--cov-append",
184+
"--cov-config=.coveragerc",
185+
"--cov-report=",
186+
"--cov-fail-under=0",
187+
tests_path,
188+
*session.posargs,
189+
)
190+
191+
115192
@nox.session(python=UNIT_TEST_PYTHON_VERSIONS[-1])
116193
def compliance(session):
117194
"""Run the compliance test suite."""
118195
default(session, os.path.join("tests", "compliance"))
119196

120197

198+
@nox.session(python=UNIT_TEST_PYTHON_VERSIONS[-1])
199+
def compliance_prerelease(session):
200+
"""Run the compliance test suite with prerelease dependencies."""
201+
prerelease(session, os.path.join("tests", "compliance"))
202+
203+
121204
@nox.session(python=UNIT_TEST_PYTHON_VERSIONS)
122205
def unit(session):
123206
"""Run the unit test suite."""
124207
default(session, os.path.join("tests", "unit"))
125208

126209

210+
@nox.session(python=UNIT_TEST_PYTHON_VERSIONS[-1])
211+
def unit_prerelease(session):
212+
"""Run the unit test suite with prerelease dependencies."""
213+
prerelease(session, os.path.join("tests", "unit"))
214+
215+
127216
@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS)
128217
def system(session):
129218
"""Run the system test suite."""

owlbot.py

+95-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@
4949
["noxfile.py"], r"[\"']google[\"']", '"db_dtypes"',
5050
)
5151

52+
s.replace(
53+
["noxfile.py"], r"import shutil", "import re\nimport shutil",
54+
)
55+
5256
s.replace(
5357
["noxfile.py"], "--cov=google", "--cov=db_dtypes",
5458
)
@@ -64,7 +68,9 @@
6468
new_sessions = """
6569
"lint",
6670
"unit",
71+
"unit_prerelease",
6772
"compliance",
73+
"compliance_prerelease",
6874
"cover",
6975
"""
7076

@@ -83,17 +89,105 @@ def unit\(session\):
8389
"""Run the unit test suite."""
8490
default\(session\)
8591
''',
86-
'''
92+
r'''
93+
def prerelease(session, tests_path):
94+
constraints_path = str(
95+
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
96+
)
97+
98+
# PyArrow prerelease packages are published to an alternative PyPI host.
99+
# https://arrow.apache.org/docs/python/install.html#installing-nightly-packages
100+
session.install(
101+
"--extra-index-url",
102+
"https://pypi.fury.io/arrow-nightlies/",
103+
"--prefer-binary",
104+
"--pre",
105+
"--upgrade",
106+
"pyarrow",
107+
)
108+
session.install(
109+
"--extra-index-url",
110+
"https://pypi.anaconda.org/scipy-wheels-nightly/simple",
111+
"--prefer-binary",
112+
"--pre",
113+
"--upgrade",
114+
"pandas",
115+
)
116+
session.install(
117+
"mock",
118+
"asyncmock",
119+
"pytest",
120+
"pytest-cov",
121+
"pytest-asyncio",
122+
"-c",
123+
constraints_path,
124+
)
125+
126+
# Because we test minimum dependency versions on the minimum Python
127+
# version, the first version we test with in the unit tests sessions has a
128+
# constraints file containing all dependencies and extras.
129+
with open(
130+
CURRENT_DIRECTORY
131+
/ "testing"
132+
/ f"constraints-{UNIT_TEST_PYTHON_VERSIONS[0]}.txt",
133+
encoding="utf-8",
134+
) as constraints_file:
135+
constraints_text = constraints_file.read()
136+
137+
# Ignore leading whitespace and comment lines.
138+
deps = [
139+
match.group(1)
140+
for match in re.finditer(
141+
r"^\s*(\S+)(?===\S+)", constraints_text, flags=re.MULTILINE
142+
)
143+
]
144+
145+
# We use --no-deps to ensure that pre-release versions aren't overwritten
146+
# by the version ranges in setup.py.
147+
session.install(*deps)
148+
session.install("--no-deps", "-e", ".")
149+
150+
# Print out prerelease package versions.
151+
session.run("python", "-m", "pip", "freeze")
152+
153+
# Run py.test against the unit tests.
154+
session.run(
155+
"py.test",
156+
"--quiet",
157+
f"--junitxml=prerelease_unit_{session.python}_sponge_log.xml",
158+
"--cov=db_dtypes",
159+
"--cov=tests/unit",
160+
"--cov-append",
161+
"--cov-config=.coveragerc",
162+
"--cov-report=",
163+
"--cov-fail-under=0",
164+
tests_path,
165+
*session.posargs,
166+
)
167+
168+
87169
@nox.session(python=UNIT_TEST_PYTHON_VERSIONS[-1])
88170
def compliance(session):
89171
"""Run the compliance test suite."""
90172
default(session, os.path.join("tests", "compliance"))
91173
92174
175+
@nox.session(python=UNIT_TEST_PYTHON_VERSIONS[-1])
176+
def compliance_prerelease(session):
177+
"""Run the compliance test suite with prerelease dependencies."""
178+
prerelease(session, os.path.join("tests", "compliance"))
179+
180+
93181
@nox.session(python=UNIT_TEST_PYTHON_VERSIONS)
94182
def unit(session):
95183
"""Run the unit test suite."""
96184
default(session, os.path.join("tests", "unit"))
185+
186+
187+
@nox.session(python=UNIT_TEST_PYTHON_VERSIONS[-1])
188+
def unit_prerelease(session):
189+
"""Run the unit test suite with prerelease dependencies."""
190+
prerelease(session, os.path.join("tests", "unit"))
97191
''',
98192
)
99193

0 commit comments

Comments
 (0)