当前位置: 首页>>代码示例>>Python>>正文


Python app.test_client方法代码示例

本文整理汇总了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')) 
开发者ID:citruspi,项目名称:Flask-Analytics,代码行数:18,代码来源:test_app.py

示例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')) 
开发者ID:citruspi,项目名称:Flask-Analytics,代码行数:22,代码来源:test_app.py

示例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')) 
开发者ID:citruspi,项目名称:Flask-Analytics,代码行数:23,代码来源:test_app.py

示例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')) 
开发者ID:citruspi,项目名称:Flask-Analytics,代码行数:20,代码来源:test_app.py

示例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,
        ) 
开发者ID:quay,项目名称:quay,代码行数:26,代码来源:test_secscan.py

示例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() 
开发者ID:LibrIT,项目名称:passhport,代码行数:10,代码来源:test_user.py

示例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() 
开发者ID:LibrIT,项目名称:passhport,代码行数:12,代码来源:test_target.py

示例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() 
开发者ID:LibrIT,项目名称:passhport,代码行数:11,代码来源:test_user.py

示例9: setUp

# 需要导入模块: from app import app [as 别名]
# 或者: from app.app import test_client [as 别名]
def setUp(self):
        self.app = app.test_client() 
开发者ID:Akagi201,项目名称:learning-python,代码行数:4,代码来源:test_todo.py

示例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) 
开发者ID:Akagi201,项目名称:learning-python,代码行数:7,代码来源:app-test.py

示例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() 
开发者ID:Akagi201,项目名称:learning-python,代码行数:10,代码来源:app-test.py

示例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() 
开发者ID:IEEE-VIT,项目名称:simple-math-flask,代码行数:5,代码来源:test_app.py

示例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 
开发者ID:minetest,项目名称:contentdb,代码行数:12,代码来源:utils.py

示例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() 
开发者ID:projectweekend,项目名称:Flask-PostgreSQL-API-Seed,代码行数:7,代码来源:testing.py

示例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() 
开发者ID:contentful,项目名称:the-example-app.py,代码行数:6,代码来源:__init__.py


注:本文中的app.app.test_client方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。