Browse Source

Remove useless classes

pull/1165/head
Markus Unterwaditzer 10 years ago
parent
commit
af41dbe0c4
  1. 4
      tests/test_basic.py
  2. 67
      tests/test_blueprints.py
  3. 4
      tests/test_config.py
  4. 12
      tests/test_deprecations.py
  5. 38
      tests/test_examples.py
  6. 21
      tests/test_helpers.py
  7. 4
      tests/test_regression.py
  8. 31
      tests/test_reqctx.py
  9. 12
      tests/test_signals.py
  10. 4
      tests/test_testing.py

4
tests/test_basic.py

@ -26,7 +26,7 @@ from werkzeug.http import parse_date
from werkzeug.routing import BuildError
class TestBasicFunctionality(TestFlask):
class TestBasicFunctionality(object):
def test_options_work(self):
app = flask.Flask(__name__)
@ -1295,7 +1295,7 @@ class TestBasicFunctionality(TestFlask):
assert sorted(flask.g) == ['bar', 'foo']
class TestSubdomain(TestFlask):
class TestSubdomain(object):
def test_basic_support(self):
app = flask.Flask(__name__)

67
tests/test_blueprints.py

@ -19,9 +19,7 @@ from werkzeug.http import parse_cache_control_header
from jinja2 import TemplateNotFound
class TestBlueprint(TestFlask):
def test_blueprint_specific_error_handling(self):
def test_blueprint_specific_error_handling():
frontend = flask.Blueprint('frontend', __name__)
backend = flask.Blueprint('backend', __name__)
sideend = flask.Blueprint('sideend', __name__)
@ -61,7 +59,7 @@ class TestBlueprint(TestFlask):
assert c.get('/backend-no').data == b'backend says no'
assert c.get('/what-is-a-sideend').data == b'application itself says no'
def test_blueprint_specific_user_error_handling(self):
def test_blueprint_specific_user_error_handling():
class MyDecoratorException(Exception):
pass
class MyFunctionException(Exception):
@ -94,7 +92,7 @@ class TestBlueprint(TestFlask):
assert c.get('/decorator').data == b'boom'
assert c.get('/function').data == b'bam'
def test_blueprint_url_definitions(self):
def test_blueprint_url_definitions():
bp = flask.Blueprint('test', __name__)
@bp.route('/foo', defaults={'baz': 42})
@ -115,7 +113,7 @@ class TestBlueprint(TestFlask):
assert c.get('/1/bar').data == b'23'
assert c.get('/2/bar').data == b'19'
def test_blueprint_url_processors(self):
def test_blueprint_url_processors():
bp = flask.Blueprint('frontend', __name__, url_prefix='/<lang_code>')
@bp.url_defaults
@ -142,7 +140,7 @@ class TestBlueprint(TestFlask):
assert c.get('/de/').data == b'/de/about'
assert c.get('/de/about').data == b'/de/'
def test_templates_and_static(self):
def test_templates_and_static():
from blueprintapp import app
c = app.test_client()
@ -187,7 +185,7 @@ class TestBlueprint(TestFlask):
with flask.Flask(__name__).test_request_context():
assert flask.render_template('nested/nested.txt') == 'I\'m nested'
def test_default_static_cache_timeout(self):
def test_default_static_cache_timeout():
app = flask.Flask(__name__)
class MyBlueprint(flask.Blueprint):
def get_send_file_max_age(self, filename):
@ -211,12 +209,12 @@ class TestBlueprint(TestFlask):
finally:
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = max_age_default
def test_templates_list(self):
def test_templates_list():
from blueprintapp import app
templates = sorted(app.jinja_env.list_templates())
assert templates == ['admin/index.html', 'frontend/index.html']
def test_dotted_names(self):
def test_dotted_names():
frontend = flask.Blueprint('myapp.frontend', __name__)
backend = flask.Blueprint('myapp.backend', __name__)
@ -241,7 +239,7 @@ class TestBlueprint(TestFlask):
assert c.get('/fe2').data.strip() == b'/fe'
assert c.get('/be').data.strip() == b'/fe'
def test_dotted_names_from_app(self):
def test_dotted_names_from_app():
app = flask.Flask(__name__)
app.testing = True
test = flask.Blueprint('test', __name__)
@ -260,7 +258,7 @@ class TestBlueprint(TestFlask):
rv = c.get('/')
assert rv.data == b'/test/'
def test_empty_url_defaults(self):
def test_empty_url_defaults():
bp = flask.Blueprint('bp', __name__)
@bp.route('/', defaults={'page': 1})
@ -275,7 +273,7 @@ class TestBlueprint(TestFlask):
assert c.get('/').data == b'1'
assert c.get('/page/2').data == b'2'
def test_route_decorator_custom_endpoint(self):
def test_route_decorator_custom_endpoint():
bp = flask.Blueprint('bp', __name__)
@ -309,7 +307,7 @@ class TestBlueprint(TestFlask):
assert c.get('/py/bar/123').data == b'bp.123'
assert c.get('/py/bar/foo').data == b'bp.bar_foo'
def test_route_decorator_custom_endpoint_with_dots(self):
def test_route_decorator_custom_endpoint_with_dots():
bp = flask.Blueprint('bp', __name__)
@bp.route('/foo')
@ -361,7 +359,7 @@ class TestBlueprint(TestFlask):
rv = c.get('/py/bar/123')
assert rv.status_code == 404
def test_template_filter(self):
def test_template_filter():
bp = flask.Blueprint('bp', __name__)
@bp.app_template_filter()
def my_reverse(s):
@ -372,7 +370,7 @@ class TestBlueprint(TestFlask):
assert app.jinja_env.filters['my_reverse'] == my_reverse
assert app.jinja_env.filters['my_reverse']('abcd') == 'dcba'
def test_add_template_filter(self):
def test_add_template_filter():
bp = flask.Blueprint('bp', __name__)
def my_reverse(s):
return s[::-1]
@ -383,7 +381,7 @@ class TestBlueprint(TestFlask):
assert app.jinja_env.filters['my_reverse'] == my_reverse
assert app.jinja_env.filters['my_reverse']('abcd') == 'dcba'
def test_template_filter_with_name(self):
def test_template_filter_with_name():
bp = flask.Blueprint('bp', __name__)
@bp.app_template_filter('strrev')
def my_reverse(s):
@ -394,7 +392,7 @@ class TestBlueprint(TestFlask):
assert app.jinja_env.filters['strrev'] == my_reverse
assert app.jinja_env.filters['strrev']('abcd') == 'dcba'
def test_add_template_filter_with_name(self):
def test_add_template_filter_with_name():
bp = flask.Blueprint('bp', __name__)
def my_reverse(s):
return s[::-1]
@ -405,7 +403,7 @@ class TestBlueprint(TestFlask):
assert app.jinja_env.filters['strrev'] == my_reverse
assert app.jinja_env.filters['strrev']('abcd') == 'dcba'
def test_template_filter_with_template(self):
def test_template_filter_with_template():
bp = flask.Blueprint('bp', __name__)
@bp.app_template_filter()
def super_reverse(s):
@ -418,7 +416,7 @@ class TestBlueprint(TestFlask):
rv = app.test_client().get('/')
assert rv.data == b'dcba'
def test_template_filter_after_route_with_template(self):
def test_template_filter_after_route_with_template():
app = flask.Flask(__name__)
@app.route('/')
def index():
@ -431,7 +429,7 @@ class TestBlueprint(TestFlask):
rv = app.test_client().get('/')
assert rv.data == b'dcba'
def test_add_template_filter_with_template(self):
def test_add_template_filter_with_template():
bp = flask.Blueprint('bp', __name__)
def super_reverse(s):
return s[::-1]
@ -444,7 +442,7 @@ class TestBlueprint(TestFlask):
rv = app.test_client().get('/')
assert rv.data == b'dcba'
def test_template_filter_with_name_and_template(self):
def test_template_filter_with_name_and_template():
bp = flask.Blueprint('bp', __name__)
@bp.app_template_filter('super_reverse')
def my_reverse(s):
@ -457,7 +455,7 @@ class TestBlueprint(TestFlask):
rv = app.test_client().get('/')
assert rv.data == b'dcba'
def test_add_template_filter_with_name_and_template(self):
def test_add_template_filter_with_name_and_template():
bp = flask.Blueprint('bp', __name__)
def my_reverse(s):
return s[::-1]
@ -470,7 +468,7 @@ class TestBlueprint(TestFlask):
rv = app.test_client().get('/')
assert rv.data == b'dcba'
def test_template_test(self):
def test_template_test():
bp = flask.Blueprint('bp', __name__)
@bp.app_template_test()
def is_boolean(value):
@ -481,7 +479,7 @@ class TestBlueprint(TestFlask):
assert app.jinja_env.tests['is_boolean'] == is_boolean
assert app.jinja_env.tests['is_boolean'](False)
def test_add_template_test(self):
def test_add_template_test():
bp = flask.Blueprint('bp', __name__)
def is_boolean(value):
return isinstance(value, bool)
@ -492,7 +490,7 @@ class TestBlueprint(TestFlask):
assert app.jinja_env.tests['is_boolean'] == is_boolean
assert app.jinja_env.tests['is_boolean'](False)
def test_template_test_with_name(self):
def test_template_test_with_name():
bp = flask.Blueprint('bp', __name__)
@bp.app_template_test('boolean')
def is_boolean(value):
@ -503,7 +501,7 @@ class TestBlueprint(TestFlask):
assert app.jinja_env.tests['boolean'] == is_boolean
assert app.jinja_env.tests['boolean'](False)
def test_add_template_test_with_name(self):
def test_add_template_test_with_name():
bp = flask.Blueprint('bp', __name__)
def is_boolean(value):
return isinstance(value, bool)
@ -514,7 +512,7 @@ class TestBlueprint(TestFlask):
assert app.jinja_env.tests['boolean'] == is_boolean
assert app.jinja_env.tests['boolean'](False)
def test_template_test_with_template(self):
def test_template_test_with_template():
bp = flask.Blueprint('bp', __name__)
@bp.app_template_test()
def boolean(value):
@ -527,7 +525,7 @@ class TestBlueprint(TestFlask):
rv = app.test_client().get('/')
assert b'Success!' in rv.data
def test_template_test_after_route_with_template(self):
def test_template_test_after_route_with_template():
app = flask.Flask(__name__)
@app.route('/')
def index():
@ -540,7 +538,7 @@ class TestBlueprint(TestFlask):
rv = app.test_client().get('/')
assert b'Success!' in rv.data
def test_add_template_test_with_template(self):
def test_add_template_test_with_template():
bp = flask.Blueprint('bp', __name__)
def boolean(value):
return isinstance(value, bool)
@ -553,7 +551,7 @@ class TestBlueprint(TestFlask):
rv = app.test_client().get('/')
assert b'Success!' in rv.data
def test_template_test_with_name_and_template(self):
def test_template_test_with_name_and_template():
bp = flask.Blueprint('bp', __name__)
@bp.app_template_test('boolean')
def is_boolean(value):
@ -566,7 +564,7 @@ class TestBlueprint(TestFlask):
rv = app.test_client().get('/')
assert b'Success!' in rv.data
def test_add_template_test_with_name_and_template(self):
def test_add_template_test_with_name_and_template():
bp = flask.Blueprint('bp', __name__)
def is_boolean(value):
return isinstance(value, bool)
@ -578,8 +576,3 @@ class TestBlueprint(TestFlask):
return flask.render_template('template_test.html', value=False)
rv = app.test_client().get('/')
assert b'Success!' in rv.data
def suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestBlueprint))
return suite

4
tests/test_config.py

@ -27,7 +27,7 @@ TEST_KEY = 'foo'
SECRET_KEY = 'devkey'
class TestConfig(TestFlask):
class TestConfig(object):
def common_object_test(self, app):
assert app.secret_key == 'devkey'
@ -181,7 +181,7 @@ class TestConfig(TestFlask):
assert 'bar stuff 2' == bar_options['STUFF_2']
class TestInstance(TestFlask):
class TestInstance(object):
def test_explicit_instance_paths(self, apps_tmpdir):
with pytest.raises(ValueError) as excinfo:
flask.Flask(__name__, instance_path='instance')

12
tests/test_deprecations.py

@ -3,7 +3,7 @@
tests.deprecations
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests deprecation support.
Tests deprecation support. Not used currently.
:copyright: (c) 2014 by Armin Ronacher.
:license: BSD, see LICENSE for more details.
@ -12,13 +12,3 @@
import flask
import unittest
from tests import TestFlask, catch_warnings
class TestDeprecations(TestFlask):
"""not used currently"""
def suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestDeprecations))
return suite

38
tests/test_examples.py

@ -1,38 +0,0 @@
# -*- coding: utf-8 -*-
"""
tests.examples
~~~~~~~~~~~~~~~~~~~~~~~~
Tests the examples.
:copyright: (c) 2014 by Armin Ronacher.
:license: BSD, see LICENSE for more details.
"""
import os
import unittest
from tests import add_to_path
def setup_path():
example_path = os.path.join(os.path.dirname(__file__),
os.pardir, os.pardir, 'examples')
add_to_path(os.path.join(example_path, 'flaskr'))
add_to_path(os.path.join(example_path, 'minitwit'))
def suite():
setup_path()
suite = unittest.TestSuite()
try:
from minitwit_tests import TestMiniTwit
except ImportError:
pass
else:
suite.addTest(unittest.makeSuite(TestMiniTwit))
try:
from flaskr_tests import TestFlaskr
except ImportError:
pass
else:
suite.addTest(unittest.makeSuite(TestFlaskr))
return suite

21
tests/test_helpers.py

@ -29,7 +29,7 @@ def has_encoding(name):
return False
class TestJSON(TestFlask):
class TestJSON(object):
def test_json_bad_requests(self):
app = flask.Flask(__name__)
@ -241,7 +241,7 @@ class TestJSON(TestFlask):
except AssertionError:
assert lines == sorted_by_str
class TestSendfile(TestFlask):
class TestSendfile(object):
def test_send_file_regular(self):
app = flask.Flask(__name__)
@ -423,7 +423,7 @@ class TestSendfile(TestFlask):
rv.close()
class TestLogging(TestFlask):
class TestLogging(object):
def test_logger_cache(self):
app = flask.Flask(__name__)
@ -566,7 +566,7 @@ class TestLogging(TestFlask):
assert flask.url_for('myview', _method='POST') == '/myview/create'
class TestNoImports(TestFlask):
class TestNoImports(object):
"""Test Flasks are created without import.
Avoiding ``__import__`` helps create Flask instances where there are errors
@ -584,7 +584,7 @@ class TestNoImports(TestFlask):
assert False, 'Flask(import_name) is importing import_name.'
class TestStreaming(TestFlask):
class TestStreaming(object):
def test_streaming_with_context(self):
app = flask.Flask(__name__)
@ -641,14 +641,3 @@ class TestStreaming(TestFlask):
rv = c.get('/?name=World')
assert rv.data == b'Hello World!'
assert called == [42]
def suite():
suite = unittest.TestSuite()
if flask.json_available:
suite.addTest(unittest.makeSuite(TestJSON))
suite.addTest(unittest.makeSuite(TestSendfile))
suite.addTest(unittest.makeSuite(TestLogging))
suite.addTest(unittest.makeSuite(TestNoImports))
suite.addTest(unittest.makeSuite(TestStreaming))
return suite

4
tests/test_regression.py

@ -54,7 +54,7 @@ class _NoLeakAsserter(object):
@pytest.mark.skipif(os.environ.get('RUN_FLASK_MEMORY_TESTS') != '1',
reason='Turned off due to envvar.')
class TestMemory(TestFlask):
class TestMemory(object):
def assert_no_leak(self):
return _NoLeakAsserter(self)
@ -88,7 +88,7 @@ class TestMemory(TestFlask):
safe_join('/foo', '..')
class TestException(TestFlask):
class TestException(object):
def test_aborting(self):
class Foo(Exception):

31
tests/test_reqctx.py

@ -20,9 +20,7 @@ except ImportError:
from tests import TestFlask
class TestRequestContext(TestFlask):
def test_teardown_on_pop(self):
def test_teardown_on_pop():
buffer = []
app = flask.Flask(__name__)
@app.teardown_request
@ -35,7 +33,7 @@ class TestRequestContext(TestFlask):
ctx.pop()
assert buffer == [None]
def test_teardown_with_previous_exception(self):
def test_teardown_with_previous_exception():
buffer = []
app = flask.Flask(__name__)
@app.teardown_request
@ -51,7 +49,7 @@ class TestRequestContext(TestFlask):
assert buffer == []
assert buffer == [None]
def test_proper_test_request_context(self):
def test_proper_test_request_context():
app = flask.Flask(__name__)
app.config.update(
SERVER_NAME='localhost.localdomain:5000'
@ -91,7 +89,7 @@ class TestRequestContext(TestFlask):
with app.test_request_context('/', environ_overrides={'SERVER_NAME': 'localhost:80'}):
pass
def test_context_binding(self):
def test_context_binding():
app = flask.Flask(__name__)
@app.route('/')
def index():
@ -106,7 +104,7 @@ class TestRequestContext(TestFlask):
assert meh() == 'http://localhost/meh'
assert flask._request_ctx_stack.top is None
def test_context_test(self):
def test_context_test():
app = flask.Flask(__name__)
assert not flask.request
assert not flask.has_request_context()
@ -118,7 +116,7 @@ class TestRequestContext(TestFlask):
finally:
ctx.pop()
def test_manual_context_binding(self):
def test_manual_context_binding():
app = flask.Flask(__name__)
@app.route('/')
def index():
@ -135,7 +133,8 @@ class TestRequestContext(TestFlask):
else:
assert 0, 'expected runtime error'
def test_greenlet_context_copying(self):
@pytest.mark.skipif(greenlet is None, reason='greenlet not installed')
def test_greenlet_context_copying():
app = flask.Flask(__name__)
greenlets = []
@ -161,7 +160,8 @@ class TestRequestContext(TestFlask):
result = greenlets[0].run()
assert result == 42
def test_greenlet_context_copying_api(self):
@pytest.mark.skipif(greenlet is None, reason='greenlet not installed')
def test_greenlet_context_copying_api():
app = flask.Flask(__name__)
greenlets = []
@ -183,14 +183,3 @@ class TestRequestContext(TestFlask):
result = greenlets[0].run()
assert result == 42
# Disable test if we don't have greenlets available
if greenlet is None:
test_greenlet_context_copying = None
test_greenlet_context_copying_api = None
def suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestRequestContext))
return suite

12
tests/test_signals.py

@ -25,9 +25,7 @@ pytestmark = pytest.mark.skipif(
reason='Signals require the blinker library.'
)
class TestSignals(TestFlask):
def test_template_rendered(self):
def test_template_rendered():
app = flask.Flask(__name__)
@app.route('/')
@ -49,7 +47,7 @@ class TestSignals(TestFlask):
finally:
flask.template_rendered.disconnect(record, app)
def test_request_signals(self):
def test_request_signals():
app = flask.Flask(__name__)
calls = []
@ -88,7 +86,7 @@ class TestSignals(TestFlask):
flask.request_started.disconnect(before_request_signal, app)
flask.request_finished.disconnect(after_request_signal, app)
def test_request_exception_signal(self):
def test_request_exception_signal():
app = flask.Flask(__name__)
recorded = []
@ -107,7 +105,7 @@ class TestSignals(TestFlask):
finally:
flask.got_request_exception.disconnect(record, app)
def test_appcontext_signals(self):
def test_appcontext_signals():
app = flask.Flask(__name__)
recorded = []
@ -133,7 +131,7 @@ class TestSignals(TestFlask):
flask.appcontext_pushed.disconnect(record_push, app)
flask.appcontext_popped.disconnect(record_pop, app)
def test_flash_signal(self):
def test_flash_signal():
app = flask.Flask(__name__)
app.config['SECRET_KEY'] = 'secret'

4
tests/test_testing.py

@ -16,7 +16,7 @@ from tests import TestFlask
from flask._compat import text_type
class TestTestTools(TestFlask):
class TestTestTools(object):
def test_environ_defaults_from_config(self):
app = flask.Flask(__name__)
@ -213,7 +213,7 @@ class TestTestTools(TestFlask):
assert 'vodka' in flask.request.args
class TestSubdomain(TestFlask):
class TestSubdomain(object):
@pytest.fixture
def app(self, request):

Loading…
Cancel
Save