|
54 | 54 |
|
55 | 55 | from . import helpers
|
56 | 56 |
|
57 |
| -try: |
58 |
| - from google.cloud import bigquery_storage |
59 |
| -except ImportError: # pragma: NO COVER |
60 |
| - bigquery_storage = None |
61 |
| - |
62 |
| -try: |
63 |
| - import pyarrow |
64 |
| - import pyarrow.types |
65 |
| -except ImportError: # pragma: NO COVER |
66 |
| - pyarrow = None |
67 | 57 |
|
68 | 58 | JOB_TIMEOUT = 120 # 2 minutes
|
69 | 59 | DATA_PATH = pathlib.Path(__file__).parent.parent / "data"
|
@@ -1772,11 +1762,10 @@ def test_dbapi_fetchall_from_script(self):
|
1772 | 1762 | row_tuples = [r.values() for r in rows]
|
1773 | 1763 | self.assertEqual(row_tuples, [(5, "foo"), (6, "bar"), (7, "baz")])
|
1774 | 1764 |
|
1775 |
| - @unittest.skipIf( |
1776 |
| - bigquery_storage is None, "Requires `google-cloud-bigquery-storage`" |
1777 |
| - ) |
1778 |
| - @unittest.skipIf(pyarrow is None, "Requires `pyarrow`") |
1779 | 1765 | def test_dbapi_fetch_w_bqstorage_client_large_result_set(self):
|
| 1766 | + bigquery_storage = pytest.importorskip("google.cloud.bigquery_storage") |
| 1767 | + pytest.importorskip("pyarrow") |
| 1768 | + |
1780 | 1769 | bqstorage_client = bigquery_storage.BigQueryReadClient(
|
1781 | 1770 | credentials=Config.CLIENT._credentials
|
1782 | 1771 | )
|
@@ -1834,10 +1823,8 @@ def test_dbapi_dry_run_query(self):
|
1834 | 1823 |
|
1835 | 1824 | self.assertEqual(list(rows), [])
|
1836 | 1825 |
|
1837 |
| - @unittest.skipIf( |
1838 |
| - bigquery_storage is None, "Requires `google-cloud-bigquery-storage`" |
1839 |
| - ) |
1840 | 1826 | def test_dbapi_connection_does_not_leak_sockets(self):
|
| 1827 | + pytest.importorskip("google.cloud.bigquery_storage") |
1841 | 1828 | current_process = psutil.Process()
|
1842 | 1829 | conn_count_start = len(current_process.connections())
|
1843 | 1830 |
|
@@ -2382,11 +2369,10 @@ def test_create_table_rows_fetch_nested_schema(self):
|
2382 | 2369 | self.assertEqual(found[7], e_favtime)
|
2383 | 2370 | self.assertEqual(found[8], decimal.Decimal(expected["FavoriteNumber"]))
|
2384 | 2371 |
|
2385 |
| - @unittest.skipIf(pyarrow is None, "Requires `pyarrow`") |
2386 |
| - @unittest.skipIf( |
2387 |
| - bigquery_storage is None, "Requires `google-cloud-bigquery-storage`" |
2388 |
| - ) |
2389 | 2372 | def test_nested_table_to_arrow(self):
|
| 2373 | + bigquery_storage = pytest.importorskip("google.cloud.bigquery_storage") |
| 2374 | + pyarrow = pytest.importorskip("pyarrow") |
| 2375 | + pyarrow.types = pytest.importorskip("pyarrow.types") |
2390 | 2376 | from google.cloud.bigquery.job import SourceFormat
|
2391 | 2377 | from google.cloud.bigquery.job import WriteDisposition
|
2392 | 2378 |
|
|
0 commit comments