Skip to content

Commit 4197086

Browse files
committed
updates test sessions in noxfile.py and adds init.py files
1 parent 782fd9e commit 4197086

File tree

4 files changed

+8
-172
lines changed

4 files changed

+8
-172
lines changed

scripts/__init__.py

Whitespace-only changes.

scripts/microgenerator/noxfile.py

Lines changed: 8 additions & 172 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
from functools import wraps
1818
import pathlib
1919
import os
20-
import shutil
2120
import nox
2221
import time
2322

@@ -28,7 +27,6 @@
2827
BLACK_PATHS = (".",)
2928

3029
DEFAULT_PYTHON_VERSION = "3.9"
31-
SYSTEM_TEST_PYTHON_VERSIONS = ["3.9", "3.11", "3.12", "3.13"]
3230
UNIT_TEST_PYTHON_VERSIONS = ["3.9", "3.11", "3.12", "3.13"]
3331
CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()
3432

@@ -56,14 +54,12 @@ def wrapper(*args, **kwargs):
5654
# 'docfx' is excluded since it only needs to run in 'docs-presubmit'
5755
nox.options.sessions = [
5856
"unit",
59-
"system",
6057
"cover",
6158
"lint",
6259
"lint_setup_py",
6360
"blacken",
6461
"mypy",
6562
"pytype",
66-
"docs",
6763
]
6864

6965

@@ -95,10 +91,8 @@ def default(session, install_extras=True):
9591
# If no, we use our own context object from magics.py. In order to exercise
9692
# that logic (and the associated tests) we avoid installing the [ipython] extra
9793
# which has a downstream effect of then avoiding installing bigquery_magics.
98-
if install_extras and session.python == UNIT_TEST_PYTHON_VERSIONS[0]:
99-
install_target = ".[bqstorage,pandas,ipywidgets,geopandas,matplotlib,tqdm,opentelemetry,bigquery_v2]"
100-
elif install_extras: # run against all other UNIT_TEST_PYTHON_VERSIONS
101-
install_target = ".[all]"
94+
if install_extras: # run against all other UNIT_TEST_PYTHON_VERSIONS
95+
install_target = "."
10296
else:
10397
install_target = "."
10498
session.install("-e", install_target, "-c", constraints_path)
@@ -107,9 +101,6 @@ def default(session, install_extras=True):
107101
# directly. For example, pandas-gbq is recommended for pandas features, but
108102
# we want to test that we fallback to the previous behavior. For context,
109103
# see internal document go/pandas-gbq-and-bigframes-redundancy.
110-
if session.python == UNIT_TEST_PYTHON_VERSIONS[0]:
111-
session.run("python", "-m", "pip", "uninstall", "pandas-gbq", "-y")
112-
113104
session.run("python", "-m", "pip", "freeze")
114105

115106
# Run py.test against the unit tests.
@@ -118,13 +109,12 @@ def default(session, install_extras=True):
118109
"-n=8",
119110
"--quiet",
120111
"-W default::PendingDeprecationWarning",
121-
"--cov=google/cloud/bigquery",
122-
"--cov=tests/unit",
112+
"--cov=scripts.microgenerator",
123113
"--cov-append",
124114
"--cov-config=.coveragerc",
125115
"--cov-report=",
126116
"--cov-fail-under=0",
127-
os.path.join("tests", "unit"),
117+
"tests/unit",
128118
*session.posargs,
129119
)
130120

@@ -142,7 +132,7 @@ def unit(session):
142132
def mypy(session):
143133
"""Run type checks with mypy."""
144134

145-
session.install("-e", ".[all]")
135+
session.install("-e", ".")
146136
session.install(MYPY_VERSION)
147137

148138
# Just install the dependencies' type info directly, since "mypy --install-types"
@@ -166,77 +156,11 @@ def pytype(session):
166156
# https://github.com/googleapis/python-bigquery/issues/655
167157

168158
session.install("attrs==20.3.0")
169-
session.install("-e", ".[all]")
159+
session.install("-e", ".")
170160
session.install(PYTYPE_VERSION)
171161
session.run("python", "-m", "pip", "freeze")
172162
# See https://github.com/google/pytype/issues/464
173-
session.run("pytype", "-P", ".", "google/cloud/bigquery")
174-
175-
176-
@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS)
177-
@_calculate_duration
178-
def system(session):
179-
"""Run the system test suite."""
180-
181-
constraints_path = str(
182-
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
183-
)
184-
185-
# Sanity check: Only run system tests if the environment variable is set.
186-
if not os.environ.get("GOOGLE_APPLICATION_CREDENTIALS", ""):
187-
session.skip("Credentials must be set via environment variable.")
188-
189-
# Use pre-release gRPC for system tests.
190-
# Exclude version 1.49.0rc1 which has a known issue.
191-
# See https://github.com/grpc/grpc/pull/30642
192-
session.install("--pre", "grpcio!=1.49.0rc1", "-c", constraints_path)
193-
194-
# Install all test dependencies, then install local packages in place.
195-
session.install(
196-
"pytest",
197-
"psutil",
198-
"pytest-xdist",
199-
"google-cloud-testutils",
200-
"-c",
201-
constraints_path,
202-
)
203-
if os.environ.get("GOOGLE_API_USE_CLIENT_CERTIFICATE", "") == "true":
204-
# mTLS test requires pyopenssl and latest google-cloud-storage
205-
session.install("google-cloud-storage", "pyopenssl")
206-
else:
207-
session.install("google-cloud-storage", "-c", constraints_path)
208-
209-
# Data Catalog needed for the column ACL test with a real Policy Tag.
210-
session.install("google-cloud-datacatalog", "-c", constraints_path)
211-
212-
# Resource Manager needed for test with a real Resource Tag.
213-
session.install("google-cloud-resource-manager", "-c", constraints_path)
214-
215-
if session.python in ["3.11", "3.12"]:
216-
extras = "[bqstorage,ipywidgets,pandas,tqdm,opentelemetry]"
217-
else:
218-
extras = "[all]"
219-
session.install("-e", f".{extras}", "-c", constraints_path)
220-
221-
# Test with some broken "extras" in case the user didn't install the extra
222-
# directly. For example, pandas-gbq is recommended for pandas features, but
223-
# we want to test that we fallback to the previous behavior. For context,
224-
# see internal document go/pandas-gbq-and-bigframes-redundancy.
225-
if session.python == SYSTEM_TEST_PYTHON_VERSIONS[0]:
226-
session.run("python", "-m", "pip", "uninstall", "pandas-gbq", "-y")
227-
228-
# print versions of all dependencies
229-
session.run("python", "-m", "pip", "freeze")
230-
231-
# Run py.test against the system tests.
232-
session.run(
233-
"py.test",
234-
"-n=auto",
235-
"--quiet",
236-
"-W default::PendingDeprecationWarning",
237-
os.path.join("tests", "system"),
238-
*session.posargs,
239-
)
163+
session.run("pytype", "-P", ".", "scripts")
240164

241165

242166
@nox.session(python=DEFAULT_PYTHON_VERSION)
@@ -266,10 +190,8 @@ def lint(session):
266190
session.install("flake8", BLACK_VERSION)
267191
session.install("-e", ".")
268192
session.run("python", "-m", "pip", "freeze")
269-
session.run("flake8", os.path.join("google", "cloud", "bigquery"))
193+
session.run("flake8", os.path.join("scripts"))
270194
session.run("flake8", "tests")
271-
session.run("flake8", os.path.join("docs", "samples"))
272-
session.run("flake8", os.path.join("docs", "snippets.py"))
273195
session.run("flake8", "benchmark")
274196
session.run("black", "--check", *BLACK_PATHS)
275197

@@ -294,89 +216,3 @@ def blacken(session):
294216
session.install(BLACK_VERSION)
295217
session.run("python", "-m", "pip", "freeze")
296218
session.run("black", *BLACK_PATHS)
297-
298-
299-
@nox.session(python="3.10")
300-
@_calculate_duration
301-
def docs(session):
302-
"""Build the docs."""
303-
304-
session.install(
305-
# We need to pin to specific versions of the `sphinxcontrib-*` packages
306-
# which still support sphinx 4.x.
307-
# See https://github.com/googleapis/sphinx-docfx-yaml/issues/344
308-
# and https://github.com/googleapis/sphinx-docfx-yaml/issues/345.
309-
"sphinxcontrib-applehelp==1.0.4",
310-
"sphinxcontrib-devhelp==1.0.2",
311-
"sphinxcontrib-htmlhelp==2.0.1",
312-
"sphinxcontrib-qthelp==1.0.3",
313-
"sphinxcontrib-serializinghtml==1.1.5",
314-
"sphinx==4.5.0",
315-
"alabaster",
316-
"recommonmark",
317-
)
318-
session.install("google-cloud-storage")
319-
session.install("-e", ".[all]")
320-
321-
shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True)
322-
session.run("python", "-m", "pip", "freeze")
323-
session.run(
324-
"sphinx-build",
325-
"-W", # warnings as errors
326-
"-T", # show full traceback on exception
327-
"-N", # no colors
328-
"-b",
329-
"html",
330-
"-d",
331-
os.path.join("docs", "_build", "doctrees", ""),
332-
os.path.join("docs", ""),
333-
os.path.join("docs", "_build", "html", ""),
334-
)
335-
336-
337-
@nox.session(python="3.10")
338-
@_calculate_duration
339-
def docfx(session):
340-
"""Build the docfx yaml files for this library."""
341-
342-
session.install("-e", ".")
343-
session.install(
344-
# We need to pin to specific versions of the `sphinxcontrib-*` packages
345-
# which still support sphinx 4.x.
346-
# See https://github.com/googleapis/sphinx-docfx-yaml/issues/344
347-
# and https://github.com/googleapis/sphinx-docfx-yaml/issues/345.
348-
"sphinxcontrib-applehelp==1.0.4",
349-
"sphinxcontrib-devhelp==1.0.2",
350-
"sphinxcontrib-htmlhelp==2.0.1",
351-
"sphinxcontrib-qthelp==1.0.3",
352-
"sphinxcontrib-serializinghtml==1.1.5",
353-
"gcp-sphinx-docfx-yaml",
354-
"alabaster",
355-
"recommonmark",
356-
)
357-
358-
shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True)
359-
session.run("python", "-m", "pip", "freeze")
360-
session.run(
361-
"sphinx-build",
362-
"-T", # show full traceback on exception
363-
"-N", # no colors
364-
"-D",
365-
(
366-
"extensions=sphinx.ext.autodoc,"
367-
"sphinx.ext.autosummary,"
368-
"docfx_yaml.extension,"
369-
"sphinx.ext.intersphinx,"
370-
"sphinx.ext.coverage,"
371-
"sphinx.ext.napoleon,"
372-
"sphinx.ext.todo,"
373-
"sphinx.ext.viewcode,"
374-
"recommonmark"
375-
),
376-
"-b",
377-
"html",
378-
"-d",
379-
os.path.join("docs", "_build", "doctrees", ""),
380-
os.path.join("docs", ""),
381-
os.path.join("docs", "_build", "html", ""),
382-
)

scripts/microgenerator/tests/__init__.py

Whitespace-only changes.

scripts/microgenerator/tests/unit/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)