本文整理汇总了Python中app.app.test_client方法的典型用法代码示例。如果您正苦于以下问题:Python app.test_client方法的具体用法?Python app.test_client怎么用?Python app.test_client使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app.app
的用法示例。
在下文中一共展示了app.test_client方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_gosquared
# 需要导入模块: from app import app [as 别名]
# 或者: from app.app import test_client [as 别名]
def test_gosquared(self):
self.test_app = app.test_client()
response = self.test_app.get('/gosquared/')
expected = """<script>
!function(g,s,q,r,d){r=g[r]=g[r]||function(){(r.q=r.q||[]).push(
arguments)};d=s.createElement(q);q=s.getElementsByTagName(q)[0];
d.src='//d1l6p2sc9645hc.cloudfront.net/tracker.js';q.parentNode.
insertBefore(d,q)}(window,document,'script','_gs');
_gs('ahz1Nahqueorahw');
</script>"""
self.assertEquals(response.data, expected.encode('utf8'))
示例2: test_piwik
# 需要导入模块: from app import app [as 别名]
# 或者: from app.app import test_client [as 别名]
def test_piwik(self):
self.test_app = app.test_client()
response = self.test_app.get('/piwik/')
expected = """<script type="text/javascript">
var _paq = _paq || [];
(function(){
var u=(("https:" == document.location.protocol) ? "https://aeniki8pheiFiad/" : "http://aeniki8pheiFiad/");
_paq.push(['setSiteId', 'uiP3eeKie6ohDo6']);
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript'; g.defer=true; g.async=true; g.src=u+'piwik.js';
s.parentNode.insertBefore(g,s);
})();
</script>"""
self.assertEquals(response.data, expected.encode('utf8'))
示例3: test_google_classic
# 需要导入模块: from app import app [as 别名]
# 或者: from app.app import test_client [as 别名]
def test_google_classic(self):
self.test_app = app.test_client()
response = self.test_app.get('/google-classic/')
expected = """<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'wiengech9tiefuW']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>"""
self.assertEquals(response.data, expected.encode('utf8'))
示例4: test_google_universal
# 需要导入模块: from app import app [as 别名]
# 或者: from app.app import test_client [as 别名]
def test_google_universal(self):
self.test_app = app.test_client()
response = self.test_app.get('/google-universal/')
expected = """<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'iqmbak3kfpdg2N', 'auto');
ga('send', 'pageview');
</script>"""
self.assertEquals(response.data, expected.encode('utf8'))
示例5: setUp
# 需要导入模块: from app import app [as 别名]
# 或者: from app.app import test_client [as 别名]
def setUp(self):
# Enable direct download in fake storage.
storage.put_content(["local_us"], "supports_direct_download", b"true")
# Have fake storage say all files exist for the duration of the test.
storage.put_content(["local_us"], "all_files_exist", b"true")
# Setup the database with fake storage.
setup_database_for_testing(self)
self.app = app.test_client()
self.ctx = app.test_request_context()
self.ctx.__enter__()
instance_keys = InstanceKeys(app)
self.api = SecurityScannerAPI(
app.config,
storage,
app.config["SERVER_HOSTNAME"],
app.config["HTTPCLIENT"],
uri_creator=get_blob_download_uri_getter(
app.test_request_context("/"), url_scheme_and_hostname
),
instance_keys=instance_keys,
)
示例6: setUp
# 需要导入模块: from app import app [as 别名]
# 或者: from app.app import test_client [as 别名]
def setUp(self):
app.config['TESTING'] = True
app.config['WTF_CSRF_ENABLED'] = False
app.config['DEBUG'] = False
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///:memory:'
self.app = app.test_client()
db.drop_all()
db.create_all()
示例7: setup_class
# 需要导入模块: from app import app [as 别名]
# 或者: from app.app import test_client [as 别名]
def setup_class(cls):
"""Initialize configuration and create an empty database before
testing
"""
app.config["TESTING"] = True
app.config["WTF_CSRF_ENABLED"] = False
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///:memory:"# /" + \
# os.path.join("/tmp/", "test.db")
cls.app = app.test_client()
db.create_all()
示例8: setup_class
# 需要导入模块: from app import app [as 别名]
# 或者: from app.app import test_client [as 别名]
def setup_class(cls):
"""Initialize configuration and create an empty database before
testing
"""
app.config['TESTING'] = True
app.config['WTF_CSRF_ENABLED'] = False
app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:///:memory:"
cls.app = app.test_client()
db.create_all()
示例9: setUp
# 需要导入模块: from app import app [as 别名]
# 或者: from app.app import test_client [as 别名]
def setUp(self):
self.app = app.test_client()
示例10: test_index
# 需要导入模块: from app import app [as 别名]
# 或者: from app.app import test_client [as 别名]
def test_index(self):
"""inital test. ensure flask was set up correctly"""
tester = app.test_client(self)
response = tester.get('/', content_type='html/text')
self.assertEqual(response.status_code, 200)
示例11: setUp
# 需要导入模块: from app import app [as 别名]
# 或者: from app.app import test_client [as 别名]
def setUp(self):
"""Set up a blank temp database before each test"""
basedir = os.path.abspath(os.path.dirname(__file__))
app.config['TESTING'] = True
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + \
os.path.join(basedir, TEST_DB)
self.app = app.test_client()
db.create_all()
示例12: setUp
# 需要导入模块: from app import app [as 别名]
# 或者: from app.app import test_client [as 别名]
def setUp(self):
app.testing = True
self.app = app.test_client()
示例13: client
# 需要导入模块: from app import app [as 别名]
# 或者: from app.app import test_client [as 别名]
def client():
app.config["TESTING"] = True
recreate_db()
assert User.query.count() == 1
with app.test_client() as client:
yield client
app.config["TESTING"] = False
示例14: setUp
# 需要导入模块: from app import app [as 别名]
# 或者: from app.app import test_client [as 别名]
def setUp(self):
app.config['TESTING'] = True
app.config['DEBUG'] = True
self.app = app.test_client()
db.create_all()
示例15: setUp
# 需要导入模块: from app import app [as 别名]
# 或者: from app.app import test_client [as 别名]
def setUp(self):
I18n(app)
app.testing = True
self.app = app.test_client()