This is an automated email from the ASF dual-hosted git repository. kentontaylor pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/allura.git
commit d8dd59967d5e73977300d837eb21e43f0e7fcbd1 Author: Dave Brondsema <[email protected]> AuthorDate: Mon Sep 13 19:16:35 2021 +0000 [#8396] upgrade decorator rewrite one @decorator due to https://github.com/micheles/decorator/issues/109 --- AlluraTest/alluratest/tools.py | 39 +++++++++++++++++++++++++++++---------- requirements.txt | 2 +- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/AlluraTest/alluratest/tools.py b/AlluraTest/alluratest/tools.py index 8831b12..71a9a6a 100644 --- a/AlluraTest/alluratest/tools.py +++ b/AlluraTest/alluratest/tools.py @@ -14,24 +14,28 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. - +import functools import unittest from decorator import decorator testcase = unittest.TestCase(methodName='__init__') # py2 needs a methodName that is a valid attr :/ + def with_setup(setup, teardown=None): # this might have subtle ordering differences from a true "setup" method, esp. if other decorators are involved - @decorator - def inner_with_setup(func, *a, **kw): - try: - setup() - return func(*a, **kw) - finally: - if teardown: - teardown() - return inner_with_setup + def with_setup__wrapper(func): + @functools.wraps(func) + def with_setup__decorated(*a, **kw): + try: + setup() + return func(*a, **kw) + finally: + if teardown: + teardown() + return with_setup__decorated + return with_setup__wrapper + def raises(ExcType): @decorator @@ -40,48 +44,63 @@ def raises(ExcType): return func(*a, **kw) return inner_raises + def assert_equal(*a, **kw): return testcase.assertEqual(*a, **kw) + def assert_equals(*a, **kw): return testcase.assertEquals(*a, **kw) + def assert_not_equal(*a, **kw): return testcase.assertNotEqual(*a, **kw) + def assert_raises(*a, **kw): return testcase.assertRaises(*a, **kw) + def assert_is_none(*a, **kw): return testcase.assertIsNone(*a, **kw) + def assert_is_not_none(*a, **kw): return testcase.assertIsNotNone(*a, **kw) + def assert_is(*a, **kw): return testcase.assertIs(*a, **kw) + def assert_true(*a, **kw): return testcase.assertTrue(*a, **kw) + def assert_false(*a, **kw): return testcase.assertFalse(*a, **kw) + def assert_in(*a, **kw): return testcase.assertIn(*a, **kw) + def assert_not_in(*a, **kw): return testcase.assertNotIn(*a, **kw) + def assert_less(*a, **kw): return testcase.assertLess(*a, **kw) + def assert_greater(*a, **kw): return testcase.assertGreater(*a, **kw) + def assert_greater_equal(*a, **kw): return testcase.assertGreaterEqual(*a, **kw) + def assert_regexp_matches(*a, **kw): return testcase.assertRegexpMatches(*a, **kw) diff --git a/requirements.txt b/requirements.txt index c28cd6c..2132c71 100644 --- a/requirements.txt +++ b/requirements.txt @@ -32,7 +32,7 @@ cryptography==3.3.2 # via -r requirements.in datadiff==2.0.0 # via -r requirements.in -decorator==4.4.0 +decorator==5.1.0 # via -r requirements.in docutils==0.15.2 # via pypeline
