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

Python unittest.skipIf函数代码示例

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

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



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

示例1: test_program_btldr

  def test_program_btldr(self):
    """ Test programming the bootloader once its sector is locked. """
    unittest.skipIf(self.skip_single, 'Skipping single Piksi tests')

    SECTOR = 0
    ADDRESS = 0x08003FFF

    if self.verbose: print "--- test_program_btldr ---"

    with serial_link.get_driver(use_ftdi=False, port=self.port1) as driver:
      with Handler(driver.read, driver.write) as handler:

        with Bootloader(handler) as piksi_bootloader:
          with Timeout(TIMEOUT_BOOT) as timeout:
            if self.verbose: print "Waiting for bootloader handshake"
            piksi_bootloader.handshake()
          with Flash(handler, flash_type='STM',
                     sbp_version=piksi_bootloader.sbp_version) as piksi_flash:
            # Make sure the bootloader sector is locked.
            with Timeout(TIMEOUT_LOCK_SECTOR) as timeout:
              if self.verbose: print "Locking STM sector:", SECTOR
              piksi_flash.lock_sector(SECTOR)
            # Make sure the address to test isn't already programmed.
            with Timeout(TIMEOUT_READ_STM) as timeout:
              byte_read = piksi_flash.read(ADDRESS, 1, block=True)
            self.assertEqual('\xFF', byte_read,
                             "Address to program is already programmed")
            # Attempt to write 0x00 to last address of the sector.
            if self.verbose: print "Attempting to lock STM sector:", SECTOR
            piksi_flash.program(0x08003FFF, '\x00')
            with Timeout(TIMEOUT_READ_STM) as timeout:
              byte_read = piksi_flash.read(0x08003FFF, 1, block=True)
            self.assertEqual('\xFF', byte_read,
                             "Bootloader sector was programmed")
开发者ID:asthakeshan,项目名称:piksi_tools,代码行数:34,代码来源:test_bootloader.py


示例2: test_get_versions

  def test_get_versions(self):
    """ Get Piksi bootloader/firmware/NAP version from device. """
    unittest.skipIf(self.skip_single, 'Skipping single Piksi tests')

    if self.verbose: print "--- test_get_versions ---"

    with serial_link.get_driver(use_ftdi=False, port=self.port1) as driver:
      with Handler(driver.read, driver.write) as handler:

        with Bootloader(handler) as piksi_bootloader:

          # Get bootloader version, print, and jump to application firmware.
          with Timeout(TIMEOUT_BOOT) as timeout:
            if self.verbose: print "Waiting for bootloader handshake"
            piksi_bootloader.handshake()
          piksi_bootloader.jump_to_app()
          print "Piksi Bootloader Version:", piksi_bootloader.version

        # Wait for heartbeat, get settings, print firmware/NAP versions.
        heartbeat = Heartbeat()
        handler.add_callback(heartbeat, SBP_MSG_HEARTBEAT)
        if self.verbose: print "Waiting to receive heartbeat"
        while not heartbeat.received:
          time.sleep(0.1)
        if self.verbose: print "Received hearbeat"
        handler.remove_callback(heartbeat, SBP_MSG_HEARTBEAT)

        if self.verbose: print "Getting Piksi settings"
        settings = self.get_piksi_settings(handler)

        if self.verbose: print "Piksi Firmware Version:", \
                          settings['system_info']['firmware_version']

        if self.verbose: print "Piksi NAP Version:", \
                          settings['system_info']['nap_version']
开发者ID:asthakeshan,项目名称:piksi_tools,代码行数:35,代码来源:test_bootloader.py


示例3: test_jump_to_app

  def test_jump_to_app(self):
    """ Test that we can jump to the application after programming. """
    unittest.skipIf(self.skip_single, 'Skipping single Piksi tests')

    if self.verbose: print "--- test_jump_to_app ---"

    with serial_link.get_driver(use_ftdi=False, port=self.port1) as driver:
      with Handler(driver.read, driver.write) as handler:

        with Bootloader(handler) as piksi_bootloader:
          if self.verbose: print "Handshaking with bootloader"
          piksi_bootloader.handshake()
          if self.verbose: print "Jumping to application"
          piksi_bootloader.jump_to_app()

        # If we succesfully jump to the application, we should receive
        # Heartbeat messages.
        with Timeout(TIMEOUT_BOOT) as timeout:

          heartbeat = Heartbeat()
          handler.add_callback(heartbeat, SBP_MSG_HEARTBEAT)

          if self.verbose: print "Waiting to receive heartbeat"
          while not heartbeat.received:
            time.sleep(0.1)
          if self.verbose: print "Received hearbeat"

          handler.remove_callback(heartbeat, SBP_MSG_HEARTBEAT)
开发者ID:asthakeshan,项目名称:piksi_tools,代码行数:28,代码来源:test_bootloader.py


示例4: test_erase_btldr

  def test_erase_btldr(self):
    """ Test erasing the bootloader once its sector is locked. """
    unittest.skipIf(self.skip_single, 'Skipping single Piksi tests')

    SECTOR = 0

    if self.verbose: print "--- test_erase_btldr ---"

    with serial_link.get_driver(use_ftdi=False, port=self.port1) as driver:
      with Handler(driver.read, driver.write) as handler:

        with Bootloader(handler) as piksi_bootloader:
          with Timeout(TIMEOUT_BOOT) as timeout:
            if self.verbose: print "Waiting for bootloader handshake"
            piksi_bootloader.handshake()
          with Flash(handler, flash_type='STM',
                     sbp_version=piksi_bootloader.sbp_version) as piksi_flash:
            # Make sure the bootloader sector is locked.
            with Timeout(TIMEOUT_LOCK_SECTOR) as timeout:
              if self.verbose: print "Locking STM sector:", SECTOR
              piksi_flash.lock_sector(SECTOR)
            # Attempt to erase the sector.
            with Timeout(TIMEOUT_ERASE_SECTOR) as timeout:
              if self.verbose: print "Attempting to erase STM sector:", SECTOR
              piksi_flash.erase_sector(SECTOR, warn=False)
            # If the sector was successfully erased, we should timeout here
            # as the bootloader will stop sending handshakes.
            with Timeout(TIMEOUT_BOOT) as timeout:
              if self.verbose: print "Waiting for bootloader handshake"
              piksi_bootloader.handshake()
开发者ID:asthakeshan,项目名称:piksi_tools,代码行数:30,代码来源:test_bootloader.py


示例5: test_flashing_wrong_sender_id

  def test_flashing_wrong_sender_id(self):
    """ Test flashing using an incorrect sender ID (should fail). """
    unittest.skipIf(self.skip_single, 'Skipping single Piksi tests')

    SECTOR = 1
    SENDER_ID = 0x41

    if self.verbose: print "--- test_flashing_wrong_sender_id ---"

    with serial_link.get_driver(use_ftdi=False, port=self.port1) as driver:
      with Handler(driver.read, driver.write) as handler:

        # Verify that flash erase times out when using incorrect sender ID.
        with Bootloader(handler) as piksi_bootloader:
          with Timeout(TIMEOUT_BOOT) as timeout:
            print "Handshaking with bootloader"
            piksi_bootloader.handshake()
          with Flash(handler, flash_type='STM',
                     sbp_version=piksi_bootloader.sbp_version) as piksi_flash:
            try:
              with Timeout(TIMEOUT_ERASE_SECTOR) as timeout:
                if self.verbose: print "Attempting to erase sector with incorrect sender ID"
                msg_buf = struct.pack("BB", piksi_flash.flash_type_byte, SECTOR)
                handler.send(SBP_MSG_FLASH_ERASE, msg_buf, sender=SENDER_ID)
                handler.wait(SBP_MSG_FLASH_DONE, TIMEOUT_ERASE_SECTOR+1)
                raise Exception("Should have timed out but didn't")
            except TimeoutError:
              if self.verbose: print "Timed out as expected"
开发者ID:asthakeshan,项目名称:piksi_tools,代码行数:28,代码来源:test_bootloader.py


示例6: test_two_piksies_btldr_mode

 def test_two_piksies_btldr_mode(self):
   """
   Test if two Piksies can set eachother into bootloader mode (should fail).
   """
   unittest.skipIf(self.skip_double, 'Skipping double Piksi tests')
   if self.port2 is None:
     return
开发者ID:asthakeshan,项目名称:piksi_tools,代码行数:7,代码来源:test_bootloader.py


示例7: test_likes

	def test_likes(self):
		for i in range(10):
			x = map(str, list(range(i)))

			shuffle(x)

			self.assertEqual(aula2.likes(x), gabarito_aula2.likes(x)

	@unittest.skipIf('remove_duplicates' not in vars(aula2),
					 'Função "remove_duplicates" não foi encontrada')
	def test_remove_duplicates(self):
		for _ in range(40):
			t = [randint(0,5) for _ in range(randint(0, 30))]

			self.assertEqual(aula2.remove_duplicates(t), remove_duplicates(t))

	@unittest.skipIf('different_evenness' not in vars(aula2),
					 'Função "different_evenness" não foi encontrada')
	def test_different_evenness(self):
		for _ in range(40):
		    testlen=randint(3,50)
		    oddeven=randint(0,1)
		    testmat=[randint(0,25)*2+oddeven for x in range(testlen)]
		    solution=randint(1,testlen)
		    testmat[solution-1]+=1
		    testmat=(" ").join(map(str,testmat))
		    self.assertEqual(different_evenness(testmat), solution)

if __name__ == '__main__':
	unittest.main(verbosity=2)
开发者ID:CalicoUFSC,项目名称:minicurso-python,代码行数:30,代码来源:tests_aula2.py


示例8: test_flash_stm_firmware

  def test_flash_stm_firmware(self):
    """ Test flashing STM hexfile. """
    unittest.skipIf(self.skip_single, 'Skipping single Piksi tests')

    if self.verbose: print "--- test_flash_stm_firmware ---"

    with serial_link.get_driver(use_ftdi=False, port=self.port1) as driver:
      with Handler(driver.read, driver.write) as handler:

        # Wait until we receive a heartbeat or bootloader handshake so we
        # know what state Piksi is in.
        with Bootloader(handler) as piksi_bootloader:

          with Timeout(TIMEOUT_BOOT) as timeout:
            if self.verbose: print "Waiting for bootloader handshake"
            piksi_bootloader.handshake()
            if self.verbose: print "Received bootloader handshake"

          with Flash(handler, flash_type="STM",
                     sbp_version=piksi_bootloader.sbp_version) as piksi_flash:
            # Erase entire STM flash (except bootloader).
            if self.verbose: print "Erasing STM"
            with Timeout(TIMEOUT_ERASE_STM) as timeout:
              for s in range(1,12):
                piksi_flash.erase_sector(s)
            # Write STM firmware.
            with Timeout(TIMEOUT_PROGRAM_STM) as timeout:
              if self.verbose:
                if self.verbose: print "Programming STM"
                piksi_flash.write_ihx(self.stm_fw, sys.stdout, 0x10, erase=False)
              else:
                piksi_flash.write_ihx(self.stm_fw, erase=False)
开发者ID:asthakeshan,项目名称:piksi_tools,代码行数:32,代码来源:test_bootloader.py


示例9: test_insertion_success

    def test_insertion_success(self):
        params = {}
        params['server'] = 'mobiledata.bigdatacorp.com.br'
        params['port'] = '21766'
        params['database'] = 'MobileAppsData'
        params['username'] = 'GitHubCrawlerUser'
        params['password'] = 'g22LrJvULU5B'
        params['seed_collection'] = 'Python_test'
        params['auth_database'] = 'MobileAppsData'
        params['write_concern'] = True

        mongo_uri = MongoDBWrapper.build_mongo_uri(**params)

        mongo_wrapper = MongoDBWrapper()

        is_connected = mongo_wrapper.connect(mongo_uri, params['database'],
                                             params['seed_collection'])

        unittest.skipIf(is_connected is False,
                     'Connection failed, insertion cancelled.')

        if is_connected:
            mongo_wrapper.insert_on_queue(self._test_app_url)

            # Find it on Mongo
            query = {'_id': self._test_app_url}
            self.assertTrue(mongo_wrapper._collection.find_one(query),
                            'Insert did not work.')

        else:
            self.fail('Connection problem, verify connection before insert.')
开发者ID:BrunoWired,项目名称:GooglePlayAppsCrawler.py,代码行数:31,代码来源:UT_MongoWrapper.py


示例10: test_uart_rx_buffer_overflow

 def test_uart_rx_buffer_overflow(self):
   """
   Test if queuing too many operations causes a UART RX buffer overflow when
   another Piksi is sending data via another UART (should fail).
   """
   unittest.skipIf(self.skip_double, 'Skipping double Piksi tests')
   if self.port2 is None:
     return
开发者ID:asthakeshan,项目名称:piksi_tools,代码行数:8,代码来源:test_bootloader.py


示例11: skip_unless_any_pythons_present

def skip_unless_any_pythons_present(*versions):
  """A decorator that only runs the decorated test method if any of the specified pythons are present.

  :param string *versions: Python version strings, such as 2.7, 3.
  """
  if any(v for v in versions if has_python_version(v)):
    return skipIf(False, 'At least one of the expected python versions found.')
  return skipIf(True, 'Could not find at least one of the required pythons from {} on the system. Skipping.'.format(versions))
开发者ID:cosmicexplorer,项目名称:pants,代码行数:8,代码来源:interpreter_selection_utils.py


示例12: skip_unless_all_pythons_present

def skip_unless_all_pythons_present(*versions):
  """A decorator that only runs the decorated test method if all of the specified pythons are present.

  :param string *versions: Python version strings, such as 2.7, 3.
  """
  missing_versions = [v for v in versions if not has_python_version(v)]
  if len(missing_versions) == 1:
    return skipIf(True, 'Could not find python {} on system. Skipping.'.format(missing_versions[0]))
  elif len(missing_versions) > 1:
    return skipIf(True,
                  'Skipping due to the following missing required pythons: {}'
                  .format(', '.join(missing_versions)))
  else:
    return skipIf(False, 'All required pythons present, continuing with test!')
开发者ID:cosmicexplorer,项目名称:pants,代码行数:14,代码来源:interpreter_selection_utils.py


示例13: with_requires

def with_requires(*requirements):
    """Run a test case only when given requirements are satisfied.

    .. admonition:: Example

       This test case runs only when `numpy>=1.10` is installed.

       >>> from cupy import testing
       ... class Test(unittest.TestCase):
       ...     @testing.with_requires('numpy>=1.10')
       ...     def test_for_numpy_1_10(self):
       ...         pass

    Args:
        requirements: A list of string representing requirement condition to
            run a given test case.

    """
    ws = pkg_resources.WorkingSet()
    try:
        ws.require(*requirements)
        skip = False
    except pkg_resources.VersionConflict:
        skip = True

    msg = 'requires: {}'.format(','.join(requirements))
    return unittest.skipIf(skip, msg)
开发者ID:bittnt,项目名称:chainer,代码行数:27,代码来源:helper.py


示例14: skip_if_windows

def skip_if_windows(cls):
    """Skip a test if run on windows"""
    decorator = unittest.skipIf(
        platform.system() == 'Windows',
        "Not supported on Windows",
    )
    return decorator(cls)
开发者ID:dvarrazzo,项目名称:psycopg,代码行数:7,代码来源:testutils.py


示例15: skip_from_python_

 def skip_from_python_(cls):
     decorator = unittest.skipIf(
         sys.version_info[:len(ver)] >= ver,
         "skipped because Python %s"
         % ".".join(map(str, sys.version_info[:len(ver)])),
     )
     return decorator(cls)
开发者ID:dvarrazzo,项目名称:psycopg,代码行数:7,代码来源:testutils.py


示例16: when_geolocation_data_available

def when_geolocation_data_available(function):
    config = get_test_config()
    geolocation_data = config.get('geolocation_data')
    geolocation_data_available = bool(geolocation_data) and os.path.isfile(geolocation_data)
    return unittest.skipIf(
        not geolocation_data_available, 'Geolocation data is not available'
    )(function)
开发者ID:aptro,项目名称:edx-analytics-pipeline,代码行数:7,代码来源:__init__.py


示例17: skip_before_libpq_

 def skip_before_libpq_(cls):
     v = libpq_version()
     decorator = unittest.skipIf(
         v < int("%d%02d%02d" % ver),
         "skipped because libpq %d" % v,
     )
     return decorator(cls)
开发者ID:dvarrazzo,项目名称:psycopg,代码行数:7,代码来源:testutils.py


示例18: skipIfPy3

def skipIfPy3(message):
    ''' unittest decorator to skip a test for Python 3

    '''
    from unittest import skipIf
    from .platform import is_py3
    return skipIf(is_py3(), message)
开发者ID:bgyarfas,项目名称:bokeh,代码行数:7,代码来源:testing.py


示例19: _add_test_methods

    def _add_test_methods(mcs, attrs, urlpatterns):
        # loop through every URL pattern
        for index, (func, regex, url_name) in enumerate(extract_views_from_urlpatterns(urlpatterns)):

            if func.__module__.startswith("%s." % attrs["module"]):
                pass
            elif func.__module__ == attrs["module"]:
                pass
            else:
                continue

            if hasattr(func, "__name__"):
                func_name = func.__name__
            elif hasattr(func, "__class__"):
                func_name = "%s()" % func.__class__.__name__
            else:
                func_name = re.sub(r" at 0x[0-9a-f]+", "", repr(func))

            url_pattern = smart_text(simplify_regex(regex))
            name = "_".join(
                ["test", func.__module__.replace(".", "_"), slugify("%s" % func_name)]
                + slugify(url_pattern.replace("/", "_") or "root").replace("_", " ").split()
            )
            url = url_pattern

            for key, value in attrs["variables"].items():
                url = url.replace("<%s>" % key, value)

            # bail out if we don't know how to visit this URL properly
            testfunc = unittest.skipIf(
                any(re.search(stop_pattern, url) for stop_pattern in [r"<.*>"]),
                "URL pattern %r contains stop pattern." % url,
            )(make_test_get_function(name, url, url_pattern))

            attrs[name] = testfunc
开发者ID:chrissamuel,项目名称:karaage,代码行数:35,代码来源:client.py


示例20: skipIfPyPy

def skipIfPyPy(message):
    """ unittest decoractor to skip a test for PyPy

    """
    from unittest import skipIf
    from .platform import is_pypy
    return skipIf(is_pypy(), message)
开发者ID:Wombatpm,项目名称:bokeh,代码行数:7,代码来源:testing.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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