Skip to content
Closed

wip #17437

Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,9 @@ replacements:
"freezegun",
]
count: 1
# TODO(https://github.com/googleapis/google-cloud-python/issues/17429):
# Temporary post-processing rule to add pytest-xdist dependency.
# Remove this once gapic-generator includes pytest-xdist by default.
- paths: [
packages/google-cloud-firestore/noxfile.py
]
Expand All @@ -574,6 +577,7 @@ replacements:
"pytest-asyncio",
"six",
"pyyaml",
"pytest-xdist",
]
count: 1
- paths: [
Expand All @@ -584,6 +588,54 @@ replacements:
after: |
"pytest-asyncio==0.21.2",
count: 2
# TODO(https://github.com/googleapis/google-cloud-python/issues/17429):
# Temporary post-processing rule to inject `-n auto` for Firestore parallel tests.
# This rule should be removed once the generator template changes are released
# and the generator version is updated in librarian.yaml.
- paths: [
packages/google-cloud-firestore/noxfile.py
]
before: |
# Run py.test against the system tests\.
if system_test_exists:
session\.run\(
"py.test",
"--quiet",
f"--junitxml=system_\{session\.python\}_sponge_log\.xml",
system_test_path,
\*session\.posargs,
\)
if system_test_folder_exists:
session\.run\(
"py.test",
"--quiet",
f"--junitxml=system_\{session\.python\}_sponge_log\.xml",
system_test_folder_path,
\*session\.posargs,
\)
after: |
# Run py.test against the system tests.
if system_test_exists:
session.run(
"py.test",
"-n",
"auto",
"--quiet",
f"--junitxml=system_{session.python}_sponge_log.xml",
system_test_path,
*session.posargs,
)
if system_test_folder_exists:
session.run(
"py.test",
"-n",
"auto",
"--quiet",
f"--junitxml=system_{session.python}_sponge_log.xml",
system_test_folder_path,
*session.posargs,
)
count: 1
- paths: [
"packages/google-cloud-firestore/docs/conf.py",
]
Expand Down
6 changes: 3 additions & 3 deletions packages/google-cloud-firestore/tests/system/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,7 @@ def test_unicode_doc(client, cleanup, database):
assert snapshot2.reference.id == explicit_doc_id


@pytest.fixture
@pytest.fixture(scope="module")
def query_docs(client, database):
collection_id = "qs" + UNIQUE_RESOURCE_ID
sub_collection = "child" + UNIQUE_RESOURCE_ID
Expand Down Expand Up @@ -1297,13 +1297,13 @@ def query_docs(client, database):
operation()


@pytest.fixture
@pytest.fixture(scope="module")
def collection(query_docs):
collection, _, _ = query_docs
return collection


@pytest.fixture
@pytest.fixture(scope="module")
def query(collection):
return collection.where(filter=FieldFilter("a", "==", 1))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1243,7 +1243,7 @@ async def test_list_collections_with_read_time(client, cleanup, database):
}


@pytest_asyncio.fixture
@pytest_asyncio.fixture(scope="module")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Changing the scope of pytest_asyncio fixtures to "module" requires that the underlying event_loop fixture also has a matching or wider scope (e.g., "module" or "session"). By default, pytest-asyncio provides a "function"-scoped event_loop fixture, which causes a ScopeMismatch error during test execution. To prevent this error, define a module- or session-scoped event_loop fixture in this file or in conftest.py if one does not already exist.

async def query_docs(client):
collection_id = "qs" + UNIQUE_RESOURCE_ID
sub_collection = "child" + UNIQUE_RESOURCE_ID
Expand Down Expand Up @@ -1272,13 +1272,13 @@ async def query_docs(client):
await operation()


@pytest_asyncio.fixture
@pytest_asyncio.fixture(scope="module")
async def collection(query_docs):
collection, _, _ = query_docs
yield collection


@pytest_asyncio.fixture
@pytest_asyncio.fixture(scope="module")
async def async_query(collection):
return collection.where(filter=FieldFilter("a", "==", 1))

Expand Down
Loading