From 6a13e22e7131fd6792dae4cb5b3ab97dcae4a4cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Mon, 2 Mar 2020 14:00:45 -0500 Subject: Use unittest.SkipTest (again?) While I can believe that the standard exception might not have worked with some ancient version of pytest, it certainly works just fine now. This saves people from importing nose which kills pytest via DeprecationWarnings these days. Closes: #316 Pull-request: https://github.com/sqlalchemy/mako/pull/316 Pull-request-sha: 90dfcfc3d0351ab9bf8125e8c2adb45c57059a6d Change-Id: Ie816acd325c6783e08801bc83de37dbe6b4581e5 --- test/__init__.py | 9 +-------- test/test_cache.py | 10 ++++++---- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/test/__init__.py b/test/__init__.py index c5c9e91..1770962 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -10,13 +10,6 @@ from mako.compat import py3k from mako.template import Template from mako.util import update_wrapper -try: - # unitttest has a SkipTest also but pytest doesn't - # honor it unless nose is imported too... - from nose import SkipTest -except ImportError: - from _pytest.runner import Skipped as SkipTest - template_base = os.path.join(os.path.dirname(__file__), "templates") module_base = os.path.join(template_base, "modules") @@ -148,7 +141,7 @@ def skip_if(predicate, reason=None): def maybe(*args, **kw): if predicate(): msg = "'%s' skipped: %s" % (fn_name, reason) - raise SkipTest(msg) + raise unittest.SkipTest(msg) else: return fn(*args, **kw) diff --git a/test/test_cache.py b/test/test_cache.py index 7fe9350..d662872 100644 --- a/test/test_cache.py +++ b/test/test_cache.py @@ -1,4 +1,5 @@ import time +import unittest from mako import lookup from mako.cache import CacheImpl @@ -9,7 +10,6 @@ from mako.lookup import TemplateLookup from mako.template import Template from test import eq_ from test import module_base -from test import SkipTest from test import TemplateTest from test.util import result_lines @@ -649,9 +649,9 @@ class BeakerCacheTest(RealBackendTest, CacheTest): def setUp(self): if not beaker_cache.has_beaker: - raise SkipTest("Beaker is required for these tests.") + raise unittest.SkipTest("Beaker is required for these tests.") if not py27: - raise SkipTest("newer beakers not working w/ py26") + raise unittest.SkipTest("newer beakers not working w/ py26") def _install_mock_cache(self, template, implname=None): template.cache_args["manager"] = self._regions() @@ -676,7 +676,9 @@ class DogpileCacheTest(RealBackendTest, CacheTest): try: import dogpile.cache # noqa except ImportError: - raise SkipTest("dogpile.cache is required to run these tests") + raise unittest.SkipTest( + "dogpile.cache is required to run these tests" + ) def _install_mock_cache(self, template, implname=None): template.cache_args["regions"] = self._regions() -- cgit v1.2.3