Skip to content

Instantly share code, notes, and snippets.

@ismaild
Created November 23, 2012 12:32
Show Gist options
  • Select an option

  • Save ismaild/4135430 to your computer and use it in GitHub Desktop.

Select an option

Save ismaild/4135430 to your computer and use it in GitHub Desktop.
tests for flask
from flask import Flask
app = Flask(__name__)
from flask import render_template
from charts import sites_charts
from dashboard import app
@app.route('/sites')
def site_dashboard():
return render_template('dashboard.html', object_list=sites_charts)
@app.route('/')
def hello():
return render_template('home.html')
F
======================================================================
FAIL: test_no_data (__main__.DashTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "tests.py", line 16, in test_no_data
assert 'PLACEHOLDER' in rv.data
AssertionError
----------------------------------------------------------------------
Ran 1 test in 0.012s
FAILED (failures=1)
import dashboard
import unittest
class DashTestCase(unittest.TestCase):
def setUp(self):
dashboard.app.config['TESTING'] = True
self.app = dashboard.app.test_client()
print self.app
def tearDown(self):
pass
def test_no_data(self):
rv = self.app.get('/')
assert 'placeholder' in rv.data
if __name__ == '__main__':
unittest.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment