]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
rework the exclusions spec expression
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 31 Dec 2018 03:02:12 +0000 (22:02 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 31 Dec 2018 05:20:08 +0000 (00:20 -0500)
The expression was expecting spaces which means we were skipping
Postgresql window function tests and possibly other things.

Change-Id: I57c4aed558f4011f2f7b882a2d9b1fee210f9eaf

lib/sqlalchemy/testing/exclusions.py

index 65b70a5a317c3e30d584746da4a5433dee6becd6..512fffb3bf39b2b322fbc79a617e7ef7cb1f8082 100644 (file)
@@ -6,14 +6,15 @@
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
 
-import operator
-from ..util import decorator
-from . import config
-from .. import util
-import inspect
 import contextlib
+import operator
+import re
+
 from sqlalchemy.util.compat import inspect_getargspec
 
+from . import config
+from .. import util
+from ..util import decorator
 
 def skip_if(predicate, reason=None):
     rule = compound()
@@ -190,13 +191,18 @@ class Predicate(object):
         elif isinstance(predicate, tuple):
             return SpecPredicate(*predicate)
         elif isinstance(predicate, util.string_types):
-            tokens = predicate.split(" ", 2)
-            op = spec = None
-            db = tokens.pop(0)
-            if tokens:
-                op = tokens.pop(0)
-            if tokens:
-                spec = tuple(int(d) for d in tokens.pop(0).split("."))
+            tokens = re.match(
+                r'([\+\w]+)\s*(?:(>=|==|!=|<=|<|>)\s*([\d\.]+))?', predicate)
+            if not tokens:
+                raise ValueError(
+                    "Couldn't locate DB name in predicate: %r" % predicate)
+            db = tokens.group(1)
+            op = tokens.group(2)
+            spec = (
+                tuple(int(d) for d in tokens.group(3).split("."))
+                if tokens.group(3) else None
+            )
+
             return SpecPredicate(db, op, spec, description=description)
         elif util.callable(predicate):
             return LambdaPredicate(predicate, description)