6565 "sqlalchemy_bigquery/requirements.py" ,
6666)
6767
68- s .replace (
69- ["noxfile.py" ],
70- r"[\"']google[\"']" ,
71- '"sqlalchemy_bigquery"' ,
72- )
73-
74- s .replace (
75- ["noxfile.py" ],
76- r"import shutil" ,
77- "import re\n import shutil" ,
78- )
79-
80- s .replace (
81- ["noxfile.py" ],
82- "LINT_PATHS = \[" ,
83- "LINT_PATHS = [\" third_party\" , "
84- )
85-
86- s .replace (
87- ["noxfile.py" ],
88- "--cov=google" ,
89- "--cov=sqlalchemy_bigquery" ,
90- )
91-
92- s .replace (
93- ["noxfile.py" ],
94- """os.path.join("tests", "unit"),""" ,
95- """os.path.join("tests", "unit"),
96- os.path.join("third_party", "sqlalchemy_bigquery_vendored"),""" ,
97- )
98-
99- s .replace (
100- ["noxfile.py" ],
101- "\+ SYSTEM_TEST_EXTRAS" ,
102- "" ,
103- )
104-
105-
106- s .replace (
107- ["noxfile.py" ],
108- """"protobuf",
109- # dependency of grpc""" ,
110- """"protobuf",
111- "sqlalchemy",
112- # dependency of grpc""" ,
113- )
114-
115-
116- s .replace (
117- ["noxfile.py" ],
118- r"def unit\(session, protobuf_implementation\)" ,
119- "def unit(session, protobuf_implementation, install_extras=True)" ,
120- )
121-
122-
123- def place_before (path , text , * before_text , escape = None ):
124- replacement = "\n " .join (before_text ) + "\n " + text
125- if escape :
126- for c in escape :
127- text = text .replace (c , "\\ " + c )
128- s .replace ([path ], text , replacement )
129-
130-
131- place_before (
132- "noxfile.py" ,
133- "nox.options.error_on_missing_interpreters = True" ,
134- "nox.options.stop_on_first_error = True" ,
135- )
136-
137-
138- install_logic = """
139- if install_extras and session.python in ["3.11", "3.12"]:
140- install_target = ".[geography,alembic,tests,bqstorage]"
141- elif install_extras:
142- install_target = ".[all]"
143- else:
144- install_target = "."
145- session.install("-e", install_target, "-c", constraints_path)
146- """
147-
148- s .replace (
149- ["noxfile.py" ],
150- r"# TODO\(https://github.com/googleapis/synthtool/issues/1976\):" ,
151- install_logic + "\n " + "# TODO(https://github.com/googleapis/synthtool/issues/1976):" ,
152- )
153-
154-
155- # Maybe we can get rid of this when we don't need pytest-rerunfailures,
156- # which we won't need when BQ retries itself:
157- # https://github.com/googleapis/python-bigquery/pull/837
158- compliance = '''
159- @nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS[-1])
160- def compliance(session):
161- """Run the SQLAlchemy dialect-compliance system tests"""
162- constraints_path = str(
163- CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
164- )
165- system_test_folder_path = os.path.join("tests", "sqlalchemy_dialect_compliance")
166-
167- if os.environ.get("RUN_COMPLIANCE_TESTS", "true") == "false":
168- session.skip("RUN_COMPLIANCE_TESTS is set to false, skipping")
169- if os.environ.get("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true":
170- session.install("pyopenssl")
171- if not os.path.exists(system_test_folder_path):
172- session.skip("Compliance tests were not found")
173-
174- session.install(
175- "mock",
176- "pytest",
177- "pytest-rerunfailures",
178- "google-cloud-testutils",
179- "-c",
180- constraints_path,
181- )
182- if session.python == "3.8":
183- extras = "[tests,alembic]"
184- elif session.python in ["3.11", "3.12"]:
185- extras = "[tests,geography]"
186- else:
187- extras = "[tests]"
188- session.install("-e", f".{extras}", "-c", constraints_path)
189-
190- session.run("python", "-m", "pip", "freeze")
191-
192- session.run(
193- "py.test",
194- "-vv",
195- f"--junitxml=compliance_{session.python}_sponge_log.xml",
196- "--reruns=3",
197- "--reruns-delay=60",
198- "--only-rerun=Exceeded rate limits",
199- "--only-rerun=Already Exists",
200- "--only-rerun=Not found",
201- "--only-rerun=Cannot execute DML over a non-existent table",
202- "--only-rerun=Job exceeded rate limits",
203- system_test_folder_path,
204- *session.posargs,
205- # To suppress the "Deprecated API features detected!" warning when
206- # features not compatible with 2.0 are detected, use a value of "1"
207- env={
208- "SQLALCHEMY_SILENCE_UBER_WARNING": "1",
209- },
210- )
211-
212-
213- '''
214-
215- place_before (
216- "noxfile.py" ,
217- "@nox.session(python=DEFAULT_PYTHON_VERSION)\n " "def cover(session):" ,
218- compliance ,
219- escape = "()" ,
220- )
221-
222- s .replace (["noxfile.py" ], '"alabaster"' , '"alabaster", "geoalchemy2", "shapely"' )
223-
224-
225- system_noextras = '''
226- @nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS)
227- def system_noextras(session):
228- """Run the system test suite."""
229- constraints_path = str(
230- CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
231- )
232- system_test_path = os.path.join("tests", "system.py")
233- system_test_folder_path = os.path.join("tests", "system")
234-
235- # Check the value of `RUN_SYSTEM_TESTS` env var. It defaults to true.
236- if os.environ.get("RUN_SYSTEM_TESTS", "true") == "false":
237- session.skip("RUN_SYSTEM_TESTS is set to false, skipping")
238- # Install pyopenssl for mTLS testing.
239- if os.environ.get("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true":
240- session.install("pyopenssl")
241-
242- system_test_exists = os.path.exists(system_test_path)
243- system_test_folder_exists = os.path.exists(system_test_folder_path)
244- # Sanity check: only run tests if found.
245- if not system_test_exists and not system_test_folder_exists:
246- session.skip("System tests were not found")
247-
248- global SYSTEM_TEST_EXTRAS_BY_PYTHON
249- SYSTEM_TEST_EXTRAS_BY_PYTHON = False
250- install_systemtest_dependencies(session, "-c", constraints_path)
251-
252- # Run py.test against the system tests.
253- if system_test_exists:
254- session.run(
255- "py.test",
256- "--quiet",
257- f"--junitxml=system_{session.python}_sponge_log.xml",
258- system_test_path,
259- *session.posargs,
260- )
261- if system_test_folder_exists:
262- session.run(
263- "py.test",
264- "--quiet",
265- f"--junitxml=system_{session.python}_sponge_log.xml",
266- system_test_folder_path,
267- *session.posargs,
268- )
269-
270-
271- '''
272-
273-
274- place_before (
275- "noxfile.py" ,
276- "@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS[-1])\n " "def compliance(session):" ,
277- system_noextras ,
278- escape = "()[]" ,
279- )
280-
28168
28269# Add DB config for SQLAlchemy dialect test suite.
28370# https://github.com/googleapis/python-bigquery-sqlalchemy/issues/89
@@ -288,15 +75,6 @@ def system_noextras(session):
28875""" ,
28976)
29077
291-
292- # Make sure build includes all necessary files.
293- s .replace (
294- ["MANIFEST.in" ],
295- re .escape ("recursive-include google" ),
296- """recursive-include third_party/sqlalchemy_bigquery_vendored *
297- recursive-include sqlalchemy_bigquery""" ,
298- )
299-
30078# ----------------------------------------------------------------------------
30179# Samples templates
30280# ----------------------------------------------------------------------------
0 commit comments