Commits

danjac  committed e72aa4b

fixtures

  • Participants
  • Parent commits 282432a
  • Branches alfajor-integration

Comments (0)

Files changed (2)

File flaskext/testing.py

 
 browser = LocalProxy(lambda: _testing_ctx_stack.top.browser)
 client = LocalProxy(lambda: _testing_ctx_stack.top.client)
+fixtures = LocalProxy(lambda: _testing_ctx_stack.top.fixtures)
+
+class _GlobalFixtures(object):
+    pass
 
 class _TestContext(object):
 
         #self.browser.configure_in_scope()
     
         self.client = self.app.test_client()
+        self.fixtures = self._GlobalFixtures()
 
     def push(self):
 
         else:
             self.create_app = app
 
-    def setup(func):
+    def setup(self, func):
         self._setup_funcs.append(func)
         return func
 
-    def teardown(func):
+    def teardown(self, func):
         self._teardown_funcs.append(func)
         return func
 

File tests/__init__.py

     jsonify, render_template, current_app
 
 from flaskext.testing import TestCase, TwillTestCase, \
-    ContextVariableDoesNotExist, Testing, client
+    ContextVariableDoesNotExist, Testing, client, fixtures
 
 def create_app():
 
     response = client.get("/foo/")
     testing.assert_404(response)
 
+@testing.setup
+def set_x():
+    fixtures.x = 10
+
+@testing.with_context
+def test_fixtures():
+    assert fixtures.x == 10
+
 class TestClientUtils(TestCase):
 
     def create_app(self):