diff --git a/src/_zkapauthorizer/tests/common.py b/src/_zkapauthorizer/tests/common.py new file mode 100644 index 0000000000000000000000000000000000000000..39aa9119e10c22670c2948b4f53a7dbb22dc4f6e --- /dev/null +++ b/src/_zkapauthorizer/tests/common.py @@ -0,0 +1,41 @@ +# Copyright 2019 PrivateStorage.io, LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +""" +Testing functionality that is specifically related to the test harness +itself. +""" + + +def skipIf(condition, reason): + """ + Create a decorate a function to be skipped if the given condition is true. + + :param bool condition: The condition under which to skip. + :param unicode reason: A reason for the skip. + + :return: A function decorator which will skip the test if the given + condition is true. + """ + if condition: + return _skipper(reason) + return lambda x: x + + +def _skipper(reason): + def wrapper(f): + def skipIt(self, *a, **kw): + self.skipTest(reason) + return skipIt + return wrapper diff --git a/src/_zkapauthorizer/tests/test_storage_protocol.py b/src/_zkapauthorizer/tests/test_storage_protocol.py index ee0dc5ba671e36fa5a2c4b3e8e039ea5d731568e..80c34b59986a8fcea78e44e3022349fc36b0177a 100644 --- a/src/_zkapauthorizer/tests/test_storage_protocol.py +++ b/src/_zkapauthorizer/tests/test_storage_protocol.py @@ -23,9 +23,6 @@ from __future__ import ( from fixtures import ( MonkeyPatch, ) -from unittest import ( - skipIf, -) from testtools import ( TestCase, ) @@ -73,6 +70,10 @@ from privacypass import ( random_signing_key, ) +from .common import ( + skipIf, +) + from .privacypass import ( make_passes, )