Skip to content
Myr

remove test relying on Werkzeug Local internals

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

authored by David Lord · committed by David Lord · parent 192f4ae · Browse files · 1 file+0 added−54 removed
This commit

State

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

Diff stats

1 file+0 added−54 removed

  • tests:+0 added−54 removed

1 file+0 added−54 removed

modified:tests/test_regression.py-54 removed
1import gc2import platform3import threading45import pytest61import flask29_gc_lock = threading.Lock()31112class assert_no_leak:13 def __enter__(self):14 gc.disable()15 _gc_lock.acquire()16 loc = flask._request_ctx_stack._local1718 # Force Python to track this dictionary at all times.19 # This is necessary since Python only starts tracking20 # dicts if they contain mutable objects. It's a horrible,21 # horrible hack but makes this kinda testable.22 loc.__storage__["FOOO"] = [1, 2, 3]2324 gc.collect()25 self.old_objects = len(gc.get_objects())2627 def __exit__(self, exc_type, exc_value, tb):28 gc.collect()29 new_objects = len(gc.get_objects())30 if new_objects > self.old_objects:31 pytest.fail("Example code leaked")32 _gc_lock.release()33 gc.enable()343536@pytest.mark.skipif(platform.python_implementation() == "PyPy", reason="CPython only")37def test_memory_consumption():38 app = flask.Flask(__name__)3940 @app.route("/")41 def index():42 return flask.render_template("simple_template.html", whiskey=42)4344 def fire():45 with app.test_client() as c:46 rv = c.get("/")47 assert rv.status_code == 20048 assert rv.data == b"<h1>42</h1>"4950 # Trigger caches51 fire()5253 with assert_no_leak():54 for _x in range(10):55 fire()56574def test_aborting(app):5 class Foo(Exception):6 whatever = 427
17 unmodified lines