Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import unittest
- from flask import Flask, session
- app = Flask(__name__)
- @app.route('/')
- def hello_world():
- t = Test()
- hello = t.hello()
- return hello
- class Test:
- def hello(self):
- session['h'] = 'hello'
- return session['h']
- class MyUnitTest(unittest.TestCase):
- def test_unit(self):
- t = tests.Test()
- t.hello()
- c = app.test_client()
- response = c.get('/test/url')
- # test response
- with app.app_context():
- # test your app context code
- with current_app.test_request_context():
- # test your request context code
- >>> ctx = app.app_context()
- >>> ctx.push()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement