Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. import unittest
  2. from flask import Flask, session
  3.  
  4. app = Flask(__name__)
  5.  
  6. @app.route('/')
  7. def hello_world():
  8. t = Test()
  9. hello = t.hello()
  10. return hello
  11.  
  12. class Test:
  13. def hello(self):
  14. session['h'] = 'hello'
  15. return session['h']
  16.  
  17. class MyUnitTest(unittest.TestCase):
  18. def test_unit(self):
  19. t = tests.Test()
  20. t.hello()
  21.  
  22. c = app.test_client()
  23. response = c.get('/test/url')
  24. # test response
  25.  
  26. with app.app_context():
  27. # test your app context code
  28.  
  29. with current_app.test_request_context():
  30. # test your request context code
  31.  
  32. >>> ctx = app.app_context()
  33. >>> ctx.push()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement