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


Python support.findfile函数代码示例

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


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

示例1: test_expat_locator_withinfo

    def test_expat_locator_withinfo(self):
        result = StringIO()
        xmlgen = XMLGenerator(result)
        parser = create_parser()
        parser.setContentHandler(xmlgen)
        parser.parse(findfile("test.xml"))

        self.assertEqual(parser.getSystemId(), findfile("test.xml"))
        self.assertEqual(parser.getPublicId(), None)
开发者ID:henrywoo,项目名称:Python3.1.3-Linux,代码行数:9,代码来源:test_sax.py

示例2: test_snd_memory

 def test_snd_memory(self):
     with open(support.findfile('pluck-pcm8.wav',
                                subdir='audiodata'), 'rb') as f:
         audio_data = f.read()
     safe_PlaySound(audio_data, winsound.SND_MEMORY)
     audio_data = bytearray(audio_data)
     safe_PlaySound(audio_data, winsound.SND_MEMORY)
开发者ID:3lnc,项目名称:cpython,代码行数:7,代码来源:test_winsound.py

示例3: test_random_files

    def test_random_files(self):
        # Test roundtrip on random python modules.
        # pass the '-ucpu' option to process the full directory.

        import glob, random
        fn = support.findfile("tokenize_tests.txt")
        tempdir = os.path.dirname(fn) or os.curdir
        testfiles = glob.glob(os.path.join(tempdir, "test*.py"))

        # Tokenize is broken on test_pep3131.py because regular expressions are
        # broken on the obscure unicode identifiers in it. *sigh*
        # With roundtrip extended to test the 5-tuple mode of  untokenize,
        # 7 more testfiles fail.  Remove them also until the failure is diagnosed.

        testfiles.remove(os.path.join(tempdir, "test_pep3131.py"))
        for f in ('buffer', 'builtin', 'fileio', 'inspect', 'os', 'platform', 'sys'):
            testfiles.remove(os.path.join(tempdir, "test_%s.py") % f)

        if not support.is_resource_enabled("cpu"):
            testfiles = random.sample(testfiles, 10)

        for testfile in testfiles:
            with open(testfile, 'rb') as f:
                with self.subTest(file=testfile):
                    self.check_roundtrip(f)
开发者ID:chidea,项目名称:GoPythonDLLWrapper,代码行数:25,代码来源:test_tokenize.py

示例4: test_cfgparser_dot_3

 def test_cfgparser_dot_3(self):
     tricky = support.findfile("cfgparser.3")
     cf = self.newconfig()
     self.assertEqual(len(cf.read(tricky, encoding='utf-8')), 1)
     self.assertEqual(cf.sections(), ['strange',
                                      'corruption',
                                      'yeah, sections can be '
                                      'indented as well',
                                      'another one!',
                                      'no values here',
                                      'tricky interpolation',
                                      'more interpolation'])
     self.assertEqual(cf.getint(self.default_section, 'go',
                                vars={'interpolate': '-1'}), -1)
     with self.assertRaises(ValueError):
         # no interpolation will happen
         cf.getint(self.default_section, 'go', raw=True,
                   vars={'interpolate': '-1'})
     self.assertEqual(len(cf.get('strange', 'other').split('\n')), 4)
     self.assertEqual(len(cf.get('corruption', 'value').split('\n')), 10)
     longname = 'yeah, sections can be indented as well'
     self.assertFalse(cf.getboolean(longname, 'are they subsections'))
     self.assertEqual(cf.get(longname, 'lets use some Unicode'), '片仮名')
     self.assertEqual(len(cf.items('another one!')), 5) # 4 in section and
                                                        # `go` from DEFAULT
     with self.assertRaises(configparser.InterpolationMissingOptionError):
         cf.items('no values here')
     self.assertEqual(cf.get('tricky interpolation', 'lets'), 'do this')
     self.assertEqual(cf.get('tricky interpolation', 'lets'),
                      cf.get('tricky interpolation', 'go'))
     self.assertEqual(cf.get('more interpolation', 'lets'), 'go shopping')
开发者ID:pogigroo,项目名称:py3k-__format__,代码行数:31,代码来源:test_cfgparser.py

示例5: test_close_opened_files_on_error

 def test_close_opened_files_on_error(self):
     non_aifc_file = findfile('pluck-pcm8.wav', subdir='audiodata')
     with check_no_resource_warning(self):
         with self.assertRaises(aifc.Error):
             # Try opening a non-AIFC file, with the expectation that
             # `aifc.open` will fail (without raising a ResourceWarning)
             f = self.f = aifc.open(non_aifc_file, 'rb')
开发者ID:amosonn,项目名称:cpython,代码行数:7,代码来源:test_aifc.py

示例6: test_parse_errors

 def test_parse_errors(self):
     cf = self.newconfig()
     self.parse_error(cf, configparser.ParsingError,
                      "[Foo]\n"
                      "{}val-without-opt-name\n".format(self.delimiters[0]))
     self.parse_error(cf, configparser.ParsingError,
                      "[Foo]\n"
                      "{}val-without-opt-name\n".format(self.delimiters[1]))
     e = self.parse_error(cf, configparser.MissingSectionHeaderError,
                          "No Section!\n")
     self.assertEqual(e.args, ('<???>', 1, "No Section!\n"))
     if not self.allow_no_value:
         e = self.parse_error(cf, configparser.ParsingError,
                             "[Foo]\n  wrong-indent\n")
         self.assertEqual(e.args, ('<???>',))
         # read_file on a real file
         tricky = support.findfile("cfgparser.3")
         if self.delimiters[0] == '=':
             error = configparser.ParsingError
             expected = (tricky,)
         else:
             error = configparser.MissingSectionHeaderError
             expected = (tricky, 1,
                         '  # INI with as many tricky parts as possible\n')
         with open(tricky, encoding='utf-8') as f:
             e = self.parse_error(cf, error, f)
         self.assertEqual(e.args, expected)
开发者ID:pogigroo,项目名称:py3k-__format__,代码行数:27,代码来源:test_cfgparser.py

示例7: test_load_file

    def test_load_file(self):
        # Borrow test/cfgparser.1 from test_configparser.
        config_path = findfile('cfgparser.1')
        parser = config.IdleConfParser(config_path)
        parser.Load()

        self.assertEqual(parser.Get('Foo Bar', 'foo'), 'newbar')
        self.assertEqual(parser.GetOptionList('Foo Bar'), ['foo'])
开发者ID:Apoorvadabhere,项目名称:cpython,代码行数:8,代码来源:test_config.py

示例8: test_html_diff

    def test_html_diff(self):
        # Check SF patch 914575 for generating HTML differences
        f1a = ((patch914575_from1 + '123\n'*10)*3)
        t1a = (patch914575_to1 + '123\n'*10)*3
        f1b = '456\n'*10 + f1a
        t1b = '456\n'*10 + t1a
        f1a = f1a.splitlines()
        t1a = t1a.splitlines()
        f1b = f1b.splitlines()
        t1b = t1b.splitlines()
        f2 = patch914575_from2.splitlines()
        t2 = patch914575_to2.splitlines()
        f3 = patch914575_from3
        t3 = patch914575_to3
        i = difflib.HtmlDiff()
        j = difflib.HtmlDiff(tabsize=2)
        k = difflib.HtmlDiff(wrapcolumn=14)

        full = i.make_file(f1a,t1a,'from','to',context=False,numlines=5)
        tables = '\n'.join(
            [
             '<h2>Context (first diff within numlines=5(default))</h2>',
             i.make_table(f1a,t1a,'from','to',context=True),
             '<h2>Context (first diff after numlines=5(default))</h2>',
             i.make_table(f1b,t1b,'from','to',context=True),
             '<h2>Context (numlines=6)</h2>',
             i.make_table(f1a,t1a,'from','to',context=True,numlines=6),
             '<h2>Context (numlines=0)</h2>',
             i.make_table(f1a,t1a,'from','to',context=True,numlines=0),
             '<h2>Same Context</h2>',
             i.make_table(f1a,f1a,'from','to',context=True),
             '<h2>Same Full</h2>',
             i.make_table(f1a,f1a,'from','to',context=False),
             '<h2>Empty Context</h2>',
             i.make_table([],[],'from','to',context=True),
             '<h2>Empty Full</h2>',
             i.make_table([],[],'from','to',context=False),
             '<h2>tabsize=2</h2>',
             j.make_table(f2,t2),
             '<h2>tabsize=default</h2>',
             i.make_table(f2,t2),
             '<h2>Context (wrapcolumn=14,numlines=0)</h2>',
             k.make_table(f3.splitlines(),t3.splitlines(),context=True,numlines=0),
             '<h2>wrapcolumn=14,splitlines()</h2>',
             k.make_table(f3.splitlines(),t3.splitlines()),
             '<h2>wrapcolumn=14,splitlines(True)</h2>',
             k.make_table(f3.splitlines(True),t3.splitlines(True)),
             ])
        actual = full.replace('</body>','\n%s\n</body>' % tables)
        # temporarily uncomment next three lines to baseline this test
        #f = open('test_difflib_expect.html','w')
        #f.write(actual)
        #f.close()
        expect = open(findfile('test_difflib_expect.html')).read()


        self.assertEqual(actual,expect)
开发者ID:LinkedModernismProject,项目名称:web_code,代码行数:57,代码来源:test_difflib.py

示例9: test_expat_inpsource_sysid

    def test_expat_inpsource_sysid(self):
        parser = create_parser()
        result = StringIO()
        xmlgen = XMLGenerator(result)

        parser.setContentHandler(xmlgen)
        parser.parse(InputSource(findfile("test.xml")))

        self.assertEqual(result.getvalue(), xml_test_out)
开发者ID:henrywoo,项目名称:Python3.1.3-Linux,代码行数:9,代码来源:test_sax.py

示例10: test_print_sans_lib

    def test_print_sans_lib(self):
        """Encodes and decodes using utf-8 after in an environment
        without the standard library

        Checks that the builtin utf-8 codec is always available:
        http://bugs.jython.org/issue1458"""
        subprocess.call([sys.executable, "-J-Dpython.cachedir.skip=true",
            "-J-Dpython.security.respectJavaAccessibility=false",
            support.findfile('print_sans_lib.py')])
开发者ID:isaiah,项目名称:jython3,代码行数:9,代码来源:test_codecs_jy.py

示例11: test_data

 def test_data(self):
     for filename, expected in TEST_FILES:
         filename = findfile(filename, subdir='imghdrdata')
         self.assertEqual(imghdr.what(filename), expected)
         with open(filename, 'rb') as stream:
             self.assertEqual(imghdr.what(stream), expected)
         with open(filename, 'rb') as stream:
             data = stream.read()
         self.assertEqual(imghdr.what(None, data), expected)
         self.assertEqual(imghdr.what(None, bytearray(data)), expected)
开发者ID:5outh,项目名称:Databases-Fall2014,代码行数:10,代码来源:test_imghdr.py

示例12: test_expat_inpsource_stream

    def test_expat_inpsource_stream(self):
        parser = create_parser()
        result = StringIO()
        xmlgen = XMLGenerator(result)

        parser.setContentHandler(xmlgen)
        inpsrc = InputSource()
        inpsrc.setByteStream(open(findfile("test.xml")))
        parser.parse(inpsrc)

        self.assertEqual(result.getvalue(), xml_test_out)
开发者ID:henrywoo,项目名称:Python3.1.3-Linux,代码行数:11,代码来源:test_sax.py

示例13: test_encoding

    def test_encoding(self):
        getpreferredencoding = locale.getpreferredencoding
        self.addCleanup(setattr, locale, 'getpreferredencoding',
                                 getpreferredencoding)
        locale.getpreferredencoding = lambda: 'ascii'

        filename = support.findfile("mime.types")
        mimes = mimetypes.MimeTypes([filename])
        exts = mimes.guess_all_extensions('application/vnd.geocube+xml',
                                          strict=True)
        self.assertEqual(exts, ['.g3', '.g\xb3'])
开发者ID:Connor124,项目名称:Gran-Theft-Crop-Toe,代码行数:11,代码来源:test_mimetypes.py

示例14: test_string_data

 def test_string_data(self):
     with warnings.catch_warnings():
         warnings.simplefilter("ignore", BytesWarning)
         for filename, _ in TEST_FILES:
             filename = findfile(filename, subdir='imghdrdata')
             with open(filename, 'rb') as stream:
                 data = stream.read().decode('latin1')
             with self.assertRaises(TypeError):
                 imghdr.what(io.StringIO(data))
             with self.assertRaises(TypeError):
                 imghdr.what(None, data)
开发者ID:5outh,项目名称:Databases-Fall2014,代码行数:11,代码来源:test_imghdr.py

示例15: check_create_from_file

 def check_create_from_file(self, ext):
     testfile = support.findfile("python." + ext, subdir="imghdrdata")
     image = tkinter.PhotoImage("::img::test", master=self.root, file=testfile)
     self.assertEqual(str(image), "::img::test")
     self.assertEqual(image.type(), "photo")
     self.assertEqual(image.width(), 16)
     self.assertEqual(image.height(), 16)
     self.assertEqual(image["data"], "")
     self.assertEqual(image["file"], testfile)
     self.assertIn("::img::test", self.root.image_names())
     del image
     self.assertNotIn("::img::test", self.root.image_names())
开发者ID:CabbageHead-360,项目名称:cpython,代码行数:12,代码来源:test_images.py


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