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


Python test_support.findfile函数代码示例

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


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

示例1: test_getline

    def test_getline(self):
        getline = linecache.getline

        # Bad values for line number should return an empty string
        self.assertEqual(getline(FILENAME, 2**15), EMPTY)
        self.assertEqual(getline(FILENAME, -1), EMPTY)

        # Float values currently raise TypeError, should it?
        self.assertRaises(TypeError, getline, FILENAME, 1.1)

        # Bad filenames should return an empty string
        self.assertEqual(getline(EMPTY, 1), EMPTY)
        self.assertEqual(getline(INVALID_NAME, 1), EMPTY)

        # Check whether lines correspond to those from file iteration
        for entry in TESTS:
            filename = support.findfile( entry + '.py')
            for index, line in enumerate(open(filename)):
                self.assertEqual(line, getline(filename, index + 1))

        # Check module loading
        for entry in MODULES:
            filename = support.findfile( entry + '.py')
            for index, line in enumerate(open(filename)):
                self.assertEqual(line, getline(filename, index + 1))

        # Check that bogus data isn't returned (issue #1309567)
        empty = linecache.getlines('a/b/c/__init__.py')
        self.assertEqual(empty, [])
开发者ID:alemacgo,项目名称:pypy,代码行数:29,代码来源:test_linecache.py

示例2: test_expat_locator_withinfo

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

    return parser.getSystemId() == findfile("test.xml") and parser.getPublicId() is None
开发者ID:Oize,项目名称:pspstacklesspython,代码行数:8,代码来源:test_sax.py

示例3: test_expat_locator_withinfo

def test_expat_locator_withinfo():
    result = StringIO()
    xmlgen = LocatorTest(result)
    parser = make_parser()
    parser.setContentHandler(xmlgen)
    parser.parse(findfile("test.xml"))

    return xmlgen.location.getSystemId() == findfile("test.xml") and \
           xmlgen.location.getPublicId() is None
开发者ID:Birdbird,项目名称:StartPage,代码行数:9,代码来源:test_sax2.py

示例4: 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.assertEquals(parser.getSystemId(), findfile("test.xml"))
        self.assertEquals(parser.getPublicId(), None)
开发者ID:AkshayJoshi,项目名称:python,代码行数:9,代码来源:test_sax.py

示例5: make_test_output

def make_test_output():
    parser = make_parser()
    result = StringIO()
    xmlgen = XMLGenerator(result)

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

    outf = open(findfile("test.xml.out"), "w")
    outf.write(result.getvalue())
    outf.close()
开发者ID:Birdbird,项目名称:StartPage,代码行数:11,代码来源:test_sax2.py

示例6: test_main

def test_main():

    uu.decode(findfile("testrgb.uue"), "test.rgb")
    uu.decode(findfile("greyrgb.uue"), "greytest.rgb")

    # Test a 3 byte color image
    testimage("test.rgb")

    # Test a 1 byte greyscale image
    testimage("greytest.rgb")

    unlink("test.rgb")
    unlink("greytest.rgb")
开发者ID:bq,项目名称:witbox-updater,代码行数:13,代码来源:test_imgfile.py

示例7: test_syspath_initializer

    def test_syspath_initializer(self):
        fn = test_support.findfile('check_for_initializer_in_syspath.py')
        jar = test_support.findfile('syspath_initializer.jar')
        env = dict(CLASSPATH=jar,
                   PATH=os.environ.get('PATH', ''))

        if WINDOWS:
            # TMP is needed to give property java.io.tmpdir a sensible value
            env['TMP'] = os.environ.get('TMP', '.')
            # SystemRoot is needed to remote debug the subprocess JVM
            env['SystemRoot'] = os.environ.get('SystemRoot', '')

        self.assertEquals(0, subprocess.call([sys.executable, fn], env=env))
开发者ID:Stewori,项目名称:jython,代码行数:13,代码来源:test_jython_initializer.py

示例8: test_expat_file

def test_expat_file():
    parser = make_parser()
    result = StringIO()
    xmlgen = XMLGenerator(result)

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

    #print result.getvalue() , xml_test_out
    f = open(findfile("test.xml.result"), 'wt')
    f.write(result.getvalue())
    f.close()

    return result.getvalue() == xml_test_out
开发者ID:Birdbird,项目名称:StartPage,代码行数:14,代码来源:test_sax2.py

示例9: testimg

def testimg(rgb_file, raw_file):
    rgb_file = findfile(rgb_file)
    raw_file = findfile(raw_file)
    width, height = rgbimg.sizeofimage(rgb_file)
    rgb = rgbimg.longimagedata(rgb_file)
    if len(rgb) != width * height * 4:
        raise error, 'bad image length'
    raw = open(raw_file, 'rb').read()
    if rgb != raw:
        raise error, \
              'images don\'t match for '+rgb_file+' and '+raw_file
    for depth in [1, 3, 4]:
        rgbimg.longstoimage(rgb, width, height, depth, '@.rgb')
    os.unlink('@.rgb')
开发者ID:B-Rich,项目名称:breve,代码行数:14,代码来源:test_rgbimg.py

示例10: setClassLoaderAndCheck

    def setClassLoaderAndCheck(self, orig_jar, prefix, compile_path=''):
        # Create a new jar and compile prefer_compiled into it
        orig_jar = test_support.findfile(orig_jar)
        jar = os.path.join(self.temp_dir, os.path.basename(orig_jar))
        shutil.copy(orig_jar, jar)

        code = os.path.join(self.temp_dir, 'prefer_compiled.py')
        fp = open(code, 'w')
        fp.write('compiled = True')
        fp.close()
        py_compile.compile(code)
        zip = zipfile.ZipFile(jar, 'a')
        zip.write(os.path.join(self.temp_dir, 'prefer_compiled$py.class'),
                  os.path.join(compile_path, 'jar_pkg',
                               'prefer_compiled$py.class'))
        zip.close()

        Thread.currentThread().contextClassLoader = test_support.make_jar_classloader(jar)
        import flat_in_jar
        self.assertEquals(flat_in_jar.value, 7)
        import jar_pkg
        self.assertEquals(prefix + '/jar_pkg/__init__.py', jar_pkg.__file__)
        from jar_pkg import prefer_compiled
        self.assertEquals(prefix + '/jar_pkg/prefer_compiled$py.class', prefer_compiled.__file__)
        self.assert_(prefer_compiled.compiled)
        self.assertRaises(NameError, __import__, 'flat_bad')
        self.assertRaises(NameError, __import__, 'jar_pkg.bad')
开发者ID:Britefury,项目名称:jython,代码行数:27,代码来源:test_classpathimporter.py

示例11: load_teststring

def load_teststring(name):
    dir = test_support.findfile('cjkencodings')
    with open(os.path.join(dir, name + '.txt'), 'rb') as f:
        encoded = f.read()
    with open(os.path.join(dir, name + '-utf8.txt'), 'rb') as f:
        utf8 = f.read()
    return encoded, utf8
开发者ID:MichaelBlume,项目名称:pypy,代码行数:7,代码来源:test_multibytecodec_support.py

示例12: test_print_sans_lib

 def test_print_sans_lib(self):
     # Encode and decode using utf-8 in an environment without the standard
     # library, to check that a utf-8 codec is always available. See:
     # http://bugs.jython.org/issue1458
     subprocess.call([sys.executable, "-J-Dpython.cachedir.skip=true",
         "-S", # No site module: avoid codec registry initialised too soon
         test_support.findfile('print_sans_lib.py')])
开发者ID:jythontools,项目名称:jython,代码行数:7,代码来源:test_codecs_jy.py

示例13: test_main

def test_main():
    if verbose:
        print 'starting...'

    # This displays the tokenization of tokenize_tests.py to stdout, and
    # regrtest.py checks that this equals the expected output (in the
    # test/output/ directory).
    f = open(findfile('tokenize_tests' + os.extsep + 'txt'))
    tokenize(f.readline)
    f.close()

    # Now run test_roundtrip() over tokenize_test.py too, and over all
    # (if the "compiler" resource is enabled) or a small random sample (if
    # "compiler" is not enabled) of the test*.py files.
    f = findfile('tokenize_tests' + os.extsep + 'txt')
    test_roundtrip(f)

    testdir = os.path.dirname(f) or os.curdir
    testfiles = glob.glob(testdir + os.sep + 'test*.py')
    if not is_resource_enabled('compiler'):
        testfiles = random.sample(testfiles, 10)

    for f in testfiles:
        test_roundtrip(f)

    # Test detecton of IndentationError.
    sampleBadText = """\
def foo():
    bar
  baz
"""

    try:
        for tok in generate_tokens(StringIO(sampleBadText).readline):
            pass
    except IndentationError:
        pass
    else:
        raise TestFailed("Did not detect IndentationError:")

    # Run the doctests in this module.
    from test import test_tokenize  # i.e., this module
    from test.test_support import run_doctest
    run_doctest(test_tokenize)

    if verbose:
        print 'finished'
开发者ID:B-Rich,项目名称:breve,代码行数:47,代码来源:test_tokenize.py

示例14: test_socket_server

    def test_socket_server(self):
        # run socketserver with a small amount of memory; verify it exits cleanly

        
        rc = subprocess.call([sys.executable,
                   "-J-Xmx32m",
                   test_support.findfile("socketserver_test.py")])
        # stdout=PIPE)
        self.assertEquals(rc, 0)
开发者ID:Alex-CS,项目名称:sonify,代码行数:9,代码来源:test_threading_jy.py

示例15: test_wait_when_sigchild_ignored

 def test_wait_when_sigchild_ignored(self):
     # NOTE: sigchild_ignore.py may not be an effective test on all OSes.
     sigchild_ignore = test_support.findfile("sigchild_ignore.py",
                                             subdir="subprocessdata")
     p = subprocess.Popen([sys.executable, sigchild_ignore],
                          stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     stdout, stderr = p.communicate()
     self.assertEqual(0, p.returncode, "sigchild_ignore.py exited"
                      " non-zero with this error:\n%s" % stderr)
开发者ID:Arcenciel,项目名称:DDReader,代码行数:9,代码来源:test_subprocess.py


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