• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python utils._函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tests.utils._函数的典型用法代码示例。如果您正苦于以下问题:Python _函数的具体用法?Python _怎么用?Python _使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了_函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_encoded_content

 def test_encoded_content(self, mock):
     self.compressor.asset_contents.clear()
     self.compressor.encoded_content(_('pipeline/images/arrow.png'))
     self.assertTrue(mock.called)
     mock.reset_mock()
     self.compressor.encoded_content(_('pipeline/images/arrow.png'))
     self.assertFalse(mock.called)
开发者ID:danxshap,项目名称:django-pipeline,代码行数:7,代码来源:test_compressor.py


示例2: test_compile_templates

 def test_compile_templates(self):
     templates = self.compressor.compile_templates([_('pipeline/templates/photo/list.jst')])
     self.assertEqual(templates, """window.JST = window.JST || {};\n%s\nwindow.JST[\'list\'] = template(\'<div class="photo">\\n <img src="<%%= src %%>" />\\n <div class="caption">\\n  <%%= caption %%>\\n </div>\\n</div>\');\n""" % TEMPLATE_FUNC)
     templates = self.compressor.compile_templates([
         _('pipeline/templates/video/detail.jst'),
         _('pipeline/templates/photo/detail.jst')
     ])
     self.assertEqual(templates, """window.JST = window.JST || {};\n%s\nwindow.JST[\'video_detail\'] = template(\'<div class="video">\\n <video src="<%%= src %%>" />\\n <div class="caption">\\n  <%%= description %%>\\n </div>\\n</div>\');\nwindow.JST[\'photo_detail\'] = template(\'<div class="photo">\\n <img src="<%%= src %%>" />\\n <div class="caption">\\n  <%%= caption %%> by <%%= author %%>\\n </div>\\n</div>\');\n""" % TEMPLATE_FUNC)
开发者ID:danxshap,项目名称:django-pipeline,代码行数:8,代码来源:test_compressor.py


示例3: test_templates

 def test_templates(self):
     packager = Packager()
     packages = packager.create_packages({
         'templates': {
             'source_filenames': (
                 _('pipeline/templates/photo/list.jst'),
             ),
             'output_filename': 'templates.js',
         }
     })
     self.assertEqual(packages['templates'].templates, [_('pipeline/templates/photo/list.jst')])
开发者ID:Alexx-G,项目名称:django-pipeline,代码行数:11,代码来源:test_packager.py


示例4: _test_compiler

 def _test_compiler(self, compiler_cls_str, infile, expected):
     compiler_cls = to_class(compiler_cls_str)
     compiler = compiler_cls(verbose=False, storage=staticfiles_storage)
     infile_path = staticfiles_storage.path(infile)
     outfile_path = compiler.output_path(infile_path, compiler.output_extension)
     compiler.compile_file(_(infile_path), _(outfile_path), force=True)
     with open(outfile_path) as f:
         result = f.read()
     with staticfiles_storage.open(expected) as f:
         expected = f.read()
     self.assertEqual(smart_bytes(result), expected)
开发者ID:chipx86,项目名称:django-pipeline,代码行数:11,代码来源:test_compiler.py


示例5: setUp

 def setUp(self):
     settings.PIPELINE_CSS = {
         'testing': {
             'source_filenames': (
                 _('pipeline/css/first.css'),
                 _('css/third.css'),
             ),
             'manifest': False,
             'output_filename': 'testing.css',
         }
     }
     settings.PIPELINE_JS_COMPRESSOR = None
     settings.PIPELINE_CSS_COMPRESSOR = None
     self.storage = PipelineStorage()
开发者ID:AndreaCrotti,项目名称:django-pipeline,代码行数:14,代码来源:test_storage.py


示例6: _test_compressor

 def _test_compressor(self, compressor_cls, compress_type, expected_file):
     override_settings = {
         ("%s_COMPRESSOR" % compress_type.upper()): compressor_cls,
     }
     with pipeline_settings(**override_settings):
         if compress_type == 'js':
             result = self.compressor.compress_js(
                 [_('pipeline/js/first.js'), _('pipeline/js/second.js')])
         else:
             result = self.compressor.compress_css(
                 [_('pipeline/css/first.css'), _('pipeline/css/second.css')],
                 os.path.join('pipeline', 'css', os.path.basename(expected_file)))
     with self.compressor.storage.open(expected_file) as f:
         expected = f.read()
     self.assertEqual(smart_bytes(result), expected)
开发者ID:danxshap,项目名称:django-pipeline,代码行数:15,代码来源:test_compressor.py


示例7: test_url_rewrite

    def test_url_rewrite(self):
        output = self.compressor.concatenate_and_rewrite([
            _('pipeline/css/urls.css'),
        ], 'css/screen.css')
        self.assertEqual("""@font-face {
  font-family: 'Pipeline';
  src: url(../pipeline/fonts/pipeline.eot);
  src: url(../pipeline/fonts/pipeline.eot?#iefix) format('embedded-opentype');
  src: local('☺'), url(../pipeline/fonts/pipeline.woff) format('woff'), url(../pipeline/fonts/pipeline.ttf) format('truetype'), url(../pipeline/fonts/pipeline.svg#IyfZbseF) format('svg');
  font-weight: normal;
  font-style: normal;
}
.relative-url {
  background-image: url(../pipeline/images/sprite-buttons.png);
}
.relative-url-querystring {
  background-image: url(../pipeline/images/sprite-buttons.png?v=1.0#foo=bar);
}
.absolute-url {
  background-image: url(/images/sprite-buttons.png);
}
.absolute-full-url {
  background-image: url(http://localhost/images/sprite-buttons.png);
}
.no-protocol-url {
  background-image: url(//images/sprite-buttons.png);
}
.anchor-tag-url {
  background-image: url(#image-gradient);
}
@font-face{src:url(../pipeline/fonts/pipeline.eot);src:url(../pipeline/fonts/pipeline.eot?#iefix) format('embedded-opentype'),url(../pipeline/fonts/pipeline.woff) format('woff'),url(../pipeline/fonts/pipeline.ttf) format('truetype');}
""", output)
开发者ID:Bogh,项目名称:django-pipeline,代码行数:32,代码来源:test_compressor.py


示例8: test_url_rewrite

    def test_url_rewrite(self):
        output = self.compressor.concatenate_and_rewrite([
            _('pipeline/css/urls.css'),
        ], 'css/screen.css')
        self.assertEqual(""".embedded-url-svg {
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath      stroke='rgba(255, 255, 255, 0.5)' stroke-width='2' stroke-linecap='round' stroke-miterlimit='10' d='M4 8h24M4 16h24M4 24h24'/%3E%     3C/svg%3E");
}
@font-face {
  font-family: 'Pipeline';
  src: url(../pipeline/fonts/pipeline.eot);
  src: url(../pipeline/fonts/pipeline.eot?#iefix) format('embedded-opentype');
  src: local('☺'), url(../pipeline/fonts/pipeline.woff) format('woff'), url(../pipeline/fonts/pipeline.ttf) format('truetype'), url(../pipeline/fonts/pipeline.svg#IyfZbseF) format('svg');
  font-weight: normal;
  font-style: normal;
}
.relative-url {
  background-image: url(../pipeline/images/sprite-buttons.png);
}
.relative-url-querystring {
  background-image: url(../pipeline/images/sprite-buttons.png?v=1.0#foo=bar);
}
.absolute-url {
  background-image: url(/images/sprite-buttons.png);
}
.absolute-full-url {
  background-image: url(http://localhost/images/sprite-buttons.png);
}
.no-protocol-url {
  background-image: url(//images/sprite-buttons.png);
}
.anchor-tag-url {
  background-image: url(#image-gradient);
}
@font-face{src:url(../pipeline/fonts/pipeline.eot);src:url(../pipeline/fonts/pipeline.eot?#iefix) format('embedded-opentype'),url(../pipeline/fonts/pipeline.woff) format('woff'),url(../pipeline/fonts/pipeline.ttf) format('truetype');}
""", output)
开发者ID:danxshap,项目名称:django-pipeline,代码行数:35,代码来源:test_compressor.py


示例9: test_encoded_content_output

 def test_encoded_content_output(self):
     self.compressor.asset_contents.clear()
     encoded = self.compressor.encoded_content(_('pipeline/images/arrow.png'))
     expected = ('iVBORw0KGgoAAAANSUhEUgAAAAkAAAAGCAYAAAARx7TFAAAAMk'
                 'lEQVR42oXKwQkAMAxC0Q7rEk5voSEepCHC9/SOpLV3JPULgArV'
                 'RtDIMEEiQ4NECRNdciCfK3K3wvEAAAAASUVORK5CYII=')
     self.assertEqual(encoded, expected)
开发者ID:danxshap,项目名称:django-pipeline,代码行数:7,代码来源:test_compressor.py


示例10: test_compile

    def test_compile(self):
        with self.assertRaises(CompilerError) as cm:
            self.compiler.compile([_('pipeline/js/dummy.coffee')])

            e = cm.exception
            self.assertEqual(e.command, ['/usr/bin/env', 'false'])
            self.assertEqual(e.error_output, '')
开发者ID:chipx86,项目名称:django-pipeline,代码行数:7,代码来源:test_compiler.py


示例11: test_url_rewrite_data_uri

    def test_url_rewrite_data_uri(self):
        output = self.compressor.concatenate_and_rewrite([
            _('pipeline/css/nested/nested.css'),
        ], 'pipeline/screen.css')
        self.assertEqual(""".data-url {
  background-image: url(data:image/svg+xml;charset=US-ASCII,%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22iso-8859-1%22%3F%3E%3C!DOCTYPE%20svg%20PUBLIC%20%22-%2F%2FW3C%2F%2FDTD%20SVG%201.1%2F%2FEN%22%20%22http%3A%2F%2Fwww.w3.org%2FGraphics%2FSVG%2F1.1%2FDTD%2Fsvg11.dtd%22%3E%3Csvg%20version%3D%221.1%22%20id%3D%22Layer_1%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22%20x%3D%220px%22%20y%3D%220px%22%20%20width%3D%2212px%22%20height%3D%2214px%22%20viewBox%3D%220%200%2012%2014%22%20style%3D%22enable-background%3Anew%200%200%2012%2014%3B%22%20xml%3Aspace%3D%22preserve%22%3E%3Cpath%20d%3D%22M11%2C6V5c0-2.762-2.239-5-5-5S1%2C2.238%2C1%2C5v1H0v8h12V6H11z%20M6.5%2C9.847V12h-1V9.847C5.207%2C9.673%2C5%2C9.366%2C5%2C9%20c0-0.553%2C0.448-1%2C1-1s1%2C0.447%2C1%2C1C7%2C9.366%2C6.793%2C9.673%2C6.5%2C9.847z%20M9%2C6H3V5c0-1.657%2C1.343-3%2C3-3s3%2C1.343%2C3%2C3V6z%22%2F%3E%3Cg%3E%3C%2Fg%3E%3Cg%3E%3C%2Fg%3E%3Cg%3E%3C%2Fg%3E%3Cg%3E%3C%2Fg%3E%3Cg%3E%3C%2Fg%3E%3Cg%3E%3C%2Fg%3E%3Cg%3E%3C%2Fg%3E%3Cg%3E%3C%2Fg%3E%3Cg%3E%3C%2Fg%3E%3Cg%3E%3C%2Fg%3E%3Cg%3E%3C%2Fg%3E%3Cg%3E%3C%2Fg%3E%3Cg%3E%3C%2Fg%3E%3Cg%3E%3C%2Fg%3E%3Cg%3E%3C%2Fg%3E%3C%2Fsvg%3E);
}
""", output)
开发者ID:alexhayes,项目名称:django-pipeline,代码行数:8,代码来源:test_compressor.py


示例12: test_compress_js_with_source_map

    def test_compress_js_with_source_map(self, mock_constructor):
        mock_js_compressor = MagicMock()
        mock_constructor.return_value = mock_js_compressor
        mock_js_compressor.compress_js_with_source_map.return_value = ['code', 'map']

        paths = [
            _('pipeline/js/first.js'),
            _('pipeline/js/second.js')
        ]
        (js, source_map) = self.compressor.compress_js(paths, source_map_filename='map.js')
        self.assertEqual(js, 'code')
        self.assertEqual(source_map, 'map')
        call = mock_js_compressor.compress_js_with_source_map.call_args_list[0]
        call_args = call[0]
        self.assertRegexpMatches(call_args[0][0], 'first.js')
        self.assertRegexpMatches(call_args[0][1], 'second.js')
        self.assertEquals(call_args[1], 'map.js')
        self.assertEquals(call_args[2], '/static/')
        self.assertEquals(call_args[3], 'tests/static/')
开发者ID:zapier,项目名称:django-pipeline,代码行数:19,代码来源:test_compressor.py


示例13: test_package_for

 def test_package_for(self):
     packager = Packager()
     packager.packages['js'] = packager.create_packages({
         'application': {
             'source_filenames': (
                 _('pipeline/js/application.js'),
             ),
             'output_filename': 'application.js'
         }
     })
     try:
         packager.package_for('js', 'application')
     except PackageNotFound:
         self.fail()
     try:
         packager.package_for('js', 'broken')
         self.fail()
     except PackageNotFound:
         pass
开发者ID:Alexx-G,项目名称:django-pipeline,代码行数:19,代码来源:test_packager.py


示例14: test_concatenate

 def test_concatenate(self):
     js = self.compressor.concatenate([
         _('pipeline/js/first.js'),
         _('pipeline/js/second.js')
     ])
     self.assertEqual("""(function() {\n  window.concat = function() {\n    console.log(arguments);\n  }\n}()) // No semicolon\n\n;(function() {\n  window.cat = function() {\n    console.log("hello world");\n  }\n}());\n""", js)
开发者ID:danxshap,项目名称:django-pipeline,代码行数:6,代码来源:test_compressor.py


示例15: test_concatenate_and_rewrite

 def test_concatenate_and_rewrite(self):
     css = self.compressor.concatenate_and_rewrite([
         _('pipeline/css/first.css'),
         _('pipeline/css/second.css')
     ], 'css/screen.css')
     self.assertEqual(""".concat {\n  display: none;\n}\n\n.concatenate {\n  display: block;\n}\n""", css)
开发者ID:danxshap,项目名称:django-pipeline,代码行数:6,代码来源:test_compressor.py


示例16: test_embeddable

 def test_embeddable(self):
     self.assertFalse(self.compressor.embeddable(_('pipeline/images/sprite.png'), None))
     self.assertFalse(self.compressor.embeddable(_('pipeline/images/arrow.png'), 'datauri'))
     self.assertTrue(self.compressor.embeddable(_('pipeline/images/embed/arrow.png'), 'datauri'))
     self.assertFalse(self.compressor.embeddable(_('pipeline/images/arrow.dat'), 'datauri'))
开发者ID:danxshap,项目名称:django-pipeline,代码行数:5,代码来源:test_compressor.py


示例17: test_compile

 def test_compile(self):
     paths = self.compiler.compile([_("pipeline/js/dummy.coffee"), _("pipeline/js/application.js")])
     self.assertEqual([_("pipeline/js/dummy.js"), _("pipeline/js/application.js")], paths)
开发者ID:Xowap,项目名称:django-pipeline,代码行数:3,代码来源:test_compiler.py


示例18: test_base_path

 def test_base_path(self):
     base_path = self.compressor.base_path([
         _('js/templates/form.jst'), _('js/templates/field.jst')
     ])
     self.assertEqual(base_path, _('js/templates'))
开发者ID:danxshap,项目名称:django-pipeline,代码行数:5,代码来源:test_compressor.py


示例19: test_compile

 def test_compile(self):
     paths = self.compiler.compile([
         _('pipeline/js/dummy.coffee'),
         _('pipeline/js/application.js'),
     ])
     self.assertEqual([_('pipeline/js/dummy.js'), _('pipeline/js/application.js')], list(paths))
开发者ID:Alexx-G,项目名称:django-pipeline,代码行数:6,代码来源:test_compiler.py


示例20: test_compile

 def test_compile(self):
     self.assertRaises(CompilerError, self.compiler.compile, [_('pipeline/js/dummy.coffee')])
开发者ID:ChristopherBrix,项目名称:django-pipeline,代码行数:2,代码来源:test_compiler.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.assert_error_message_equal函数代码示例发布时间:2022-05-27
下一篇:
Python shell_util.exec_process函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap