Skip to content

Commit 97e27a1

Browse files
author
Yalin Li
authored
Load prepared images by decorator (Azure#30475)
1 parent 2d6b6c6 commit 97e27a1

File tree

2 files changed

+25
-30
lines changed

2 files changed

+25
-30
lines changed

sdk/containerregistry/azure-containerregistry/tests/conftest.py

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,33 @@
44
# Licensed under the MIT License. See License.txt in the project root for
55
# license information.
66
# --------------------------------------------------------------------------
7-
87
import os
9-
108
import pytest
11-
from devtools_testutils import add_general_regex_sanitizer, add_body_key_sanitizer, add_uri_regex_sanitizer, test_proxy
12-
13-
# Fixture
14-
from testcase import load_registry
9+
from devtools_testutils import (
10+
add_general_regex_sanitizer,
11+
add_body_key_sanitizer,
12+
add_uri_regex_sanitizer,
13+
test_proxy,
14+
is_live,
15+
)
16+
from testcase import get_authority, import_image
1517

16-
17-
def pytest_configure(config):
18-
config.addinivalue_line("usefixtures", "load_registry")
18+
@pytest.fixture(scope="session", autouse=True)
19+
def load_registry():
20+
if not is_live():
21+
return
22+
authority = get_authority(os.environ.get("CONTAINERREGISTRY_ENDPOINT"))
23+
authority_anon = get_authority(os.environ.get("CONTAINERREGISTRY_ANONREGISTRY_ENDPOINT"))
24+
repo = "library/hello-world"
25+
tags = [
26+
"library/hello-world:latest",
27+
"library/hello-world:v1"
28+
]
29+
try:
30+
import_image(authority, repo, tags)
31+
import_image(authority_anon, repo, tags, is_anonymous=True)
32+
except Exception as e:
33+
print(e)
1934

2035
@pytest.fixture(scope="session", autouse=True)
2136
def add_sanitizers(test_proxy):

sdk/containerregistry/azure-containerregistry/tests/testcase.py

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from azure.mgmt.containerregistry.models import ImportImageParameters, ImportSource, ImportMode
1515
from azure.identity import DefaultAzureCredential, AzureAuthorityHosts, ClientSecretCredential
1616

17-
from devtools_testutils import AzureRecordedTestCase, is_live, FakeTokenCredential
17+
from devtools_testutils import AzureRecordedTestCase, FakeTokenCredential
1818

1919
logger = logging.getLogger()
2020

@@ -154,23 +154,3 @@ def import_image(authority, repository, tags, is_anonymous=False):
154154
)
155155

156156
result.wait()
157-
158-
@pytest.fixture(scope="session")
159-
def load_registry():
160-
if not is_live():
161-
return
162-
authority = get_authority(os.environ.get("CONTAINERREGISTRY_ENDPOINT"))
163-
authority_anon = get_authority(os.environ.get("CONTAINERREGISTRY_ANONREGISTRY_ENDPOINT"))
164-
repo = "library/hello-world"
165-
tags = [
166-
[
167-
"library/hello-world:latest",
168-
"library/hello-world:v1"
169-
]
170-
]
171-
for tag in tags:
172-
try:
173-
import_image(authority, repo, tag)
174-
import_image(authority_anon, repo, tag, is_anonymous=True)
175-
except Exception as e:
176-
print(e)

0 commit comments

Comments
 (0)