Unittests¶
test_cansignal¶
Tests for cansignal module.
-
class
tests.test_cansignal.TestCanSignal(methodName='runTest')[source] -
setUp()[source]
-
testConstructor()[source]
-
testConstructorWrongValues()[source]
-
testProperties()[source]
-
testPropertiesWrongValues()[source]
-
testRepr()[source]
-
testGetDescriptiveAsciiArt()[source]
-
testMaximumPossibleValueGet()[source]
-
testMinimumPossibleValueGet()[source]
-
testGetMinimumDlc()[source]
-
test_canframedefinition¶
Tests for canframe_definition module.
-
class
tests.test_canframedefinition.TestCanFrameDefinition(methodName='runTest')[source] -
setUp()[source]
-
testConstructor()[source]
-
testConstructorCycletime()[source]
-
testConstructorCycletimeNone()[source]
-
testConstructorNamedArguments()[source]
-
testConstructorWrongValues()[source]
-
testProperties()[source]
-
testPropertiesWrongValues()[source]
-
testIsOutbound()[source]
-
testIsOutboundWrongType()[source]
-
testGetSignalMask()[source]
-
testRepr()[source]
-
testReprThrottling()[source]
-
testReprNoSignals()[source]
-
testGetDescriptiveAsciiArt()[source]
-
test_configuration¶
Tests for configuration module.
-
class
tests.test_configuration.TestConfiguration(methodName='runTest')[source] -
setUp()[source]
-
testConstructor()[source]
-
testRepr()[source]
-
testProperties()[source]
-
testPropertiesWrongValues()[source]
-
testSetThrottleTimes()[source]
-
testSetThrottleTimesWrongValues()[source]
-
testSetThrottleTimesFromSignalnames()[source]
-
testSetThrottleTimesFromSignalnamesWrongValues()[source]
-
testSetReceiveOnChangeOnly()[source]
-
testSetReceiveOnChangeOnlyWrongValue()[source]
-
testSetReceiveOnChangeOnlyFromSignalnames()[source]
-
testSetReceiveOnChangeOnlyFromSignalnamesWrongValues()[source]
-
testGetDescriptiveAsciiArt()[source]
-
testAddFramedefinition()[source]
-
test_filehandler_kcd¶
Tests for filehandler_kcd module.
-
class
tests.test_filehandler_kcd.TestConfiguration(methodName='runTest')[source] -
OUTPUT_FILENAME_1= 'test_out_1_TEMPORARY.kcd'
-
OUTPUT_FILENAME_2= 'test_out_2_TEMPORARY.kcd'
-
OUTPUT_FILENAME_3= 'test_out_3_TEMPORARY.kcd'
-
OUTPUT_FILENAME_10= 'test_out_10_TEMPORARY.kcd'
-
setUp()[source]
-
tearDown()[source]
-
testReadKcdFile()[source]
-
testReadKcdFileFaulty()[source]
-
testReadKcdFileWrongBusname()[source]
-
testReadKcdFileNoBusnameGiven()[source]
-
testWriteKcdFile()[source]
-
testSaveLoadedConfigurationToFile()[source]
-
testWriteKcdFileNoBusnameGiven()[source]
-
testWriteKcdFileNoProducerGiven()[source]
-
test_utilities¶
Tests for utilities module.
-
class
tests.test_utilities.TestCalculateBackwardBitnumber(methodName='runTest')[source] -
knownValues= ((0, 56), (1, 57), (7, 63), (56, 0), (63, 7))
-
test_known_values()[source]
-
testWrongInputValue()[source]
-
-
class
tests.test_utilities.TestCalculateNormalBitnumber(methodName='runTest')[source] -
knownValues= ((0, 56), (1, 57), (7, 63), (56, 0), (63, 7))
-
test_known_values()[source]
-
testWrongInputValue()[source]
-
-
class
tests.test_utilities.TestSanityBitnumber(methodName='runTest')[source] -
test_known_values()[source]
-
-
class
tests.test_utilities.TestGenerateBitByteOverview(methodName='runTest')[source] -
test_known_values()[source]
-
testWrongInputValue()[source]
-
-
class
tests.test_utilities.TestGenerateCanIntegerOverview(methodName='runTest')[source] -
test_known_values()[source]
-
-
class
tests.test_utilities.TestBytesToInt(methodName='runTest')[source] -
knownValues= ((b'\x00', 0), (b'\x01', 72057594037927936), (b'\x01\x00\x00\x00\x00\x00\x00\x00', 72057594037927936), (b'\x00\x00\x00\x00\x00\x00\x00\x01', 1), (b'\x00\x00\x00\x00\x00\x00\x00\x10', 16), (b'\x00\x00\x00\x00\x00\x00\x00\xff', 255), (b'\x00\x00\x00\x00\x00\x00\x01\x00', 256), (b'\x00\x00\x00\x00\x00\x01\x00\x00', 65536), (b'\x00\x00\x00\x00\x01\x00\x00\x00', 16777216), (b'\x00\x00\x00\x01\x00\x00\x00\x00', 4294967296))
-
testKnownValues()[source]
-
-
class
tests.test_utilities.TestIntToBytes(methodName='runTest')[source] -
knownValues= ((1, 0, b''), (1, 1, b'\x00'), (1, 2, b'\x00\x00'))
-
testKnownValues()[source]
-
-
class
tests.test_utilities.TestTwosComplement(methodName='runTest')[source] -
knownValues= ((-4, 3, 4), (-3, 3, 5), (-2, 3, 6), (-1, 3, 7), (0, 3, 0), (1, 3, 1), (2, 3, 2), (3, 3, 3), (-128, 8, 128), (-127, 8, 129), (-126, 8, 130), (-2, 8, 254), (-1, 8, 255), (0, 8, 0), (1, 8, 1), (2, 8, 2), (126, 8, 126), (127, 8, 127))
-
testKnownValues()[source]
-
testWrongInputValue()[source]
-
-
class
tests.test_utilities.TestFromTwosComplement(methodName='runTest')[source] -
knownValues= ((-4, 3, 4), (-3, 3, 5), (-2, 3, 6), (-1, 3, 7), (0, 3, 0), (1, 3, 1), (2, 3, 2), (3, 3, 3), (-128, 8, 128), (-127, 8, 129), (-126, 8, 130), (-2, 8, 254), (-1, 8, 255), (0, 8, 0), (1, 8, 1), (2, 8, 2), (126, 8, 126), (127, 8, 127))
-
testKnownValues()[source]
-
testWrongInputValue()[source]
-
-
class
tests.test_utilities.TestTwosComplementSanity(methodName='runTest')[source] -
testSanity()[source]
-
-
class
tests.test_utilities.TestSplitSeconds(methodName='runTest')[source] -
knownValues= ((0, 0, 0), (1e-06, 0, 1), (0.001, 0, 1000), (0.02, 0, 20000), (0.25, 0, 250000), (0.33, 0, 330000), (0.9, 0, 900000), (0.99, 0, 990000), (1.0, 1, 0), (1, 1, 0), (1.25, 1, 250000), (99.99, 99, 990000), (100000.1, 100000, 100000))
-
testKnownValues()[source]
-
testWrongInputValue()[source]
-
-
class
tests.test_utilities.TestCheckFrameId(methodName='runTest')[source] -
testKnownValues()[source]
-
testWrongInputValue()[source]
-
testWrongInputType()[source]
-
-
class
tests.test_utilities.TestGetBusvalueFromBytes(methodName='runTest')[source] -
knownValues= ((b'\x00\x00\x00\x00\x00\x00\x00\x01', 'big', 8, 56, 1), (b'\x00\x00\x00\x00\x00\x00\x00\x06', 'big', 4, 56, 6), (b'\x00\x00\x00\x00\x00\x00\x00\xff', 'big', 8, 56, 255), (b'\x00\x00\x00\x00\x00\x00\xff\xff', 'big', 16, 56, 65535), (b'\x00\x00\x00\x00\x00\x00\x00\x01', 'big', 1, 56, 1), (b'\x00\x00\x00\x00\xff\x00\x00\x00', 'big', 8, 32, 255), (b'\x00\x00\x00\xff\xff\x00\x00\x00', 'big', 16, 32, 65535), (b'\x00\x00\x00\xff\xff\x00\x00\x00', 'big', 16, 32, 65535), (b'\x00\x00\x00\x00\x00\x00\x00\x01', 'little', 8, 56, 1), (b'\x00\x00\x00\x00\x00\x00\x00\xff', 'little', 8, 56, 255), (b'\x00\x00\x00\x00\x00\x00\xff\xff', 'little', 16, 48, 65535), (b'\x00\x00\x00\x00\x00\x00\x00\x01', 'little', 1, 56, 1), (b'\x00\x00\x00\x00\xff\x00\x00\x00', 'little', 8, 32, 255), (b'\xff\x00\x00\x00\x00\x00\x00\x00', 'little', 8, 0, 255), (b'\x00\x00\x00\x02\x01\x00\x00\x00', 'little', 16, 24, 258))
-
testKnownValues()[source]
-
-
class
tests.test_utilities.TestGetShiftedvalueFromBusvalue(methodName='runTest')[source] -
knownValues= ((b'\x00\x00\x00\x00\x00\x00\x00\x01', 'big', 8, 56, 1), (b'\x00\x00\x00\x00\x00\x00\x00\x06', 'big', 4, 56, 6), (b'\x00\x00\x00\x00\x00\x00\x00\xff', 'big', 8, 56, 255), (b'\x00\x00\x00\x00\x00\x00\xff\xff', 'big', 16, 56, 65535), (b'\x00\x00\x00\x00\x00\x00\x00\x01', 'big', 1, 56, 1), (b'\x00\x00\x00\x00\xff\x00\x00\x00', 'big', 8, 32, 255), (b'\x00\x00\x00\xff\xff\x00\x00\x00', 'big', 16, 32, 65535), (b'\x00\x00\x00\xff\xff\x00\x00\x00', 'big', 16, 32, 65535), (b'\x00\x00\x00\x00\x00\x00\x00\x01', 'little', 8, 56, 1), (b'\x00\x00\x00\x00\x00\x00\x00\xff', 'little', 8, 56, 255), (b'\x00\x00\x00\x00\x00\x00\xff\xff', 'little', 16, 48, 65535), (b'\x00\x00\x00\x00\x00\x00\x00\x01', 'little', 1, 56, 1), (b'\x00\x00\x00\x00\xff\x00\x00\x00', 'little', 8, 32, 255), (b'\xff\x00\x00\x00\x00\x00\x00\x00', 'little', 8, 0, 255), (b'\x00\x00\x00\x02\x01\x00\x00\x00', 'little', 16, 24, 258))
-
testKnownValues()[source]
-
test_canframe¶
Tests for canframe module.
-
class
tests.test_canframe.TestCanFrame(methodName='runTest')[source] -
setUp()[source]
-
testConstructor()[source]
-
testConstructorNamedArguments()[source]
-
testConstructorFromEmptyBytes()[source]
-
testConstructorFromRawframes()[source]
-
testWrongConstructor()[source]
-
testWrongConstructorFromEmptyBytes()[source]
-
testWrongConstructorFromRawframe()[source]
-
testFrameidGet()[source]
-
testFrameidSet()[source]
-
testFrameidSetWrongValue()[source]
-
testFrameFormatGet()[source]
-
testFrameFormatSet()[source]
-
testFrameFormatSetWrongValue()[source]
-
testFramedataGet()[source]
-
testFramedataSet()[source]
-
testFramedataSetWrongValue()[source]
-
testSignalvalueSet()[source]
-
testSignalvalueSetSigned()[source]
-
testSignalvalueSetSingle()[source]
-
testSignalvalueSetSingleLittle()[source]
-
testSignalvalueGetSingle()[source]
-
testSignalvalueGetSingleLittle()[source]
-
testSignalvalueSetDouble()[source]
-
testSignalvalueSetDoubleLittle()[source]
-
testSignalvalueGetDouble()[source]
-
testSignalvalueGetDoubleLittle()[source]
-
testSignalvalueSetTooShortFrame()[source]
-
testSignalvalueGetSetMin()[source]
-
testSignalvalueGetSetMax()[source]
-
testSignalvalueSetWrongValue()[source]
-
testSignalvalueGet()[source]
-
testSignalvalueGetSigned()[source]
-
testGetRawFrameStandard()[source]
-
testGetRawFrameExtended()[source]
-
testUnpack()[source]
-
testUnpackWrongFrameId()[source]
-
testUnpackWrongFramelength()[source]
-
testRepr()[source]
-
testLen()[source]
-
testGetDescriptiveAsciiArt()[source]
-
test_caninterface_raw¶
Tests for caninterface_raw module.
Notes
A virtual CAN interface ‘vcan’ must be enabled for this test. See enable_virtual_can_bus(). Must be run as sudo.
-
tests.test_caninterface_raw.enable_virtual_can_bus()[source]
-
tests.test_caninterface_raw.disable_virtual_can_bus()[source]
-
class
tests.test_caninterface_raw.TestSocketCanRawInterface(methodName='runTest')[source] -
NUMBER_OF_LOOPS= 10000
-
FRAME_SENDER_SPACING_MILLISECONDS= 0.1
-
FRAME_ID_RECEIVE= 4
-
FRAME_ID_SEND= 1
-
FRAME_NUMBER_OF_DATABYTES= 8
-
NONEXISTING_CAN_BUS_NAME= 'vcan8'
-
setUp()[source]
-
tearDown()[source]
-
start_can_frame_sender()[source] Send CAN frames using the cangen command.
-
testConstructor()[source]
-
testConstructorWrongValue()[source]
-
testConstructorWrongType()[source]
-
testConstructorSeveralInterfaces()[source]
-
testCreateNonExistingBus()[source]
-
testWriteToInterfacenameAttribute()[source]
-
testRepr()[source]
-
testReceiveData()[source]
-
testReceiveSpeed()[source]
-
testReceiveNoData()[source]
-
testReceiveClosedBus()[source]
-
testReceiveClosedInterface()[source]
-
testSend()[source]
-
testSendClosedBus()[source]
-
testSendClosedInterface()[source]
-
testTooFewTooManyFiltersDefined()[source]
-
test_caninterface_bcm¶
Tests for caninterface_bcm module.
Notes
A virtual CAN interface ‘vcan’ must be enabled for this test. See enable_virtual_can_bus(). Must be run as sudo.
-
class
tests.test_caninterface_bcm.TestSocketCanBcmInterface(methodName='runTest')[source] -
NUMBER_OF_LOOPS= 10000
-
FRAME_SENDER_SPACING_MILLISECONDS= 0.1
-
FRAME_ID_RECEIVE= 4
-
FRAME_ID_SEND= 1
-
FRAME_NUMBER_OF_DATABYTES= 8
-
NONEXISTING_CAN_BUS_NAME= 'vcan8'
-
NONEXISTING_FRAME_ID= 22
-
setUp()[source]
-
tearDown()[source]
-
start_can_frame_sender(interval_milliseconds=0.1)[source] Send CAN frames using the cangen command. Unlimited number of frames.
-
testConstructor()[source]
-
testConstructorWrongValue()[source]
-
testConstructorWrongType()[source]
-
testConstructorSeveralInterfaces()[source]
-
testCreateNonExistingBus()[source]
-
testWriteToInterfacenameAttribute()[source]
-
testRepr()[source]
-
testSetupReception()[source]
-
testSetupReceptionWrongValue()[source]
-
testSetupReceptionWrongType()[source]
-
testReceiveData()[source]
-
testReceiveStoppedReception()[source]
-
testReceiveWrongId()[source]
-
testReceiveSpeed()[source]
-
testReceiveSpeedThrottled()[source]
-
testReceiveDataChanged()[source] Verify that data change filtering works, by measuring time to receive a small number of frames from a larger data flow.
-
testReceiveDataChangedShorterDlcThanMask()[source] Verify that filtering works also when the input frame is shorter (3 bytes) than the data mask (8 bytes).
-
testReceiveDlcChanged()[source] Verify that we are receiving frames where each frame is longer (or no data) than the previous.
-
testReceiveNoData()[source]
-
testReceiveClosedBus()[source]
-
testReceiveClosedInterface()[source]
-
testSendSingleFrameWrongType()[source]
-
testSendSingleFrame()[source]
-
testSetupPeriodicSendWrongValue()[source]
-
testSetupPeriodicSendWrongType()[source]
-
testSendPeriodicAndChangeFrameAndStop()[source] Start periodic CAN transmission, update frame data (not interval), and finally stop transmission.
-
testSendPeriodicAndChangeFrameAndStopExtended()[source] Start periodic CAN transmission, update frame data (not interval), and finally stop transmission.
-
testStopNonexistingPeriodicTask()[source]
-
testSendClosedBus()[source]
-
testSendClosedInterface()[source]
-
test_canbus¶
Tests for canbus module.
Notes
A virtual CAN interface ‘vcan’ must be enabled for this test. Must be run as sudo.
-
class
tests.test_canbus.TestCanBus(methodName='runTest')[source] -
NUMBER_OF_LOOPS= 1000
-
FRAME_SENDER_SPACING_MILLISECONDS= 1
-
FRAME_NUMBER_OF_DATABYTES= 8
-
OUTPUT_FILENAME_4= 'test_out_4_TEMPORARY.kcd'
-
OUTPUT_FILENAME_5= 'test_out_5_TEMPORARY.kcd'
-
OUTPUT_FILENAME_6= 'test_out_6_TEMPORARY.kcd'
-
OUTPUT_FILENAME_7= 'test_out_7_TEMPORARY.kcd'
-
setUp()[source]
-
tearDown()[source]
-
testUseBcmAttribute()[source]
-
testWriteToBcmAttribute()[source]
-
testWriteToConfigAttribute()[source]
-
testConstructor()[source]
-
testReadConfigFromFile()[source] See test_configuration.py and others for more complete configuration read testing
-
testRepr()[source]
-
testGetDescriptiveAsciiArt()[source]
-
testSendRaw()[source]
-
testSendRawKeywordArguments()[source]
-
testSendBcm()[source]
-
testSendBcmFrame()[source]
-
testSendSpeedAndDetectAllRaw()[source]
-
testSendSpeedAndDetectAllBcm()[source]
-
testPeriodicSendingUpdateSignalsAndStop()[source]
-
testStartSendingAllSignals()[source]
-
testSendWrongSignal()[source]
-
testSendWrongSignalValue()[source]
-
testUsingBcmCommandsForRawInterface()[source]
-
testInitReception()[source]
-
testReceiveRaw()[source]
-
testReceiveBcmAndStop()[source]
-
testReceiveBcmFrameAndStop()[source]
-
testReceiveSpeedRaw()[source]
-
testReceiveSpeedBcm()[source]
-
testReceiveAllSentFramesRaw()[source]
-
testReceiveAllSentFramesBcm()[source]
-
testReceiveNoData()[source]
-
testSaveDefinitionToFileRaw()[source]
-
testSaveLoadedDefinitionToFileRaw()[source]
-
testSaveDefinitionToFileBcm()[source]
-
testSaveLoadedDefinitionToFileBcm()[source]
-