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

Python unittest.expectedFailure函数代码示例

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

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



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

示例1: test_05_03_http_image_zipfile

    def test_05_03_http_image_zipfile(self):
        # Make a zipfile using files accessed from the web
        def alter_fn(module):
            self.assertTrue(isinstance(module, C.CreateWebPage))
            module.wants_zip_file.value = True
            module.zipfile_name.value = ZIPFILE_NAME
            module.directory_choice.dir_choice = C.ABSOLUTE_FOLDER_NAME
            module.directory_choice.custom_path = cpprefs.get_default_image_directory()

        url_root = "http://cellprofiler.org/svnmirror/ExampleImages/ExampleSBSImages/"
        url_query = "?r=11710"
        filenames = [(url_root, fn + url_query) for fn in
                     ("Channel1-01-A-01.tif", "Channel2-01-A-01.tif",
                      "Channel1-02-A-02.tif", "Channel2-02-A-02.tif")]
        #
        # Make sure URLs are accessible
        #
        try:
            for filename in filenames:
                URLopener().open("".join(filename)).close()
        except IOError, e:
            def bad_url(e=e):
                raise e

            unittest.expectedFailure(bad_url)()
开发者ID:0x00B1,项目名称:CellProfiler,代码行数:25,代码来源:test_createwebpage.py


示例2: test_put_file_twice_no_tic

  def test_put_file_twice_no_tic(self):
    self.postFile()
    self.commit()
    self.postFile()
    self.tic()

    document_list = self.portal.portal_catalog(reference=self.key)

    self.assertEqual(2, len(document_list))
    expectedFailure(self.assertEqual)(sorted(['archived', 'published']),
        sorted(q.getValidationState() for q in document_list))
开发者ID:Verde1705,项目名称:erp5,代码行数:11,代码来源:test.erp5.testShaCache.py


示例3: test_load_using_bioformats_url

def test_load_using_bioformats_url():
    url = "https://github.com/CellProfiler/python-bioformats/raw/1.0.5/bioformats/tests/Channel1-01-A-01.tif"
    try:
        fd = future.moves.urllib.request.urlopen(url)
        if fd.code < 200 or fd.code >= 300:
            raise OSError("Http error %d" % fd.code)
    except OSError as e:
        def bad_url(e=e):
            raise e
        unittest.expectedFailure(bad_url)()

    data = bioformats.formatreader.load_using_bioformats_url(url, rescale=False)
    assert data.shape == (640, 640)
开发者ID:CellProfiler,项目名称:python-bioformats,代码行数:13,代码来源:test_formatreader.py


示例4: test_03_03_load_using_bioformats_url

 def test_03_03_load_using_bioformats_url(self):
     url = "https://github.com/CellProfiler/python-bioformats/raw/1.0.5/bioformats/tests/Channel1-01-A-01.tif"
     try:
         fd = urlopen(url)
         if fd.code < 200 or fd.code >= 300:
             raise OSError("Http error %d" % fd.code)
     except OSError as e:
         def bad_url(e=e):
             raise e
         unittest.expectedFailure(bad_url)()
     
     data = F.load_using_bioformats_url(url, rescale=False)
     self.assertSequenceEqual(data.shape, (640, 640))
开发者ID:AnneCarpenter,项目名称:python-bioformats,代码行数:13,代码来源:test_formatreader.py


示例5: test_01_05_load_pipeline

 def test_01_05_load_pipeline(self):
     import cellprofiler.pipeline as cpp
     import os
     def callback(caller, event):
         self.assertFalse(isinstance(event, cpp.LoadExceptionEvent))
     pipeline = cpp.Pipeline()
     pipeline.add_listener(callback)
     try:
         fd = urlopen(self.fly_url)
     except IOError, e:
         def bad_url(e=e):
             raise e
         unittest.expectedFailure(bad_url)()
开发者ID:thesarahmeister,项目名称:CellProfiler,代码行数:13,代码来源:test_nowx.py


示例6: test_02_01_run_headless

    def test_02_01_run_headless(self):
        output_directory = tempfile.mkdtemp()
        temp_directory = os.path.join(output_directory, "temp")
        os.mkdir(temp_directory)
        try:
            #
            # Run with a .cp file
            #
            fly_pipe = "http://cellprofiler.org/ExampleFlyImages/ExampleFlyURL.cppipe"
            urllib.URLopener().open(fly_pipe).close()
            measurements_file = os.path.join(output_directory, "Measurements.h5")
            done_file = os.path.join(output_directory, "Done.txt")
            self.run_cellprofiler(
                "-c",
                "-r",
                "-o",
                output_directory,
                "-p",
                fly_pipe,
                "-d",
                done_file,
                "-t",
                temp_directory,
                "-f",
                "1",
                "-l",
                "1",
                measurements_file,
            )
            import cellprofiler.preferences as cpprefs

            self.assertTrue(os.path.exists(measurements_file))
            self.assertTrue(os.path.exists(done_file))
            #
            # Re-run using the measurements file.
            #
            m2_file = os.path.join(output_directory, "M2.h5")
            self.run_cellprofiler(
                "-c", "-r", "-o", output_directory, "-f", "1", "-l", "1", "-p", measurements_file, m2_file
            )
            self.assertTrue(os.path.exists(m2_file))
        except IOError, e:
            if e.args[0] != "http error":
                raise e

            def bad_url(e=e):
                raise e

            unittest.expectedFailure(bad_url)()
开发者ID:shntnu,项目名称:CellProfiler,代码行数:49,代码来源:test_cellprofiler.py


示例7: test_ResourceTags

    def test_ResourceTags(self):
        # Host tags might not be present when using a v2 service
        if self.is_v2:
            return unittest.expectedFailure(self)

        topo = Topology()
        h1 = topo.source(host_name)
        h1.resource_tags.add('host1')
        
        h2 = topo.source(host_name)
        h2.resource_tags.add('host2')
        
        h = h1.union({h2})
        h.print()
        h = h.map(RemoveDup())

        h2sink = h2.for_each(lambda x : None, name='SinkOnHost1')
        h2sink.resource_tags.add('host1')

        beacon = Source(topo, "spl.utility::Beacon",
            'tuple<uint64 seq>',
            params = {'period': 0.02, 'iterations':100},
            name = 'BeaconOnHost1')
        beacon.seq = beacon.output('IterationCount()')
        beacon.resource_tags.add('host2')

        h2sinkNotags = h2.for_each(lambda x : None, name='SinkNoTags')
        self.assertFalse(h2sinkNotags.resource_tags)
        
        self.tester = Tester(topo)
        self.tester.tuple_count(h, 2)
        self.tester.local_check = self.check_placements
     
        sr = self.tester.test(self.test_ctxtype, self.test_config)
开发者ID:vdogaru,项目名称:streamsx.topology,代码行数:34,代码来源:test2_placement.py


示例8: create_test

def create_test(input_file, output_file, thing):
    first_line = open(input_file, 'r').readline()
    def do_test(self):
        self.check_file(input_file, output_file, thing)
    if first_line.startswith('dnl fail') and thing == 'parser':
        return unittest.expectedFailure(do_test)
    return do_test
开发者ID:luser,项目名称:pym4,代码行数:7,代码来源:runtests.py


示例9: main

def main():
    test_cases = list_delegation_tests(FIXTURE_ROOT)
    
    # Generate the 'constraint-solving-without-injection' tests.
    # These replace the TargetSolverNoInjection tests we used to have in test.py.
    constraint_solved_tests = {
            "eq": {
                #"Concolic::Solver::ErrorsReadingSolution": "0",    # Error by default, don't neet to test explicitly.
                #"Concolic::Solver::ConstraintsSolvedAsUNSAT": "0", # Error by default, don't neet to test explicitly.
                #"Concolic::Solver::ConstraintsNotSolved": "0",     # Error by default, don't neet to test explicitly.
                "Concolic::Solver::ConstraintsSolved": "1"
            }
        }
    
    for t in test_cases:
        test_name = 'test_constraint-solving-without-injection_%s' % t['name']
        file_name = "%s%s" % (FIXTURE_ROOT, t['fn'])
        test = concolic.test_generator(_artemis_runner_no_injections, file_name, test_name, test_dict=constraint_solved_tests, internal_test=None)
        setattr(EventDelegation, test_name, test)
    
    # Generate the tests which check for the assertions included in the test suite.
    for t in test_cases:
        test_name = 'test_%s' % t['name']
        file_name = "%s%s" % (FIXTURE_ROOT, t['fn'])
        
        test = concolic.test_generator(_artemis_runner_full, file_name, test_name, test_dict=t['test'], internal_test=t['i_test'])
        
        if t['expected_failure']:
            test = unittest.expectedFailure(test)
        
        setattr(EventDelegation, test_name, test)
    
    unittest.main(buffer=True, catchbreak=True)
开发者ID:sukwon0709,项目名称:Artemis,代码行数:33,代码来源:delegation.py


示例10: mark_tests_as_expected_failure

def mark_tests_as_expected_failure(failing_tests):
    """
    Flag tests as expectedFailure. This should only run during the
    testsuite.
    """
    django_version = django.VERSION[:2]
    for test_name, versions in six.iteritems(failing_tests):
        if not versions or not isinstance(versions, (list, tuple)):
            # skip None, empty, or invalid
            continue
        if not isinstance(versions[0], (list, tuple)):
            # Ensure list of versions
            versions = [versions]
        if all(map(lambda v: v[:2] != django_version, versions)):
            continue
        test_case_name, _, method_name = test_name.rpartition('.')
        try:
            test_case = import_string(test_case_name)
        except ImproperlyConfigured:
            # Django tests might not be available during
            # testing of client code
            continue
        method = getattr(test_case, method_name)
        method = expectedFailure(method)
        setattr(test_case, method_name, method)
开发者ID:bradleyy,项目名称:django-sqlserver,代码行数:25,代码来源:runtests.py


示例11: f

 def f(func):
     rc = subprocess.call(['ip', 'link', 'add', 'dev', 'erspan99', 'type', 'erspan', 'seq', 'key', '30', 'local', '192.168.1.4', 'remote', '192.168.1.1', 'erspan_ver', '1', 'erspan', '123'])
     if rc == 0:
         subprocess.call(['ip', 'link', 'del', 'erspan99'])
         return func
     else:
         return unittest.expectedFailure(func)
开发者ID:fsateler,项目名称:systemd,代码行数:7,代码来源:systemd-networkd-tests.py


示例12: maybe_download_tesst_image

def maybe_download_tesst_image( file_name):
    '''Download the given TestImages file if not in the directory

    file_name - name of file to fetch

    Image will be downloaded if not present to CP_EXAMPLEIMAGES directory.
    '''
    local_path = os.path.join(testimages_directory(), file_name)
    if not os.path.exists(local_path):
        url = testimages_url() + "/" + file_name
        try:
            URLopener().retrieve(url, local_path)
        except IOError, e:
            # This raises the "expected failure" exception.
            def bad_url(e=e):
                raise e
            unittest.expectedFailure(bad_url)()
开发者ID:thesarahmeister,项目名称:CellProfiler,代码行数:17,代码来源:__init__.py


示例13: implements

def implements(commands, expectedFailure=False):  # noqa: N803
    def _test(self):
        with self.run_bpd() as client:
            response = client.send_command('commands')
        self._assert_ok(response)
        implemented = response.data['command']
        self.assertEqual(commands.intersection(implemented), commands)
    return unittest.expectedFailure(_test) if expectedFailure else _test
开发者ID:beetbox,项目名称:beets,代码行数:8,代码来源:test_player.py


示例14: _addTests

def _addTests():
    for path in glob.glob(os.path.join(drawBotScriptDir, "*.py")):
        scriptName = os.path.splitext(os.path.basename(path))[0]
        for ext in testExt:
            testMethodName = "test_%s_%s" % (ext, scriptName)
            testMethod = makeTestCase(path, ext, testMethodName in ignoreDeprecationWarnings)
            testMethod.__name__ = testMethodName
            if testMethodName in expectedFailures:
                testMethod = unittest.expectedFailure(testMethod)
            setattr(DrawBotTest, testMethodName, testMethod)
开发者ID:typemytype,项目名称:drawbot,代码行数:10,代码来源:testScripts.py


示例15: cxOracle_py3_bug

def cxOracle_py3_bug(func):
    """
    There's a bug in Django/cx_Oracle with respect to string handling under
    Python 3 (essentially, they treat Python 3 strings as Python 2 strings
    rather than unicode). This makes some tests here fail under Python 3, so
    we mark them as expected failures until someone fixes them in #23843.
    """
    from unittest import expectedFailure
    from django.db import connection
    return expectedFailure(func) if connection.vendor == 'oracle' else func
开发者ID:LouisAmon,项目名称:django,代码行数:10,代码来源:tests.py


示例16: expectedFailureIfAppengine

def expectedFailureIfAppengine(func):
    try:
        from google import appengine
    except ImportError:
        return func
    else:
        import os

        if os.environ.get('SERVER_SOFTWARE', None) is None:
            return func

        return unittest.expectedFailure(func)
开发者ID:meemeer,项目名称:kayframework-pyamf,代码行数:12,代码来源:util.py


示例17: cxOracle_513_py3_bug

def cxOracle_513_py3_bug(func):
    """
    cx_Oracle versions up to and including 5.1.3 have a bug with respect to
    string handling under Python3 (essentially, they treat Python3 strings
    as Python2 strings rather than unicode). This makes some tests here
    fail under Python 3 -- so we mark them as expected failures.

    See  https://code.djangoproject.com/ticket/23843, in particular comment 6,
    which points to https://bitbucket.org/anthony_tuininga/cx_oracle/issue/6/
    """
    from unittest import expectedFailure
    from django.db import connection

    if connection.vendor == 'oracle' and six.PY3 and connection.Database.version <= '5.1.3':
        return expectedFailure(func)
    else:
        return func
开发者ID:IanLee1521,项目名称:django,代码行数:17,代码来源:tests.py


示例18: _addExampleTests

def _addExampleTests():
    allExamples = _collectExamples([
        DrawBotDrawingTool,
        DrawBotDrawingTool._formattedStringClass,
        DrawBotDrawingTool._bezierPathClass,
        DrawBotDrawingTool._imageClass
    ])

    for exampleName, source in allExamples.items():
        testMethodName = "test_%s" % exampleName
        testMethod = _makeTestCase(exampleName, source, doSaveImage=testMethodName not in dontSaveImage,
                allowFuzzyImageComparison=testMethodName in allowFuzzyImageComparison)
        testMethod.__name__ = testMethodName
        if testMethodName in skip:
            continue
        if testMethodName in expectedFailures:
            testMethod = unittest.expectedFailure(testMethod)
        setattr(ExampleTester, testMethodName, testMethod)
开发者ID:typemytype,项目名称:drawbot,代码行数:18,代码来源:testExamples.py


示例19: catalog

  def catalog(self, reference_tree, kw, check_search_text=True,
      check_select_expression=True, expected_failure=False):
    reference_param_dict = self._catalog._queryResults(query_table='foo', **kw)
    query = self._catalog.buildQuery(kw)
    assertEqual = self.assertEqual
    if expected_failure:
      assertEqual = unittest.expectedFailure(assertEqual)

    assertEqual(reference_tree, query)
    search_text = query.asSearchTextExpression(self._catalog)
    if check_search_text:
      # XXX: sould "keyword" be always used for search text searches ?
      search_text_param_dict = self._catalog._queryResults(query_table='foo', keyword=search_text)
      if not check_select_expression:
        search_text_param_dict.pop('select_expression')
        reference_param_dict.pop('select_expression')
      assertEqual(reference_param_dict, search_text_param_dict,
          'Query: %r\nSearchText: %r\nReference: %r\nSecond rendering: %r' % \
                       (query, search_text, reference_param_dict, search_text_param_dict))
开发者ID:alvsgithub,项目名称:erp5,代码行数:19,代码来源:testSQLCatalog.py


示例20: expected_failure_if_suit

def expected_failure_if_suit(func):
    if 'suit' in settings.INSTALLED_APPS:
        return unittest.expectedFailure(func)
    return func
开发者ID:theatlantic,项目名称:django-nested-admin,代码行数:4,代码来源:base.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python unittest.findTestCases函数代码示例发布时间:2022-05-27
下一篇:
Python utils.set_module_args函数代码示例发布时间: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