Skip to content

Commit

Permalink
100% coverage for test_expressions.py. Minor whitespace cleanups.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamadden committed Sep 22, 2017
1 parent b5f6350 commit c9689c9
Show file tree
Hide file tree
Showing 3 changed files with 235 additions and 130 deletions.
13 changes: 6 additions & 7 deletions src/zope/tales/expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ def __init__(self, path, traverser, engine):
compiledpath.append(tuple(currentpath))

first = compiledpath[0]
base = first[0]

if callable(first):
# check for initial function
Expand All @@ -101,6 +100,7 @@ def __init__(self, path, traverser, engine):
raise engine.getCompilerError()(
'Dynamic name specified in first subpath element')

base = first[0]
if base and not _valid_name(base):
raise engine.getCompilerError()(
'Invalid variable name "%s"' % element)
Expand Down Expand Up @@ -211,9 +211,7 @@ def _eval(self, econtext):
# __call__.
if getattr(ob, '__call__', _marker) is not _marker:
return ob()
if PY2 and isinstance(ob, types.ClassType):
return ob()
return ob
return ob() if PY2 and isinstance(ob, types.ClassType) else ob

def __call__(self, econtext):
if self._name == 'exists':
Expand All @@ -229,8 +227,8 @@ def __repr__(self):


_interp = re.compile(
r'\$(%(n)s)|\${(%(n)s(?:/[^}|]*)*(?:\|%(n)s(?:/[^}|]*)*)*)}'
% {'n': NAME_RE})
r'\$(%(n)s)|\${(%(n)s(?:/[^}|]*)*(?:\|%(n)s(?:/[^}|]*)*)*)}'
% {'n': NAME_RE})

@implementer(ITALESExpression)
class StringExpr(object):
Expand Down Expand Up @@ -318,9 +316,10 @@ def __repr__(self):
class LazyWrapper(DeferWrapper):
"""Wrapper for lazy: expression
"""
_result = _marker

def __init__(self, expr, econtext):
DeferWrapper.__init__(self, expr, econtext)
self._result = _marker

def __call__(self):
r = self._result
Expand Down
Loading

0 comments on commit c9689c9

Please sign in to comment.