GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — chore: use mock from unittest (#1823) · chenhance/python-bigquery@08762fb

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • noxfile.py
  • samples
    • desktopapp
      • user_credentials_test.py
    • tests
      • conftest.py
  • testing
    • constraints-3.7.txt
  • tests/unit
    • conftest.py
    • helpers.py
    • job
      • test_base.py
      • test_copy.py
      • test_extract.py
      • test_load.py
      • test_query.py
      • test_query_pandas.py
    • test__helpers.py
    • test__http.py
    • test__pandas_helpers.py
    • test__versions_helpers.py
    • test_client.py
    • test_create_dataset.py
    • test_dataset.py
    • test_dbapi_connection.py
    • test_dbapi_cursor.py
    • test_encryption_configuration.py
    • test_job_retry.py
    • test_list_datasets.py
    • test_list_jobs.py
    • test_list_projects.py
    • test_magics.py
    • test_opentelemetry_tracing.py
    • test_query.py
    • test_retry.py
    • test_schema.py
    • test_table.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎noxfile.py‎

Copy file name to clipboardExpand all lines: noxfile.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ def default(session, install_extras=True):
7272

7373
# Install all test dependencies, then install local packages in-place.
7474
session.install(
75-
"mock",
7675
"pytest",
7776
"google-cloud-testutils",
7877
"pytest-cov",
@@ -89,6 +88,8 @@ def default(session, install_extras=True):
8988
install_target = "."
9089
session.install("-e", install_target, "-c", constraints_path)
9190

91+
session.run("python", "-m", "pip", "freeze")
92+
9293
# Run py.test against the unit tests.
9394
session.run(
9495
"py.test",
@@ -176,7 +177,7 @@ def system(session):
176177

177178
# Install all test dependencies, then install local packages in place.
178179
session.install(
179-
"mock", "pytest", "psutil", "google-cloud-testutils", "-c", constraints_path
180+
"pytest", "psutil", "google-cloud-testutils", "-c", constraints_path
180181
)
181182
if os.environ.get("GOOGLE_API_USE_CLIENT_CERTIFICATE", "") == "true":
182183
# mTLS test requires pyopenssl and latest google-cloud-storage
@@ -249,7 +250,7 @@ def snippets(session):
249250
)
250251

251252
# Install all test dependencies, then install local packages in place.
252-
session.install("mock", "pytest", "google-cloud-testutils", "-c", constraints_path)
253+
session.install("pytest", "google-cloud-testutils", "-c", constraints_path)
253254
session.install("google-cloud-storage", "-c", constraints_path)
254255
session.install("grpcio", "-c", constraints_path)
255256

@@ -336,7 +337,6 @@ def prerelease_deps(session):
336337
"google-cloud-datacatalog",
337338
"google-cloud-storage",
338339
"google-cloud-testutils",
339-
"mock",
340340
"psutil",
341341
"pytest",
342342
"pytest-cov",
Collapse file

‎samples/desktopapp/user_credentials_test.py‎

Copy file name to clipboardExpand all lines: samples/desktopapp/user_credentials_test.py
+9-2Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,24 @@
1313
# limitations under the License.
1414

1515
import os
16+
import sys
1617
from typing import Iterator, Union
18+
from unittest import mock
1719

1820
import google.auth
19-
import mock
2021
import pytest
2122

2223
from .user_credentials import main # type: ignore
2324

2425
PROJECT = os.environ["GOOGLE_CLOUD_PROJECT"]
2526

26-
MockType = Union[mock.mock.MagicMock, mock.mock.AsyncMock]
27+
28+
if sys.version_info >= (3, 8):
29+
# Python 3.8+ has an AsyncMock attribute in unittest.mock, but 3.7 does not
30+
MockType = Union[mock.MagicMock, mock.AsyncMock]
31+
else:
32+
# Other definitions and imports
33+
MockType = Union[mock.MagicMock]
2734

2835

2936
@pytest.fixture
Collapse file

‎samples/tests/conftest.py‎

Copy file name to clipboardExpand all lines: samples/tests/conftest.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414

1515
import datetime
1616
from typing import Iterator, List
17+
from unittest import mock
1718
import uuid
1819

1920
import google.auth
20-
import mock
2121
import pytest
2222

2323
from google.cloud import bigquery
Collapse file

‎testing/constraints-3.7.txt‎

Copy file name to clipboardExpand all lines: testing/constraints-3.7.txt
+9-4Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,16 @@
77
# Then this file should have foo==1.14.0
88
db-dtypes==0.3.0
99
geopandas==0.9.0
10-
google-api-core==1.31.5
11-
google-cloud-bigquery-storage==2.6.0
12-
google-cloud-core==1.6.0
13-
google-resumable-media==0.6.0
10+
google-api-core==2.17.1
11+
google-auth==2.28.1
12+
google-cloud-bigquery-storage==2.24.0
13+
google-cloud-core==2.4.1
14+
google-cloud-testutils==1.4.0
15+
google-crc32c==1.5.0
16+
google-resumable-media==2.7.0
17+
googleapis-common-protos==1.62.0
1418
grpcio==1.47.0
19+
grpcio-status==1.47.0
1520
ipywidgets==7.7.1
1621
ipython==7.23.1
1722
ipykernel==6.0.0
Collapse file

‎tests/unit/conftest.py‎

Copy file name to clipboardExpand all lines: tests/unit/conftest.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import mock
15+
from unittest import mock
16+
1617
import pytest
1718

1819
from .helpers import make_client
Collapse file

‎tests/unit/helpers.py‎

Copy file name to clipboardExpand all lines: tests/unit/helpers.py
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
from unittest import mock
16+
17+
import pytest
18+
1519
import google.cloud.bigquery.client
1620
import google.cloud.bigquery.dataset
17-
import mock
18-
import pytest
1921

2022

2123
def make_connection(*responses):
2224
import google.cloud.bigquery._http
23-
import mock
2425
from google.cloud.exceptions import NotFound
2526

2627
mock_conn = mock.create_autospec(google.cloud.bigquery._http.Connection)
Collapse file

‎tests/unit/job/test_base.py‎

Copy file name to clipboardExpand all lines: tests/unit/job/test_base.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
import copy
1616
import http
1717
import unittest
18+
from unittest import mock
1819

1920
from google.api_core import exceptions
2021
import google.api_core.retry
2122
from google.api_core.future import polling
22-
import mock
2323
import pytest
2424

2525
from ..helpers import make_connection
Collapse file

‎tests/unit/job/test_copy.py‎

Copy file name to clipboardExpand all lines: tests/unit/job/test_copy.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import mock
15+
from unittest import mock
1616

1717
from ..helpers import make_connection
1818

Collapse file

‎tests/unit/job/test_extract.py‎

Copy file name to clipboardExpand all lines: tests/unit/job/test_extract.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import mock
15+
from unittest import mock
1616

1717
from ..helpers import make_connection
1818

Collapse file

‎tests/unit/job/test_load.py‎

Copy file name to clipboardExpand all lines: tests/unit/job/test_load.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
# limitations under the License.
1414

1515
import copy
16-
17-
import mock
16+
from unittest import mock
1817

1918
from ..helpers import make_connection
2019

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.