ported some more stuff to py 3.3

removed init_jinja_globals hack from app.py after consulting mitsuhiko
(didn't work on py 3.3 "as is")

removed with_statement future imports, not needed any more

needs more work on 2.7 as well as on 3.3
This commit is contained in:
Thomas Waldmann 2013-05-22 01:33:04 +02:00
parent a503520ac5
commit e1d356fb71
24 changed files with 36 additions and 87 deletions

View file

@ -11,17 +11,16 @@
"""
from __future__ import print_function
from __future__ import with_statement
import os
import sys
import flask
import warnings
import unittest
from StringIO import StringIO
from functools import update_wrapper
from contextlib import contextmanager
from werkzeug.utils import import_string, find_modules
from flask._compat import reraise, StringIO
def add_to_path(path):
@ -159,7 +158,7 @@ class _ExceptionCatcher(object):
self.test_case.fail('Expected exception of type %r' %
exception_name)
elif not issubclass(exc_type, self.exc_type):
raise exc_type, exc_value, tb
reraise(exc_type, exc_value, tb)
return True

View file

@ -9,8 +9,6 @@
:license: BSD, see LICENSE for more details.
"""
from __future__ import with_statement
import flask
import unittest
from flask.testsuite import FlaskTestCase

View file

@ -9,8 +9,6 @@
:license: BSD, see LICENSE for more details.
"""
from __future__ import with_statement
import re
import uuid
import flask
@ -1060,7 +1058,7 @@ class BasicFunctionalityTestCase(FlaskTestCase):
1/0
c = app.test_client()
for x in xrange(3):
for x in range(3):
with self.assert_raises(ZeroDivisionError):
c.get('/fail')

View file

@ -9,8 +9,6 @@
:license: BSD, see LICENSE for more details.
"""
from __future__ import with_statement
import flask
import unittest
import warnings

View file

@ -8,7 +8,6 @@
:copyright: (c) 2011 by Armin Ronacher.
:license: BSD, see LICENSE for more details.
"""
from __future__ import with_statement
import os
import sys

View file

@ -9,30 +9,13 @@
:license: BSD, see LICENSE for more details.
"""
from __future__ import with_statement
import flask
import unittest
from flask.testsuite import FlaskTestCase, catch_warnings
class DeprecationsTestCase(FlaskTestCase):
def test_init_jinja_globals(self):
class MyFlask(flask.Flask):
def init_jinja_globals(self):
self.jinja_env.globals['foo'] = '42'
with catch_warnings() as log:
app = MyFlask(__name__)
@app.route('/')
def foo():
return app.jinja_env.globals['foo']
c = app.test_client()
self.assert_equal(c.get('/').data, '42')
self.assert_equal(len(log), 1)
self.assert_('init_jinja_globals' in str(log[0]['message']))
"""not used currently"""
def suite():

View file

@ -8,7 +8,6 @@
:copyright: (c) 2011 by Armin Ronacher.
:license: BSD, see LICENSE for more details.
"""
from __future__ import with_statement
import sys
import unittest
@ -22,7 +21,7 @@ class ExtImportHookTestCase(FlaskTestCase):
# that a real flaskext could be in there which would disable our
# fake package. Secondly we want to make sure that the flaskext
# import hook does not break on reloading.
for entry, value in sys.modules.items():
for entry, value in list(sys.modules.items()):
if (entry.startswith('flask.ext.') or
entry.startswith('flask_') or
entry.startswith('flaskext.') or
@ -100,7 +99,7 @@ class ExtImportHookTestCase(FlaskTestCase):
self.assert_equal(test_function(), 42)
def test_flaskext_broken_package_no_module_caching(self):
for x in xrange(2):
for x in range(2):
with self.assert_raises(ImportError):
import flask.ext.broken

View file

@ -9,16 +9,14 @@
:license: BSD, see LICENSE for more details.
"""
from __future__ import with_statement
import os
import flask
import unittest
from logging import StreamHandler
from StringIO import StringIO
from flask.testsuite import FlaskTestCase, catch_warnings, catch_stderr
from werkzeug.http import parse_cache_control_header, parse_options_header
import six
from flask._compat import StringIO
def has_encoding(name):

View file

@ -9,8 +9,6 @@
:license: BSD, see LICENSE for more details.
"""
from __future__ import with_statement
import os
import gc
import sys
@ -77,7 +75,7 @@ class MemoryTestCase(FlaskTestCase):
if sys.version_info >= (2, 7) and \
not hasattr(sys, 'pypy_translation_info'):
with self.assert_no_leak():
for x in xrange(10):
for x in range(10):
fire()
def test_safe_join_toplevel_pardir(self):

View file

@ -9,8 +9,6 @@
:license: BSD, see LICENSE for more details.
"""
from __future__ import with_statement
import flask
import unittest
try:

View file

@ -8,7 +8,6 @@
:copyright: (c) 2011 by Armin Ronacher.
:license: BSD, see LICENSE for more details.
"""
from __future__ import with_statement
import flask
import unittest

View file

@ -11,9 +11,9 @@
"""
import flask
import unittest
from StringIO import StringIO
from logging import StreamHandler
from flask.testsuite import FlaskTestCase
from flask._compat import StringIO
class FlaskSubclassingTestCase(FlaskTestCase):

View file

@ -9,8 +9,6 @@
:license: BSD, see LICENSE for more details.
"""
from __future__ import with_statement
import flask
import unittest
from flask.testsuite import FlaskTestCase

View file

@ -9,8 +9,6 @@
:license: BSD, see LICENSE for more details.
"""
from __future__ import with_statement
import flask
import unittest
from flask.testsuite import FlaskTestCase

View file

@ -8,7 +8,7 @@
:copyright: (c) 2011 by Armin Ronacher.
:license: BSD, see LICENSE for more details.
"""
from __future__ import with_statement
import flask
import flask.views
import unittest