Python flask._compat.PY2 Examples

The following are 14 code examples of flask._compat.PY2(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module flask._compat , or try the search function .
Example #1
Source File: ext.py    From Flask-P2P with MIT License 6 votes vote down vote up
def test_no_error_swallowing(self):
        try:
            import flask.ext.broken
        except ImportError:
            exc_type, exc_value, tb = sys.exc_info()
            self.assert_true(exc_type is ImportError)
            if PY2:
                message = 'No module named missing_module'
            else:
                message = 'No module named \'missing_module\''
            self.assert_equal(str(exc_value), message)
            self.assert_true(tb.tb_frame.f_globals is globals())

            # reraise() adds a second frame so we need to skip that one too.
            # On PY3 we even have another one :(
            next = tb.tb_next.tb_next
            if not PY2:
                next = next.tb_next
            self.assert_in('flask_broken/__init__.py', next.tb_frame.f_code.co_filename) 
Example #2
Source File: ext.py    From syntheticmass with Apache License 2.0 6 votes vote down vote up
def test_no_error_swallowing(self):
        try:
            import flask.ext.broken
        except ImportError:
            exc_type, exc_value, tb = sys.exc_info()
            self.assert_true(exc_type is ImportError)
            if PY2:
                message = 'No module named missing_module'
            else:
                message = 'No module named \'missing_module\''
            self.assert_equal(str(exc_value), message)
            self.assert_true(tb.tb_frame.f_globals is globals())

            # reraise() adds a second frame so we need to skip that one too.
            # On PY3 we even have another one :(
            next = tb.tb_next.tb_next
            if not PY2:
                next = next.tb_next
            self.assert_in('flask_broken/__init__.py', next.tb_frame.f_code.co_filename) 
Example #3
Source File: ext.py    From data with GNU General Public License v3.0 6 votes vote down vote up
def test_no_error_swallowing(self):
        try:
            import flask.ext.broken
        except ImportError:
            exc_type, exc_value, tb = sys.exc_info()
            self.assert_true(exc_type is ImportError)
            if PY2:
                message = 'No module named missing_module'
            else:
                message = 'No module named \'missing_module\''
            self.assert_equal(str(exc_value), message)
            self.assert_true(tb.tb_frame.f_globals is globals())

            # reraise() adds a second frame so we need to skip that one too.
            # On PY3 we even have another one :(
            next = tb.tb_next.tb_next
            if not PY2:
                next = next.tb_next
            self.assert_in('flask_broken/__init__.py', next.tb_frame.f_code.co_filename) 
Example #4
Source File: ext.py    From data with GNU General Public License v3.0 6 votes vote down vote up
def test_no_error_swallowing(self):
        try:
            import flask.ext.broken
        except ImportError:
            exc_type, exc_value, tb = sys.exc_info()
            self.assert_true(exc_type is ImportError)
            if PY2:
                message = 'No module named missing_module'
            else:
                message = 'No module named \'missing_module\''
            self.assert_equal(str(exc_value), message)
            self.assert_true(tb.tb_frame.f_globals is globals())

            # reraise() adds a second frame so we need to skip that one too.
            # On PY3 we even have another one :(
            next = tb.tb_next.tb_next
            if not PY2:
                next = next.tb_next
            self.assert_in('flask_broken/__init__.py', next.tb_frame.f_code.co_filename) 
Example #5
Source File: ext.py    From data with GNU General Public License v3.0 6 votes vote down vote up
def test_no_error_swallowing(self):
        try:
            import flask.ext.broken
        except ImportError:
            exc_type, exc_value, tb = sys.exc_info()
            self.assert_true(exc_type is ImportError)
            if PY2:
                message = 'No module named missing_module'
            else:
                message = 'No module named \'missing_module\''
            self.assert_equal(str(exc_value), message)
            self.assert_true(tb.tb_frame.f_globals is globals())

            # reraise() adds a second frame so we need to skip that one too.
            # On PY3 we even have another one :(
            next = tb.tb_next.tb_next
            if not PY2:
                next = next.tb_next
            self.assert_in('flask_broken/__init__.py', next.tb_frame.f_code.co_filename) 
Example #6
Source File: ext.py    From data with GNU General Public License v3.0 6 votes vote down vote up
def test_no_error_swallowing(self):
        try:
            import flask.ext.broken
        except ImportError:
            exc_type, exc_value, tb = sys.exc_info()
            self.assert_true(exc_type is ImportError)
            if PY2:
                message = 'No module named missing_module'
            else:
                message = 'No module named \'missing_module\''
            self.assert_equal(str(exc_value), message)
            self.assert_true(tb.tb_frame.f_globals is globals())

            # reraise() adds a second frame so we need to skip that one too.
            # On PY3 we even have another one :(
            next = tb.tb_next.tb_next
            if not PY2:
                next = next.tb_next
            self.assert_in('flask_broken/__init__.py', next.tb_frame.f_code.co_filename) 
Example #7
Source File: ext.py    From data with GNU General Public License v3.0 6 votes vote down vote up
def test_no_error_swallowing(self):
        try:
            import flask.ext.broken
        except ImportError:
            exc_type, exc_value, tb = sys.exc_info()
            self.assert_true(exc_type is ImportError)
            if PY2:
                message = 'No module named missing_module'
            else:
                message = 'No module named \'missing_module\''
            self.assert_equal(str(exc_value), message)
            self.assert_true(tb.tb_frame.f_globals is globals())

            # reraise() adds a second frame so we need to skip that one too.
            # On PY3 we even have another one :(
            next = tb.tb_next.tb_next
            if not PY2:
                next = next.tb_next
            self.assert_in('flask_broken/__init__.py', next.tb_frame.f_code.co_filename) 
Example #8
Source File: ext.py    From Flask with Apache License 2.0 6 votes vote down vote up
def test_no_error_swallowing(self):
        try:
            import flask.ext.broken
        except ImportError:
            exc_type, exc_value, tb = sys.exc_info()
            self.assert_true(exc_type is ImportError)
            if PY2:
                message = 'No module named missing_module'
            else:
                message = 'No module named \'missing_module\''
            self.assert_equal(str(exc_value), message)
            self.assert_true(tb.tb_frame.f_globals is globals())

            # reraise() adds a second frame so we need to skip that one too.
            # On PY3 we even have another one :(
            next = tb.tb_next.tb_next
            if not PY2:
                next = next.tb_next
            self.assert_in('flask_broken/__init__.py', next.tb_frame.f_code.co_filename) 
Example #9
Source File: ext.py    From Flask with Apache License 2.0 6 votes vote down vote up
def test_no_error_swallowing(self):
        try:
            import flask.ext.broken
        except ImportError:
            exc_type, exc_value, tb = sys.exc_info()
            self.assert_true(exc_type is ImportError)
            if PY2:
                message = 'No module named missing_module'
            else:
                message = 'No module named \'missing_module\''
            self.assert_equal(str(exc_value), message)
            self.assert_true(tb.tb_frame.f_globals is globals())

            # reraise() adds a second frame so we need to skip that one too.
            # On PY3 we even have another one :(
            next = tb.tb_next.tb_next
            if not PY2:
                next = next.tb_next
            self.assert_in('flask_broken/__init__.py', next.tb_frame.f_code.co_filename) 
Example #10
Source File: __init__.py    From recruit with Apache License 2.0 5 votes vote down vote up
def load(fp, **kwargs):
    """Like :func:`loads` but reads from a file object.
    """
    _load_arg_defaults(kwargs)
    if not PY2:
        fp = _wrap_reader_for_text(fp, kwargs.pop('encoding', None) or 'utf-8')
    return _json.load(fp, **kwargs) 
Example #11
Source File: __init__.py    From Building-Recommendation-Systems-with-Python with MIT License 5 votes vote down vote up
def load(fp, app=None, **kwargs):
    """Like :func:`loads` but reads from a file object."""
    _load_arg_defaults(kwargs, app=app)
    if not PY2:
        fp = _wrap_reader_for_text(fp, kwargs.pop('encoding', None) or 'utf-8')
    return _json.load(fp, **kwargs) 
Example #12
Source File: __init__.py    From Building-Recommendation-Systems-with-Python with MIT License 5 votes vote down vote up
def load(fp, app=None, **kwargs):
    """Like :func:`loads` but reads from a file object."""
    _load_arg_defaults(kwargs, app=app)
    if not PY2:
        fp = _wrap_reader_for_text(fp, kwargs.pop('encoding', None) or 'utf-8')
    return _json.load(fp, **kwargs) 
Example #13
Source File: __init__.py    From scylla with Apache License 2.0 5 votes vote down vote up
def load(fp, app=None, **kwargs):
    """Like :func:`loads` but reads from a file object."""
    _load_arg_defaults(kwargs, app=app)
    if not PY2:
        fp = _wrap_reader_for_text(fp, kwargs.pop('encoding', None) or 'utf-8')
    return _json.load(fp, **kwargs) 
Example #14
Source File: __init__.py    From android_universal with MIT License 5 votes vote down vote up
def load(fp, **kwargs):
    """Like :func:`loads` but reads from a file object.
    """
    _load_arg_defaults(kwargs)
    if not PY2:
        fp = _wrap_reader_for_text(fp, kwargs.pop('encoding', None) or 'utf-8')
    return _json.load(fp, **kwargs)