aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBrian Harring <ferringb@gmail.com>2023-01-14 22:59:31 -0800
committerArthur Zamarin <arthurzam@gentoo.org>2023-02-02 21:59:11 +0200
commitf40af28d677663b4cd8cfe053ad88259077a1710 (patch)
tree3fc5ef1aefadd42e50a7f7ddbe5ee478cb25d6c1 /tests
parentdomain: support `-*` in use as previous removal (diff)
downloadpkgcore-f40af28d677663b4cd8cfe053ad88259077a1710.tar.gz
pkgcore-f40af28d677663b4cd8cfe053ad88259077a1710.tar.bz2
pkgcore-f40af28d677663b4cd8cfe053ad88259077a1710.zip
refactor(config): adding typing to config hints along with immutability.
ConfigHint's should be treated as immutable; any manipulation of their data should be handled either via clone or via pre-processing. This system is complex enough we don't want mutability, and the allowance of that was an oversight from the good ole days of py2.4. Force immutability sincei t's the actual design contract and also to flush out anyone breaking said contract (no pkgcore code breaks that, to be clear). Signed-off-by: Brian Harring <ferringb@gmail.com> Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/config/test_basics.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/tests/config/test_basics.py b/tests/config/test_basics.py
index 374fc135..929c907c 100644
--- a/tests/config/test_basics.py
+++ b/tests/config/test_basics.py
@@ -196,6 +196,7 @@ class TestConfigHint:
def test_clone(self):
c = ConfigHint(
types={"foo": "list", "one": "str"},
+ # use lists to ensure it forces immutability.
positional=["one"],
required=["one"],
typename="barn",
@@ -205,8 +206,8 @@ class TestConfigHint:
types={"foo": "list", "one": "str", "two": "str"}, required=["one", "two"]
)
assert c2.types == {"foo": "list", "one": "str", "two": "str"}
- assert c2.positional == c.positional
- assert c2.required == ["one", "two"]
+ assert c2.positional == tuple(c.positional)
+ assert c2.required == ("one", "two")
assert c2.typename == c.typename
assert c2.allow_unknowns == c.allow_unknowns
assert c2.doc == c.doc