google-cloud-testutils 1.4.0__tar.gz → 1.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. {google-cloud-testutils-1.4.0/google_cloud_testutils.egg-info → google_cloud_testutils-1.5.0}/PKG-INFO +2 -1
  2. {google-cloud-testutils-1.4.0 → google_cloud_testutils-1.5.0/google_cloud_testutils.egg-info}/PKG-INFO +2 -1
  3. {google-cloud-testutils-1.4.0 → google_cloud_testutils-1.5.0}/setup.py +2 -1
  4. {google-cloud-testutils-1.4.0 → google_cloud_testutils-1.5.0}/tests/unit/resources/bad_package/setup.py +2 -2
  5. {google-cloud-testutils-1.4.0 → google_cloud_testutils-1.5.0}/tests/unit/resources/good_package/setup.py +2 -2
  6. {google-cloud-testutils-1.4.0 → google_cloud_testutils-1.5.0}/tests/unit/test_lower_bound_checker.py +82 -19
  7. {google-cloud-testutils-1.4.0 → google_cloud_testutils-1.5.0}/LICENSE +0 -0
  8. {google-cloud-testutils-1.4.0 → google_cloud_testutils-1.5.0}/MANIFEST.in +0 -0
  9. {google-cloud-testutils-1.4.0 → google_cloud_testutils-1.5.0}/README.rst +0 -0
  10. {google-cloud-testutils-1.4.0 → google_cloud_testutils-1.5.0}/google_cloud_testutils.egg-info/SOURCES.txt +0 -0
  11. {google-cloud-testutils-1.4.0 → google_cloud_testutils-1.5.0}/google_cloud_testutils.egg-info/dependency_links.txt +0 -0
  12. {google-cloud-testutils-1.4.0 → google_cloud_testutils-1.5.0}/google_cloud_testutils.egg-info/entry_points.txt +0 -0
  13. {google-cloud-testutils-1.4.0 → google_cloud_testutils-1.5.0}/google_cloud_testutils.egg-info/not-zip-safe +0 -0
  14. {google-cloud-testutils-1.4.0 → google_cloud_testutils-1.5.0}/google_cloud_testutils.egg-info/requires.txt +0 -0
  15. {google-cloud-testutils-1.4.0 → google_cloud_testutils-1.5.0}/google_cloud_testutils.egg-info/top_level.txt +0 -0
  16. {google-cloud-testutils-1.4.0 → google_cloud_testutils-1.5.0}/setup.cfg +0 -0
  17. {google-cloud-testutils-1.4.0 → google_cloud_testutils-1.5.0}/test_utils/__init__.py +0 -0
  18. {google-cloud-testutils-1.4.0 → google_cloud_testutils-1.5.0}/test_utils/imports.py +0 -0
  19. {google-cloud-testutils-1.4.0 → google_cloud_testutils-1.5.0}/test_utils/lower_bound_checker/__init__.py +0 -0
  20. {google-cloud-testutils-1.4.0 → google_cloud_testutils-1.5.0}/test_utils/lower_bound_checker/lower_bound_checker.py +0 -0
  21. {google-cloud-testutils-1.4.0 → google_cloud_testutils-1.5.0}/test_utils/orchestrate.py +0 -0
  22. {google-cloud-testutils-1.4.0 → google_cloud_testutils-1.5.0}/test_utils/prefixer.py +0 -0
  23. {google-cloud-testutils-1.4.0 → google_cloud_testutils-1.5.0}/test_utils/py.typed +0 -0
  24. {google-cloud-testutils-1.4.0 → google_cloud_testutils-1.5.0}/test_utils/retry.py +0 -0
  25. {google-cloud-testutils-1.4.0 → google_cloud_testutils-1.5.0}/test_utils/system.py +0 -0
  26. {google-cloud-testutils-1.4.0 → google_cloud_testutils-1.5.0}/test_utils/vpcsc_config.py +0 -0
  27. {google-cloud-testutils-1.4.0 → google_cloud_testutils-1.5.0}/tests/unit/test_orchestrate.py +0 -0
  28. {google-cloud-testutils-1.4.0 → google_cloud_testutils-1.5.0}/tests/unit/test_prefixer.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: google-cloud-testutils
3
- Version: 1.4.0
3
+ Version: 1.5.0
4
4
  Home-page: https://github.com/googleapis/python-test-utils
5
5
  Author: Google LLC
6
6
  Author-email: googleapis-packages@google.com
@@ -16,6 +16,7 @@ Classifier: Programming Language :: Python :: 3.9
16
16
  Classifier: Programming Language :: Python :: 3.10
17
17
  Classifier: Programming Language :: Python :: 3.11
18
18
  Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
19
20
  Classifier: Topic :: Internet
20
21
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
22
  Requires-Python: >=3.7
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: google-cloud-testutils
3
- Version: 1.4.0
3
+ Version: 1.5.0
4
4
  Home-page: https://github.com/googleapis/python-test-utils
5
5
  Author: Google LLC
6
6
  Author-email: googleapis-packages@google.com
@@ -16,6 +16,7 @@ Classifier: Programming Language :: Python :: 3.9
16
16
  Classifier: Programming Language :: Python :: 3.10
17
17
  Classifier: Programming Language :: Python :: 3.11
18
18
  Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
19
20
  Classifier: Topic :: Internet
20
21
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
22
  Requires-Python: >=3.7
@@ -16,7 +16,7 @@ import io
16
16
  import os
17
17
  import setuptools # type: ignore
18
18
 
19
- version = "1.4.0"
19
+ version = "1.5.0"
20
20
 
21
21
  package_root = os.path.abspath(os.path.dirname(__file__))
22
22
 
@@ -64,6 +64,7 @@ setuptools.setup(
64
64
  "Programming Language :: Python :: 3.10",
65
65
  "Programming Language :: Python :: 3.11",
66
66
  "Programming Language :: Python :: 3.12",
67
+ "Programming Language :: Python :: 3.13",
67
68
  "Topic :: Internet",
68
69
  "Topic :: Software Development :: Libraries :: Python Modules",
69
70
  ],
@@ -17,8 +17,8 @@ import setuptools
17
17
 
18
18
  requirements = [
19
19
  "requests", # no lower bound
20
- "packaging>=14.0, !=15.0, <22.0.0", # too complex for tool
21
- "wheel<0.42.0",
20
+ "packaging>=14.0, !=15.0", # too complex for tool
21
+ "wheel<0.45.0",
22
22
  "click==7.0.0",
23
23
  ]
24
24
 
@@ -20,8 +20,8 @@ import setuptools
20
20
  # extracts lower bounds.
21
21
  requirements = [
22
22
  "requests>=1.0.0",
23
- "packaging>=14.0, <22.0.0",
24
- "wheel<0.42.0, >=0.41.0",
23
+ "packaging>=14.0",
24
+ "wheel >=0.41.0",
25
25
  "click==7.0.0",
26
26
  ]
27
27
 
@@ -16,11 +16,18 @@ from contextlib import contextmanager
16
16
  from pathlib import Path
17
17
  import re
18
18
  import tempfile
19
+ import sys
19
20
  from typing import List
20
21
 
21
22
  from click.testing import CliRunner
22
23
  import pytest # type: ignore
23
24
 
25
+ if sys.version_info >= (3, 8):
26
+ import importlib.metadata as importlib_metadata
27
+ else:
28
+ # For Python 3.7 compatibility
29
+ import importlib_metadata
30
+
24
31
  from test_utils.lower_bound_checker import lower_bound_checker
25
32
 
26
33
  RUNNER = CliRunner()
@@ -34,9 +41,19 @@ GOOD_PACKAGE = "valid-package"
34
41
  BAD_PACKAGE = "invalid-package"
35
42
 
36
43
 
44
+ def skip_test_if_not_installed(package_name: str):
45
+ """Skips the current test if given package is not installed"""
46
+ try:
47
+ importlib_metadata.distribution(package_name)
48
+ except importlib_metadata.PackageNotFoundError:
49
+ pytest.skip(
50
+ f"Skipping test which requires {package_name} in `tests/unit/resources/` to be installed"
51
+ )
52
+
53
+
37
54
  def parse_error_msg(msg: str) -> List[str]:
38
55
  """Get package names from the error message.
39
-
56
+
40
57
  Example:
41
58
  Error: setup.py is missing explicit lower bounds for the following packages: ["requests", "grpcio"]
42
59
  """
@@ -47,12 +64,13 @@ def parse_error_msg(msg: str) -> List[str]:
47
64
  if match:
48
65
  reqs = match.groups(1)[0].split(",") # type: ignore
49
66
  reqs = [r.strip().replace("'", "").replace('"', "") for r in reqs]
50
-
67
+
51
68
  return reqs
52
69
 
70
+
53
71
  def parse_diff_versions_error_msg(msg: str) -> List[str]:
54
72
  """Get package names from the error message listing different versions
55
-
73
+
56
74
  Example:
57
75
  'requests' lower bound is 1.2.0 in setup.py but constraints file has 1.3.0
58
76
  'grpcio' lower bound is 1.0.0 in setup.py but constraints file has 1.10.0
@@ -62,6 +80,7 @@ def parse_diff_versions_error_msg(msg: str) -> List[str]:
62
80
 
63
81
  return pkg_names
64
82
 
83
+
65
84
  @contextmanager
66
85
  def constraints_file(requirements: List[str]):
67
86
  """Write the list of requirements into a temporary file"""
@@ -76,23 +95,38 @@ def constraints_file(requirements: List[str]):
76
95
 
77
96
 
78
97
  def test_update_constraints():
98
+ skip_test_if_not_installed(GOOD_PACKAGE)
99
+
79
100
  with tempfile.TemporaryDirectory() as tmpdir:
80
101
  constraints_path = Path(tmpdir) / "constraints.txt"
81
102
 
82
103
  result = RUNNER.invoke(
83
- lower_bound_checker.update, ["--package-name", GOOD_PACKAGE, "--constraints-file", str(constraints_path)]
104
+ lower_bound_checker.update,
105
+ [
106
+ "--package-name",
107
+ GOOD_PACKAGE,
108
+ "--constraints-file",
109
+ str(constraints_path),
110
+ ],
84
111
  )
85
112
 
86
113
  assert result.exit_code == 0
87
114
  assert constraints_path.exists()
88
-
89
- output = constraints_path.read_text().split("\n")
90
115
 
91
- assert output == ["click==7.0.0", "grpcio==1.0.0", "packaging==14.0", "requests==1.0.0", "wheel==0.41.0",]
116
+ output = constraints_path.read_text().split("\n")
92
117
 
118
+ assert output == [
119
+ "click==7.0.0",
120
+ "grpcio==1.0.0",
121
+ "packaging==14.0",
122
+ "requests==1.0.0",
123
+ "wheel==0.41.0",
124
+ ]
93
125
 
94
126
 
95
127
  def test_update_constraints_overwrites_existing_file():
128
+ skip_test_if_not_installed(GOOD_PACKAGE)
129
+
96
130
  constraints = [
97
131
  "requests==1.0.0",
98
132
  "packaging==13.0",
@@ -101,16 +135,25 @@ def test_update_constraints_overwrites_existing_file():
101
135
  ]
102
136
  with constraints_file(constraints) as c:
103
137
  result = RUNNER.invoke(
104
- lower_bound_checker.update, ["--package-name", GOOD_PACKAGE, "--constraints-file", c]
138
+ lower_bound_checker.update,
139
+ ["--package-name", GOOD_PACKAGE, "--constraints-file", c],
105
140
  )
106
141
 
107
142
  assert result.exit_code == 0
108
143
 
109
144
  output = c.read_text().split("\n")
110
- assert output == ["click==7.0.0", "grpcio==1.0.0", "packaging==14.0", "requests==1.0.0", "wheel==0.41.0",
145
+ assert output == [
146
+ "click==7.0.0",
147
+ "grpcio==1.0.0",
148
+ "packaging==14.0",
149
+ "requests==1.0.0",
150
+ "wheel==0.41.0",
111
151
  ]
112
152
 
153
+
113
154
  def test_update_constraints_with_setup_py_missing_lower_bounds():
155
+ skip_test_if_not_installed(BAD_PACKAGE)
156
+
114
157
  constraints = [
115
158
  "requests==1.0.0",
116
159
  "packaging==14.0",
@@ -119,7 +162,8 @@ def test_update_constraints_with_setup_py_missing_lower_bounds():
119
162
  ]
120
163
  with constraints_file(constraints) as c:
121
164
  result = RUNNER.invoke(
122
- lower_bound_checker.update, ["--package-name", BAD_PACKAGE, "--constraints-file", c]
165
+ lower_bound_checker.update,
166
+ ["--package-name", BAD_PACKAGE, "--constraints-file", c],
123
167
  )
124
168
 
125
169
  assert result.exit_code == 2
@@ -129,24 +173,28 @@ def test_update_constraints_with_setup_py_missing_lower_bounds():
129
173
  assert set(invalid_pkg_list) == {"requests", "packaging", "wheel"}
130
174
 
131
175
 
132
-
133
176
  def test_check():
177
+ skip_test_if_not_installed(GOOD_PACKAGE)
178
+
134
179
  constraints = [
135
180
  "requests==1.0.0",
136
181
  "packaging==14.0",
137
182
  "wheel==0.41.0",
138
183
  "click==7.0.0",
139
- "grpcio==1.0.0"
184
+ "grpcio==1.0.0",
140
185
  ]
141
186
  with constraints_file(constraints) as c:
142
187
  result = RUNNER.invoke(
143
- lower_bound_checker.check, ["--package-name", GOOD_PACKAGE, "--constraints-file", c]
188
+ lower_bound_checker.check,
189
+ ["--package-name", GOOD_PACKAGE, "--constraints-file", c],
144
190
  )
145
191
 
146
192
  assert result.exit_code == 0
147
193
 
148
194
 
149
195
  def test_update_constraints_with_extra_constraints():
196
+ skip_test_if_not_installed(GOOD_PACKAGE)
197
+
150
198
  constraints = [
151
199
  "requests==1.0.0",
152
200
  "packaging==14.0",
@@ -157,13 +205,16 @@ def test_update_constraints_with_extra_constraints():
157
205
  ]
158
206
  with constraints_file(constraints) as c:
159
207
  result = RUNNER.invoke(
160
- lower_bound_checker.check, ["--package-name", GOOD_PACKAGE, "--constraints-file", c]
208
+ lower_bound_checker.check,
209
+ ["--package-name", GOOD_PACKAGE, "--constraints-file", c],
161
210
  )
162
211
 
163
212
  assert result.exit_code == 0
164
213
 
165
214
 
166
215
  def test_check_with_missing_constraints_file():
216
+ skip_test_if_not_installed(GOOD_PACKAGE)
217
+
167
218
  result = RUNNER.invoke(
168
219
  lower_bound_checker.check,
169
220
  [
@@ -179,6 +230,8 @@ def test_check_with_missing_constraints_file():
179
230
 
180
231
 
181
232
  def test_check_with_constraints_file_invalid_pins():
233
+ skip_test_if_not_installed(GOOD_PACKAGE)
234
+
182
235
  constraints = [
183
236
  "requests==1.0.0",
184
237
  "packaging==14.0",
@@ -187,7 +240,8 @@ def test_check_with_constraints_file_invalid_pins():
187
240
  ]
188
241
  with constraints_file(constraints) as c:
189
242
  result = RUNNER.invoke(
190
- lower_bound_checker.check, ["--package-name", GOOD_PACKAGE, "--constraints-file", c]
243
+ lower_bound_checker.check,
244
+ ["--package-name", GOOD_PACKAGE, "--constraints-file", c],
191
245
  )
192
246
 
193
247
  assert result.exit_code == 2
@@ -198,6 +252,8 @@ def test_check_with_constraints_file_invalid_pins():
198
252
 
199
253
 
200
254
  def test_check_with_constraints_file_missing_packages():
255
+ skip_test_if_not_installed(GOOD_PACKAGE)
256
+
201
257
  constraints = [
202
258
  "requests==1.0.0",
203
259
  "packaging==14.0",
@@ -205,7 +261,8 @@ def test_check_with_constraints_file_missing_packages():
205
261
  ]
206
262
  with constraints_file(constraints) as c:
207
263
  result = RUNNER.invoke(
208
- lower_bound_checker.check, ["--package-name", GOOD_PACKAGE, "--constraints-file", c]
264
+ lower_bound_checker.check,
265
+ ["--package-name", GOOD_PACKAGE, "--constraints-file", c],
209
266
  )
210
267
 
211
268
  assert result.exit_code == 2
@@ -215,16 +272,19 @@ def test_check_with_constraints_file_missing_packages():
215
272
 
216
273
 
217
274
  def test_check_with_constraints_file_different_versions():
275
+ skip_test_if_not_installed(GOOD_PACKAGE)
276
+
218
277
  constraints = [
219
278
  "requests==1.2.0", # setup.py has 1.0.0
220
279
  "packaging==14.1", # setup.py has 14.0
221
280
  "wheel==0.42.0", # setup.py has 0.41.0
222
281
  "click==7.0.0",
223
- "grpcio==1.0.0"
282
+ "grpcio==1.0.0",
224
283
  ]
225
284
  with constraints_file(constraints) as c:
226
285
  result = RUNNER.invoke(
227
- lower_bound_checker.check, ["--package-name", GOOD_PACKAGE, "--constraints-file", c]
286
+ lower_bound_checker.check,
287
+ ["--package-name", GOOD_PACKAGE, "--constraints-file", c],
228
288
  )
229
289
 
230
290
  assert result.exit_code == 2
@@ -234,6 +294,8 @@ def test_check_with_constraints_file_different_versions():
234
294
 
235
295
 
236
296
  def test_check_with_setup_py_missing_lower_bounds():
297
+ skip_test_if_not_installed(BAD_PACKAGE)
298
+
237
299
  constraints = [
238
300
  "requests==1.0.0",
239
301
  "packaging==14.0",
@@ -242,7 +304,8 @@ def test_check_with_setup_py_missing_lower_bounds():
242
304
  ]
243
305
  with constraints_file(constraints) as c:
244
306
  result = RUNNER.invoke(
245
- lower_bound_checker.check, ["--package-name", BAD_PACKAGE, "--constraints-file", c]
307
+ lower_bound_checker.check,
308
+ ["--package-name", BAD_PACKAGE, "--constraints-file", c],
246
309
  )
247
310
 
248
311
  assert result.exit_code == 2