4949 ["noxfile.py" ], r"[\"']google[\"']" , '"db_dtypes"' ,
5050)
5151
52+ s .replace (
53+ ["noxfile.py" ], r"import shutil" , "import re\n import shutil" ,
54+ )
55+
5256s .replace (
5357 ["noxfile.py" ], "--cov=google" , "--cov=db_dtypes" ,
5458)
6468new_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])
88170def 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)
94182def 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