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


Python unittest.skipIf函数代码示例

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


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


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