From 639136bbe36c731714de79dbb9e6bce7ff310368 Mon Sep 17 00:00:00 2001 From: Rouven Czerwinski Date: Tue, 12 Sep 2023 10:49:44 +0200 Subject: [PATCH] tests: test different resources having a default This came up in an IRC discussion where the reporter said that this raised some issues for him. The core library already supports this, add a test to ensure the support stays. Signed-off-by: Rouven Czerwinski --- tests/test_target.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/test_target.py b/tests/test_target.py index 71d416368..3afd66a17 100644 --- a/tests/test_target.py +++ b/tests/test_target.py @@ -41,6 +41,23 @@ class A(Resource): with pytest.raises(NoResourceFoundError) as excinfo: target.get_resource(A, name="nosuchresource") +def test_get_resource_multiple_with_default(target): + class A(Resource): + pass + + class B(Resource): + pass + + a = A(target, "aresource") + adef = A(target, "default") + b = B(target, "bresource") + bdef = B(target, "default") + + assert target.get_resource(A) is adef + assert target.get_resource(B) is bdef + assert target.get_resource(A, name="aresource") is a + assert target.get_resource(B, name="bresource") is b + def test_get_driver(target): class A(Driver): pass