This is an automated email from the ASF dual-hosted git repository.
heejong pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git
The following commit(s) were added to refs/heads/master by this push:
new 541dfb38105 Fix NonType error when importing google.api_core fails
new 668e0506323 Merge pull request #17774 from ihji/fix_none_exception
541dfb38105 is described below
commit 541dfb38105b2453665f9d16f2423456f043168d
Author: Heejong Lee <[email protected]>
AuthorDate: Thu May 26 18:57:25 2022 -0700
Fix NonType error when importing google.api_core fails
---
sdks/python/apache_beam/io/gcp/bigquery_test.py | 44 ++++++++++++++-----------
1 file changed, 25 insertions(+), 19 deletions(-)
diff --git a/sdks/python/apache_beam/io/gcp/bigquery_test.py
b/sdks/python/apache_beam/io/gcp/bigquery_test.py
index 117ce60128b..20b525382e2 100644
--- a/sdks/python/apache_beam/io/gcp/bigquery_test.py
+++ b/sdks/python/apache_beam/io/gcp/bigquery_test.py
@@ -858,19 +858,19 @@ class
BigQueryStreamingInsertsErrorHandling(unittest.TestCase):
# to determine error types and messages to try for retriables.
@parameterized.expand([
param(
- exception_type=exceptions.Forbidden,
+ exception_type=exceptions.Forbidden if exceptions else None,
error_reason='rateLimitExceeded'),
param(
- exception_type=exceptions.DeadlineExceeded,
+ exception_type=exceptions.DeadlineExceeded if exceptions else None,
error_reason='somereason'),
param(
- exception_type=exceptions.ServiceUnavailable,
+ exception_type=exceptions.ServiceUnavailable if exceptions else None,
error_reason='backendError'),
param(
- exception_type=exceptions.InternalServerError,
+ exception_type=exceptions.InternalServerError if exceptions else
None,
error_reason='internalError'),
param(
- exception_type=exceptions.InternalServerError,
+ exception_type=exceptions.InternalServerError if exceptions else
None,
error_reason='backendError'),
])
@mock.patch('time.sleep')
@@ -934,7 +934,7 @@ class
BigQueryStreamingInsertsErrorHandling(unittest.TestCase):
exception_type=ConnectionError,
error_message='some py connection error'),
param(
- exception_type=exceptions.BadGateway,
+ exception_type=exceptions.BadGateway if exceptions else None,
error_message='some badgateway error'),
])
@mock.patch('time.sleep')
@@ -980,28 +980,31 @@ class
BigQueryStreamingInsertsErrorHandling(unittest.TestCase):
exception_type=retry.PermanentException,
error_args=('nonretriable', )),
param(
- exception_type=exceptions.BadRequest,
+ exception_type=exceptions.BadRequest if exceptions else None,
error_args=(
'forbidden morbidden', [{
'reason': 'nonretriablereason'
}])),
param(
- exception_type=exceptions.BadRequest,
+ exception_type=exceptions.BadRequest if exceptions else None,
error_args=('BAD REQUEST!', [{
'reason': 'nonretriablereason'
}])),
param(
- exception_type=exceptions.MethodNotAllowed,
+ exception_type=exceptions.MethodNotAllowed if exceptions else None,
error_args=(
'method not allowed!', [{
'reason': 'nonretriablereason'
}])),
param(
- exception_type=exceptions.MethodNotAllowed,
+ exception_type=exceptions.MethodNotAllowed if exceptions else None,
error_args=('method not allowed!', 'args')),
- param(exception_type=exceptions.Unknown, error_args=('unknown!',
'args')),
param(
- exception_type=exceptions.Aborted, error_args=('abortet!', 'abort')),
+ exception_type=exceptions.Unknown if exceptions else None,
+ error_args=('unknown!', 'args')),
+ param(
+ exception_type=exceptions.Aborted if exceptions else None,
+ error_args=('abortet!', 'abort')),
])
@mock.patch('time.sleep')
@mock.patch('google.cloud.bigquery.Client.insert_rows_json')
@@ -1041,28 +1044,31 @@ class
BigQueryStreamingInsertsErrorHandling(unittest.TestCase):
exception_type=retry.PermanentException,
error_args=('nonretriable', )),
param(
- exception_type=exceptions.BadRequest,
+ exception_type=exceptions.BadRequest if exceptions else None,
error_args=(
'forbidden morbidden', [{
'reason': 'nonretriablereason'
}])),
param(
- exception_type=exceptions.BadRequest,
+ exception_type=exceptions.BadRequest if exceptions else None,
error_args=('BAD REQUEST!', [{
'reason': 'nonretriablereason'
}])),
param(
- exception_type=exceptions.MethodNotAllowed,
+ exception_type=exceptions.MethodNotAllowed if exceptions else None,
error_args=(
'method not allowed!', [{
'reason': 'nonretriablereason'
}])),
param(
- exception_type=exceptions.MethodNotAllowed,
+ exception_type=exceptions.MethodNotAllowed if exceptions else None,
error_args=('method not allowed!', 'args')),
- param(exception_type=exceptions.Unknown, error_args=('unknown!',
'args')),
param(
- exception_type=exceptions.Aborted, error_args=('abortet!', 'abort')),
+ exception_type=exceptions.Unknown if exceptions else None,
+ error_args=('unknown!', 'args')),
+ param(
+ exception_type=exceptions.Aborted if exceptions else None,
+ error_args=('abortet!', 'abort')),
param(
exception_type=requests.exceptions.ConnectionError,
error_args=('some connection error', )),
@@ -1073,7 +1079,7 @@ class
BigQueryStreamingInsertsErrorHandling(unittest.TestCase):
exception_type=ConnectionError,
error_args=('some py connection error', )),
param(
- exception_type=exceptions.BadGateway,
+ exception_type=exceptions.BadGateway if exceptions else None,
error_args=('some badgateway error', )),
])
@mock.patch('time.sleep')