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


Python Device.close方法代码示例

本文整理汇总了Python中device.Device.close方法的典型用法代码示例。如果您正苦于以下问题:Python Device.close方法的具体用法?Python Device.close怎么用?Python Device.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在device.Device的用法示例。


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

示例1: DeviceTest

# 需要导入模块: from device import Device [as 别名]
# 或者: from device.Device import close [as 别名]
class DeviceTest(unittest.TestCase):
    def setUp(self):
        self.block_size = 1
        self.blocks = 100
        self.dev = Device("data", self.block_size, self.blocks)
        self.data = [randrange(0, 256) for i in range(0, self.blocks)]
        for i, block in enumerate(self.data):
            self.dev.write_block(i, chr(block))

    def test_memory_read(self):
        self.should_preserve_data(self.dev)

    def test_file_read(self):
        self.dev.close()
        dev = Device("data", self.block_size, self.blocks)
        self.should_preserve_data(dev)

    def should_preserve_data(self, dev):
        for i, block in enumerate(self.data):
            read = dev.read_block(i)
            self.assertEqual(read, chr(block))

    @unittest.expectedFailure
    def test_fail_to_write_data_bigger_than_block(self):
        self.dev.write_block(0, b'aa')

    @unittest.expectedFailure
    def test_fail_with_out_of_bounds(self):
        self.dev.write_block(self.blocks + 1, b'a')

    def tearDown(self):
        self.dev.close()
开发者ID:rtshadow,项目名称:miscs,代码行数:34,代码来源:device_test.py

示例2: TC_ZC_FUNC

# 需要导入模块: from device import Device [as 别名]
# 或者: from device.Device import close [as 别名]
class TC_ZC_FUNC(unittest.TestCase):
    @classmethod
    def setUpClass(self):
        self.dev = Device(TEST_DEVICE)
        self.mGS = GSMonitor(self.dev)
        self.mCfg = ConfigManager(self.dev)

    @classmethod
    def tearDownClass(self):
        self.mCfg.close()
        self.mGS.close()
        self.dev.close()

    def test_zc_generating(self):
        self.assertEqual(self.dev.isFSRunning(), True, "Fusion Sensor is not running.")
        self.mCfg.setZoneCountMode()
        time.sleep(5*60)
        self.assertTrue(self.dev.isNewDataOnDevice("zone-count") or self.mGS.isNewZoneCountUploaded(),
                    "Failed to find new zone-count data"
                )
        print("ZoneCount generating is approved")
开发者ID:hufengping,项目名称:percolata,代码行数:23,代码来源:tc_zc_func.py

示例3: TC_LOI_FUNC

# 需要导入模块: from device import Device [as 别名]
# 或者: from device.Device import close [as 别名]
class TC_LOI_FUNC(unittest.TestCase):
    @classmethod
    def setUpClass(self):
        self.dev = Device(TEST_DEVICE)
        self.mGS = GSMonitor(self.dev)
        self.mCfg = ConfigManager(self.dev)

    @classmethod
    def tearDownClass(self):
        self.mCfg.close()
        self.mGS.close()
        self.dev.close()

    def test_loi_generating(self):
        self.assertEqual(self.dev.isFSRunning(), True, "Fusion Sensor is not running.")
        self.mCfg.setLoiMode()
        time.sleep(8*60)
        self.assertTrue(self.dev.isNewDataOnDevice("loi") or self.mGS.isNewLoiUploaded(),
                    "Failed to find new loi data"
                )
        print("Loi generating is approved")
开发者ID:hufengping,项目名称:percolata,代码行数:23,代码来源:tc_loi_func.py

示例4: TC_AUDIO_FUNC_001

# 需要导入模块: from device import Device [as 别名]
# 或者: from device.Device import close [as 别名]
class TC_AUDIO_FUNC_001(unittest.TestCase):
    @classmethod
    def setUpClass(self):
        self.dev = Device(TEST_DEVICE)
        self.mGS = GSMonitor(self.dev)
        self.mCfg = ConfigManager(self.dev)

    @classmethod
    def tearDownClass(self):
        self.mCfg.close()
        self.mGS.close()
        self.dev.close()

    def test_audio_generating(self):
        self.assertEqual(self.dev.isFSRunning(), True, "Fusion Sensor is not running.")
        self.mCfg.setTrackingMode()
        self.mCfg.setAudio(True)
        time.sleep(6*60)
        self.assertTrue(self.dev.isNewDataOnDevice("audio") or self.mGS.isNewAudioUploaded(),
                    "Failed to find new audio data"
                )
        print("Audio generating is approved")
开发者ID:hufengping,项目名称:percolata,代码行数:24,代码来源:tc_audio_func.py


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