def tearDown(self): Helper(platform_name='K64F', allowed_files=['DETAILS.TXT', 'MBED.HTM']).clear() devices = list_mbeds_ext() # validates that there is still all devices than was originally self.assertEqual(len(devices), len(EraseTestCaseHW.all_devices)) count_eraseable = len(list_mbeds_eraseable(devices)) self.assertEqual(count_eraseable, len(EraseTestCaseHW.erase_allowed_devices))
def setUp(self): self.logging_patcher = mock.patch("mbed_flasher.main.logging") mock_logging = self.logging_patcher.start() mock_logging.getLogger = \ mock.MagicMock(return_value=mock.Mock(spec=logging.Logger)) # Mock logging # pylint: disable=no-member mock_logging.disable(logging.CRITICAL) Helper(platform_name='K64F', allowed_files=['DETAILS.TXT', 'MBED.HTM']).clear()
def setUp(self): logging.disable(logging.CRITICAL) Helper(platform_name='K64F', allowed_files=['DETAILS.TXT', 'MBED.HTM']).clear()
class EraseTestCaseHW(unittest.TestCase): """ Basic true asserts to see that testing is executed """ mbeds = mbed_lstools.create() all_devices = Helper.list_mbeds_ext() erase_allowed_devices = Helper.list_mbeds_eraseable(all_devices) def setUp(self): logging.disable(logging.CRITICAL) Helper(platform_name='K64F', allowed_files=['DETAILS.TXT', 'MBED.HTM']).clear() def tearDown(self): Helper(platform_name='K64F', allowed_files=['DETAILS.TXT', 'MBED.HTM']).clear() devices = list_mbeds_ext() # validates that there is still all devices than was originally self.assertEqual(len(devices), len(EraseTestCaseHW.all_devices)) count_eraseable = len(list_mbeds_eraseable(devices)) self.assertEqual(count_eraseable, len(EraseTestCaseHW.erase_allowed_devices)) def test_erase_with_all(self): eraser = Erase() ret = eraser.erase(target_id='all', method='simple') self.assertEqual(ret, EXIT_CODE_SUCCESS) def test_erase_with_target_id(self): eraser = Erase() devices = EraseTestCaseHW.erase_allowed_devices ret = None for item in devices: if item['target_id']: ret = eraser.erase(target_id=item['target_id'], method='simple') break self.assertEqual(ret, EXIT_CODE_SUCCESS) # test func name is larger than 30, but is meaningful # pylint: disable=invalid-name def test_erase_failed_non_supported_method(self): devices = EraseTestCaseHW.erase_allowed_devices eraser = Erase() for item in devices: if item['target_id']: with self.assertRaises(EraseError) as cm: eraser.erase(target_id=item['target_id'], method='unknown') self.assertEqual(cm.exception.return_code, EXIT_CODE_MISUSE_CMD) break # test func name is larger than 30, but is meaningful # pylint: disable=invalid-name def test_erase_with_target_id_no_reset(self): devices = EraseTestCaseHW.erase_allowed_devices eraser = Erase() ret = None for item in devices: if item['target_id']: ret = eraser.erase(target_id=item['target_id'], method='simple', no_reset=True) break self.assertEqual(ret, EXIT_CODE_SUCCESS) def test_erase_with_target_id_list(self): devices = EraseTestCaseHW.erase_allowed_devices eraser = Erase() ret = None for item in devices: if item['target_id']: ret = eraser.erase(target_id=[item['target_id']], method='simple') break self.assertEqual(ret, EXIT_CODE_SUCCESS)
def tearDown(self): Helper(platform_name='K64F', allowed_files=['DETAILS.TXT', 'MBED.HTM']).clear()