Skip to content

Commit a9396ab

Browse files
committed
Implements skip by capability
1 parent 783d5fd commit a9396ab

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

nutkit/protocol/responses.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323

2424
class RunTest:
2525
""" Response to StartTest indicating that the test can be started"""
26-
pass
26+
27+
def __init__(self, capabilities=[]):
28+
self.capabilities = capabilities
2729

2830

2931
class SkipTest:

tests/shared.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,22 @@ def new_backend():
2929
return Backend(host, port)
3030

3131

32+
def driver_feature(capability):
33+
def get_valid_test_case(*args, **kwargs):
34+
if not isinstance(args[0], TestkitTestCase):
35+
raise Exception('Should only decorate TestkitTestCase')
36+
return args[0]
37+
38+
def driver_feature_decorator(func):
39+
def wrapper(*args, **kwargs):
40+
test_case = get_valid_test_case(*args, **kwargs)
41+
if (capability not in test_case._driver_capabilities):
42+
test_case.skipTest("Needs support for %s" % capability)
43+
return func(*args, **kwargs)
44+
return wrapper
45+
return driver_feature_decorator
46+
47+
3248
def get_driver_name():
3349
return os.environ['TEST_DRIVER_NAME']
3450

@@ -46,3 +62,4 @@ def setUp(self):
4662
raise Exception("Should be SkipTest or RunTest, "
4763
"received {}: {}".format(type(response),
4864
response))
65+
self._driver_capabilities = response.capabilities

tests/stub/authorization.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from tests.shared import (
44
get_driver_name,
55
TestkitTestCase,
6+
driver_feature
67
)
78
from tests.stub.shared import StubServer
89

@@ -698,6 +699,7 @@ def read_return_1_failure_return_2_succeed_script(self):
698699
+}
699700
"""
700701

702+
@driver_feature('AutorizationExpiredTreament')
701703
def test_should_drop_connection_after_AuthorizationExpired(self):
702704
self._server.start(
703705
script=self.read_return_1_failure_return_2_succeed_script()
@@ -732,6 +734,7 @@ def test_should_drop_connection_after_AuthorizationExpired(self):
732734

733735
driver.close()
734736

737+
@driver_feature('AutorizationExpiredTreament')
735738
def test_should_be_able_to_use_current_sessions_after_AuthorizationExpired(self):
736739
self._server.start(
737740
script=self.read_return_1_failure_return_2_succeed_script()

0 commit comments

Comments
 (0)