@@ 394-408 (lines=15) @@ | ||
391 | ||
392 | assert Test.ns.cls_mthd() == 'called' |
|
393 | assert Test().ns.cls_mthd() == 'called' |
|
394 | ||
395 | ||
396 | def test_meta_plus_classmethod(namespaces): |
|
397 | class Meta(namespaces.Namespaceable, type(namespaces.Namespaceable)): |
|
398 | with namespaces.Namespace() as ns: |
|
399 | pass |
|
400 | ||
401 | class Test(namespaces.Namespaceable, metaclass=Meta): |
|
402 | with namespaces.Namespace() as ns: |
|
403 | @classmethod |
|
404 | def cls_mthd(cls): |
|
405 | return 'called' |
|
406 | ||
407 | assert Test().ns.cls_mthd() == 'called' |
|
408 | assert Test.ns.cls_mthd() == 'called' |
|
409 | ||
410 | ||
411 | def test_get_through_namespace(namespaces): |
|
@@ 319-330 (lines=12) @@ | ||
316 | ||
317 | def test_add_later(namespaces): |
|
318 | class Test(namespaces.Namespaceable): |
|
319 | pass |
|
320 | ||
321 | Test.ns = namespaces.Namespace() |
|
322 | Test.ns.ns = namespaces.Namespace() |
|
323 | Test.ns.value = 1 |
|
324 | Test.ns.ns.value = 2 |
|
325 | assert Test.ns.value == 1 |
|
326 | assert Test.ns.ns.value == 2 |
|
327 | ||
328 | ||
329 | @pytest.mark.xfail(sys.version_info < (3, 6), |
|
330 | reason="python3.6 api changes", strict=True) |
|
331 | def test_3_6_descriptor(namespaces): |
|
332 | class Descriptor: |
|
333 | def __set_name__(self, owner, name): |
|
@@ 206-218 (lines=13) @@ | ||
203 | assert Subclass().ns.foo == 2 |
|
204 | assert Subclass().ns.bar == 3 |
|
205 | ||
206 | ||
207 | def test_advanced_overlap(namespaces): |
|
208 | class Test(namespaces.Namespaceable): |
|
209 | with namespaces.Namespace() as ns: |
|
210 | foo = 2 |
|
211 | with namespaces.Namespace() as ns: |
|
212 | qux = 4 |
|
213 | ||
214 | class Subclass(Test): |
|
215 | with namespaces.Namespace() as ns: |
|
216 | bar = 3 |
|
217 | assert Subclass().ns.foo == 2 |
|
218 | assert Subclass().ns.bar == 3 |
|
219 | assert Subclass().ns.ns.qux == 4 |
|
220 | ||
221 |