|
142 | 142 | ) |
143 | 143 |
|
144 | 144 | # Emit deprecation warning if return_immediately flag is set with synchronous pull. |
145 | | -count = s.replace( |
| 145 | +s.replace( |
146 | 146 | "google/pubsub_v1/services/subscriber/*client.py", |
147 | 147 | r"import pkg_resources", |
148 | 148 | "import warnings\n\g<0>", |
|
170 | 170 | if count != 2: |
171 | 171 | raise Exception("Too many or too few replacements in pull() methods.") |
172 | 172 |
|
| 173 | +# Silence deprecation warnings in pull() method flattened parameter tests. |
| 174 | +s.replace( |
| 175 | + "tests/unit/gapic/pubsub_v1/test_subscriber.py", |
| 176 | + "import mock", |
| 177 | + "\g<0>\nimport warnings", |
| 178 | +) |
| 179 | +count = s.replace( |
| 180 | + "tests/unit/gapic/pubsub_v1/test_subscriber.py", |
| 181 | + textwrap.dedent( |
| 182 | + r""" |
| 183 | + ([^\n\S]+# Call the method with a truthy value for each flattened field, |
| 184 | + [^\n\S]+# using the keyword arguments to the method\.) |
| 185 | + \s+(client\.pull\(.*?\))""" |
| 186 | + ), |
| 187 | + """\n\g<1> |
| 188 | + with warnings.catch_warnings(): |
| 189 | + warnings.simplefilter("ignore", category=DeprecationWarning) |
| 190 | + \g<2>""", |
| 191 | + flags = re.MULTILINE | re.DOTALL, |
| 192 | +) |
| 193 | + |
| 194 | +if count < 1: |
| 195 | + raise Exception("Catch warnings replacement failed.") |
| 196 | + |
| 197 | +count = s.replace( |
| 198 | + "tests/unit/gapic/pubsub_v1/test_subscriber.py", |
| 199 | + textwrap.dedent( |
| 200 | + r""" |
| 201 | + ([^\n\S]+# Call the method with a truthy value for each flattened field, |
| 202 | + [^\n\S]+# using the keyword arguments to the method\.) |
| 203 | + \s+response = (await client\.pull\(.*?\))""" |
| 204 | + ), |
| 205 | + """\n\g<1> |
| 206 | + with warnings.catch_warnings(): |
| 207 | + warnings.simplefilter("ignore", category=DeprecationWarning) |
| 208 | + \g<2>""", |
| 209 | + flags = re.MULTILINE | re.DOTALL, |
| 210 | +) |
| 211 | + |
| 212 | +if count < 1: |
| 213 | + raise Exception("Catch warnings replacement failed.") |
| 214 | + |
173 | 215 | # Make sure that client library version is present in user agent header. |
174 | 216 | s.replace( |
175 | 217 | [ |
|
206 | 248 | "\n\g<0>", |
207 | 249 | ) |
208 | 250 |
|
| 251 | +# The namespace package declaration in google/cloud/__init__.py should be excluded |
| 252 | +# from coverage. |
| 253 | +s.replace( |
| 254 | + ".coveragerc", |
| 255 | + r"((?P<indent>[^\n\S]+)google/pubsub/__init__\.py)", |
| 256 | + "\g<indent>google/cloud/__init__.py\n\g<0>", |
| 257 | +) |
| 258 | + |
209 | 259 | # ---------------------------------------------------------------------------- |
210 | 260 | # Add templated files |
211 | 261 | # ---------------------------------------------------------------------------- |
212 | 262 | templated_files = gcp.CommonTemplates().py_library( |
213 | 263 | microgenerator=True, |
214 | 264 | samples=True, |
215 | | - cov_level=99, |
| 265 | + cov_level=100, |
216 | 266 | system_test_external_dependencies=["psutil"], |
217 | 267 | ) |
218 | 268 | s.move(templated_files, excludes=[".coveragerc"]) |
|
0 commit comments