Skip to content
Myr

__init__.py

This file

Path

tests/__init__.py

62 lines · 1.6 KiB · Python

Last changed by

Remove old helper functionMarkus Unterwaditzerbefore adoption4ea4ea7

History of this file

Take it

Move testsMarkus Unterwaditzerbefore adoption3550b26

lines 1–2why, one step back
1# -*- coding: utf-8 -*-
2"""

Made tests recognizableMarkus Unterwaditzerbefore adoption961db8a

line 3why, one step back
3 tests

Move testsMarkus Unterwaditzerbefore adoption3550b26

lines 4–19why, one step back
4 ~~~~~~~~~~~~~~~
56 Tests Flask itself. The majority of Flask is already tested7 as part of Werkzeug.89 :copyright: (c) 2014 by Armin Ronacher.10 :license: BSD, see LICENSE for more details.11"""1213from __future__ import print_function1415import os16import sys17import warnings18from functools import update_wrapper19from contextlib import contextmanager

Tests pass now.Markus Unterwaditzerbefore adoption8fa5e32

line 20why, one step back
20from flask._compat import StringIO

Move testsMarkus Unterwaditzerbefore adoption3550b26

lines 21–32why, one step back
21
2223@contextmanager24def catch_warnings():25 """Catch warnings in a with block in a list"""26 # make sure deprecation warnings are active in tests27 warnings.simplefilter('default', category=DeprecationWarning)2829 filters = warnings.filters30 warnings.filters = filters[:]31 old_showwarning = warnings.showwarning32 log = []

Tests pass now.Markus Unterwaditzerbefore adoption8fa5e32

line 33why, one step back
33

Move testsMarkus Unterwaditzerbefore adoption3550b26

lines 34–58why, one step back
34 def showwarning(message, category, filename, lineno, file=None, line=None):
35 log.append(locals())36 try:37 warnings.showwarning = showwarning38 yield log39 finally:40 warnings.filters = filters41 warnings.showwarning = old_showwarning424344@contextmanager45def catch_stderr():46 """Catch stderr in a StringIO"""47 old_stderr = sys.stderr48 sys.stderr = rv = StringIO()49 try:50 yield rv51 finally:52 sys.stderr = old_stderr535455def emits_module_deprecation_warning(f):56 def new_f(self, *args, **kwargs):57 with catch_warnings() as log:58 f(self, *args, **kwargs)

Rewrite assertion methodsMarkus Unterwaditzerbefore adoption5da2c00

line 59why, one step back
59 assert log, 'expected deprecation warning'

Move testsMarkus Unterwaditzerbefore adoption3550b26

line 60why, one step back
60 for entry in log:

Rewrite assertion methodsMarkus Unterwaditzerbefore adoption5da2c00

line 61why, one step back
61 assert 'Modules are deprecated' in str(entry['message'])

Move testsMarkus Unterwaditzerbefore adoption3550b26

line 62why, one step back
62 return update_wrapper(new_f, f)