Skip to content

Commit 296786f

Browse files
committed
Add warning test
1 parent 1e26689 commit 296786f

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ def quiet_log():
6060

6161

6262
class LogCaptureHandler(list):
63-
def skip_until(self, pattern, args=()):
63+
def skip_until(self, pattern, args=None):
6464
return ('until', pattern, args)
6565

66-
def not_logged(self, pattern, args=()):
66+
def not_logged(self, pattern, args=None):
6767
return ('not', pattern, args)
6868

6969
def __call__(self, *cmp):

tests/test_pep514utils.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import winreg
33

44
from manage import pep514utils
5+
from manage import tagutils
56

67
def test_is_tag_managed(registry, tmp_path):
78
registry.setup(Company={
@@ -23,3 +24,37 @@ def test_is_tag_managed(registry, tmp_path):
2324
assert pep514utils._is_tag_managed(registry.key, r"Company\3.0", creating=True)
2425
with winreg.OpenKey(registry.key, r"Company\3.0.2"):
2526
pass
27+
28+
29+
def test_is_tag_managed_warning_suppressed(registry, tmp_path, assert_log):
30+
registry.setup(Company={
31+
"3.0.0": {"": "Just in the way here"},
32+
"3.0.1": {"": "Also in the way here"},
33+
})
34+
pep514utils.update_registry(
35+
rf"HKEY_CURRENT_USER\{registry.root}",
36+
dict(company="Company", tag="3.0.0"),
37+
dict(kind="pep514", Key="Company\\3.0.0", InstallPath=dict(_="dir")),
38+
warn_for=[tagutils.tag_or_range(r"Company\3.0.1")],
39+
)
40+
assert_log(
41+
"Registry key %s appears invalid.+",
42+
assert_log.not_logged("An existing runtime is registered at %s"),
43+
)
44+
45+
46+
def test_is_tag_managed_warning(registry, tmp_path, assert_log):
47+
registry.setup(Company={
48+
"3.0.0": {"": "Just in the way here"},
49+
"3.0.1": {"": "Also in the way here"},
50+
})
51+
pep514utils.update_registry(
52+
rf"HKEY_CURRENT_USER\{registry.root}",
53+
dict(company="Company", tag="3.0.0"),
54+
dict(kind="pep514", Key="Company\\3.0.0", InstallPath=dict(_="dir")),
55+
warn_for=[tagutils.tag_or_range(r"Company\3.0.0")],
56+
)
57+
assert_log(
58+
"Registry key %s appears invalid.+",
59+
assert_log.skip_until("An existing registry key for %s"),
60+
)

0 commit comments

Comments
 (0)