Skip to content
Myr

Fix number test failing for long in Python 2

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by ThiefMaster · committed by ThiefMaster · parent 85820fc · Browse files · 4 files+8 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+8 added−3 removed

  • other:+8 added−3 removed

4 files+8 added−3 removed

modified:jinja2/testsuite/tests.py+3 added-1 removed
49 unmodified lines
50 {{ range(5) is iterable }}51 {{ {} is mapping }}52 {{ mydict is mapping }}53 {{ [] is mapping }}54 {{ 10 is number }}55 {{ (10 ** 100) is number }}56 ''')57 class MyDict(dict):58 pass59 assert tmpl.render(mydict=MyDict()).split() == [60 'False', 'True', 'False', 'True', 'True', 'False',61 'True', 'True', 'True', 'True', 'False', 'True',60 'True', 'True', 'False'62 'True', 'True', 'False', 'True', 'True'63 ]6465 def test_sequence(self):66 tmpl = env.from_string(
40 unmodified lines
modified:jinja2/_compat.py+2 added
20 unmodified lines
21 unichr = chr22 range_type = range23 text_type = str24 string_types = (str,)25 integer_types = (int,)2627 iterkeys = lambda d: iter(d.keys())28 itervalues = lambda d: iter(d.values())29 iteritems = lambda d: iter(d.items())
21 unmodified lines
51 unichr = unichr52 text_type = unicode53 range_type = xrange54 string_types = (str, unicode)55 integer_types = (int, long)5657 iterkeys = lambda d: d.iterkeys()58 itervalues = lambda d: d.itervalues()59 iteritems = lambda d: d.iteritems()
52 unmodified lines
modified:jinja2/tests.py+2 added-2 removed
9 unmodified lines
10"""11import re12from collections import Mapping13from jinja2.runtime import Undefined14from jinja2._compat import text_type, string_types14from jinja2._compat import text_type, string_types, integer_types151617number_re = re.compile(r'^-?\d+(\.\d+)?$')18regex_type = type(number_re)
68 unmodified lines
878889def test_number(value):90 """Return true if the variable is a number."""91 return isinstance(value, (int, float, complex))91 return isinstance(value, integer_types + (float, complex))929394def test_sequence(value):95 """Return true if the variable is a sequence. Sequences are variables
76 unmodified lines
modified:CHANGES+1 added
18 unmodified lines
19- If unmarshalling of cached data fails the template will be20 reloaded now.21- Implemented a block ``set`` tag.22- Default cache size was incrased to 400 from a low 50.23- Fixed ``is number`` test to accept long integers in all Python versions.2425Version 2.7.326-------------27(bugfix release, released on June 6th 2014)
328 unmodified lines