From ec0cd6ea9edd655b748e44b5d9d846870c12b8e3 Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Thu, 23 Aug 2012 07:59:37 -0400 Subject: portable way to get regex type --- testsuite/Testlib/TestServer/TestPlugin.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/testsuite/Testlib/TestServer/TestPlugin.py b/testsuite/Testlib/TestServer/TestPlugin.py index be345b0d1..e8a723b8e 100644 --- a/testsuite/Testlib/TestServer/TestPlugin.py +++ b/testsuite/Testlib/TestServer/TestPlugin.py @@ -22,6 +22,12 @@ from common import XI_NAMESPACE, XI, inPy3k, call, builtins, u, can_skip, \ skip, skipIf, skipUnless, Bcfg2TestCase, DBModelTestCase, syncdb, \ patchIf, datastore + +try: + re_type = re._pattern_type +except AttributeError: + re_type = type(re.compile("")) + def tostring(el): return lxml.etree.tostring(el, xml_declaration=False).decode('UTF-8') @@ -1686,7 +1692,7 @@ class TestEntrySet(TestDebuggable): def test__init(self): for basename in self.basenames: eset = self.get_obj(basename=basename) - self.assertIsInstance(eset.specific, re._pattern_type) + self.assertIsInstance(eset.specific, re_type) self.assertTrue(eset.specific.match(os.path.join(datastore, basename))) ppath = os.path.join(datastore, "Plugin", basename) -- cgit v1.2.3-1-g7c22