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


Python files.GeneratedFile类代码示例

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


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

示例1: test_minified_verify_failure

    def test_minified_verify_failure(self):
        orig_f = GeneratedFile('\n'.join(self.orig_lines))
        min_f = MinifiedJavaScript(orig_f,
            verify_command=self._verify_command('1'))

        mini_lines = min_f.open().readlines()
        self.assertEqual(mini_lines, orig_f.open().readlines())
开发者ID:Andrel322,项目名称:gecko-dev,代码行数:7,代码来源:test_files.py

示例2: test_generated_file_open

 def test_generated_file_open(self):
     '''
     Test whether GeneratedFile.open returns an appropriately reset file
     object.
     '''
     content = ''.join(samples)
     f = GeneratedFile(content)
     self.assertEqual(content[:42], f.open().read(42))
     self.assertEqual(content, f.open().read())
开发者ID:AtulKumar2,项目名称:gecko-dev,代码行数:9,代码来源:test_files.py

示例3: test_generated_file

    def test_generated_file(self):
        '''
        Check that GeneratedFile.copy yields the proper content in the
        destination file in all situations that trigger different code paths
        (see TestFile.test_file)
        '''
        dest = self.tmppath('dest')

        for content in samples:
            f = GeneratedFile(content)
            f.copy(dest)
            self.assertEqual(content, open(dest, 'rb').read())
开发者ID:AtulKumar2,项目名称:gecko-dev,代码行数:12,代码来源:test_files.py

示例4: test_minified_verify_failure

    def test_minified_verify_failure(self):
        orig_f = GeneratedFile('\n'.join(self.orig_lines))
        errors.out = StringIO()
        min_f = MinifiedJavaScript(orig_f,
            verify_command=self._verify_command('1'))

        mini_lines = min_f.open().readlines()
        output = errors.out.getvalue()
        errors.out = sys.stderr
        self.assertEqual(output,
            'Warning: JS minification verification failed for <unknown>:\n'
            'Warning: Error message\n')
        self.assertEqual(mini_lines, orig_f.open().readlines())
开发者ID:AtulKumar2,项目名称:gecko-dev,代码行数:13,代码来源:test_files.py

示例5: test_generated_file_no_write

    def test_generated_file_no_write(self):
        '''
        Test various conditions where GeneratedFile.copy is expected not to
        write in the destination file.
        '''
        dest = self.tmppath('dest')

        # Initial copy
        f = GeneratedFile('test')
        f.copy(dest)

        # Ensure subsequent copies won't trigger writes
        f.copy(DestNoWrite(dest))
        self.assertEqual('test', open(dest, 'rb').read())

        # When using a new instance with the same content, no copy should occur
        f = GeneratedFile('test')
        f.copy(DestNoWrite(dest))
        self.assertEqual('test', open(dest, 'rb').read())

        # Double check that under conditions where a copy occurs, we would get
        # an exception.
        f = GeneratedFile('fooo')
        self.assertRaises(RuntimeError, f.copy, DestNoWrite(dest))
开发者ID:AtulKumar2,项目名称:gecko-dev,代码行数:24,代码来源:test_files.py

示例6: __init__

 def __init__(self, copier):
     self.copier = copier
     GeneratedFile.__init__(self, '')
开发者ID:npark-mozilla,项目名称:gecko-dev,代码行数:3,代码来源:packager.py

示例7: __init__

 def __init__(self, path, content):
     GeneratedFile.__init__(self, content)
     self.path = path
开发者ID:AtulKumar2,项目名称:gecko-dev,代码行数:3,代码来源:test_packager.py


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