Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a971361

Browse filesBrowse files
authored
Handle delete Not Found exceptions if needed (GoogleCloudPlatform#1778)
* Handle delete Not Found exceptions if needed * Update main_test.py
1 parent 293e10c commit a971361
Copy full SHA for a971361

File tree

Expand file treeCollapse file tree

1 file changed

+15
-7
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+15
-7
lines changed

‎dns/api/main_test.py

Copy file name to clipboardExpand all lines: dns/api/main_test.py
+15-7Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
from gcp_devrel.testing.flaky import flaky
1717
from google.cloud import dns
18+
from google.cloud.exceptions import NotFound
19+
1820
import pytest
1921

2022
import main
@@ -33,7 +35,10 @@ def client():
3335

3436
# Delete anything created during the test.
3537
for zone in client.list_zones():
36-
zone.delete()
38+
try:
39+
zone.delete()
40+
except NotFound: # May have been in process
41+
pass
3742

3843

3944
@pytest.yield_fixture
@@ -45,7 +50,10 @@ def zone(client):
4550
yield zone
4651

4752
if zone.exists():
48-
zone.delete()
53+
try:
54+
zone.delete()
55+
except NotFound: # May have been under way
56+
pass
4957

5058

5159
@flaky
@@ -77,11 +85,6 @@ def test_list_zones(client, zone):
7785
assert TEST_ZONE_NAME in zones
7886

7987

80-
@flaky
81-
def test_delete_zone(client, zone):
82-
main.delete_zone(PROJECT, TEST_ZONE_NAME)
83-
84-
8588
@flaky
8689
def test_list_resource_records(client, zone):
8790
records = main.list_resource_records(PROJECT, TEST_ZONE_NAME)
@@ -94,3 +97,8 @@ def test_list_changes(client, zone):
9497
changes = main.list_changes(PROJECT, TEST_ZONE_NAME)
9598

9699
assert changes
100+
101+
102+
@flaky
103+
def test_delete_zone(client, zone):
104+
main.delete_zone(PROJECT, TEST_ZONE_NAME)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.