Castle: The best Real-Time/Embedded/HighTech language EVER. Attempt 2
修订版 | 8948acb0b11d8f3dd091c9ebe4a9852b4dcca7fd (tree) |
---|---|
时间 | 2023-10-20 22:45:25 |
作者 | Albert Mietus < albert AT mietus DOT nl > |
Commiter | Albert Mietus < albert AT mietus DOT nl > |
ASIS (more test on namednode/NamedNode interaction: 2ways is limited
@@ -23,3 +23,7 @@ | ||
23 | 23 | def register_in_NS(self, ns): |
24 | 24 | self._ns = ns |
25 | 25 | |
26 | + @property | |
27 | + def ns(self): | |
28 | + return self._ns | |
29 | + |
@@ -84,8 +84,20 @@ | ||
84 | 84 | assert sub.getID('elm') is elm |
85 | 85 | assert top.search(dottedName="sub.elm") is elm |
86 | 86 | |
87 | -def test_6_registered_is_2way(aNS, a_node): | |
88 | - assert a_node._ns is aNS | |
87 | +def test_6a_registered_is_2ways(aNS, a_node): | |
88 | + """When a NamedNode is registered in a NameSpace, it should a backlink (`ns property) to the NS again""" | |
89 | + assert a_node.ns is aNS | |
90 | + | |
91 | +def test_6b_registered_is_2ways_once(aNS, a_node): | |
92 | + """Currently, a NamedNode can be registered in multiple namespaces, but the backlink is always the last | |
93 | + XXX ToDo: is that the intent? For now test as is""" | |
94 | + name = a_node.name | |
95 | + other = NameSpace('other') | |
96 | + other.register(a_node) | |
97 | + | |
98 | + assert (aNS.getID(name) is a_node) and (other.getID(name) is a_node), "A NamedNode can be registered in two NS'ses ..." | |
99 | + assert a_node.ns is other, " ...but Only the last NS is remembered" | |
100 | + | |
89 | 101 | |
90 | 102 | |
91 | 103 | @pytest.mark.skip("Todo: Unite `.search()` and `.find()` [& `.getID()] -- see comment in `aigr/namespaces.py`") |