Unverified Commit a1adc50b authored by Qianli Scott Zhu's avatar Qianli Scott Zhu Committed by GitHub
Browse files

Mock the bigquery client in the unit test. (#4447)

This will prevent the unit test to read the local config of the GCP API, which does not necessary to exist for the test environment.
parent 7ba78e94
...@@ -66,7 +66,8 @@ class BenchmarkLoggerTest(tf.test.TestCase): ...@@ -66,7 +66,8 @@ class BenchmarkLoggerTest(tf.test.TestCase):
logger.BenchmarkFileLogger) logger.BenchmarkFileLogger)
@unittest.skipIf(bigquery is None, 'Bigquery dependency is not installed.') @unittest.skipIf(bigquery is None, 'Bigquery dependency is not installed.')
def test_config_benchmark_bigquery_logger(self): @mock.patch.object(bigquery, "Client")
def test_config_benchmark_bigquery_logger(self, mock_bigquery_client):
with flagsaver.flagsaver(benchmark_logger_type='BenchmarkBigQueryLogger'): with flagsaver.flagsaver(benchmark_logger_type='BenchmarkBigQueryLogger'):
logger.config_benchmark_logger() logger.config_benchmark_logger()
self.assertIsInstance(logger.get_benchmark_logger(), self.assertIsInstance(logger.get_benchmark_logger(),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment