mirror of
https://github.com/BOSWatch/BW3-Core.git
synced 2026-04-06 06:43:54 +00:00
Avoid "DeprecationWarning: invalid escape sequence"
Without this change, many warnings like this will be generated while running pytest:
```
test/test_template.py:3
/build/source/test/test_template.py:3: DeprecationWarning: invalid escape sequence '\/'
"""!
```
This can also be seen when manually running python with warnings enabled.
This happens because the comment uses a multiline string and Python interprets the backslash in the logo as an escape character and complains that \/ is not a valid escape sequence. To fix this, prepend the string with the letter r to indicate that the backslash should be treated as a literal character, see https://docs.python.org/3/reference/lexical_analysis.html#index-20.
I also applied this change to all the comment strings since that shouldn't break anything and to establish it as a pattern for the future so this problem hopefully never happens again.
This is what I did specifically:
- Change the comment at the top of bw_client.py and bw_server.py to start with `"""!` since that seems to be the pattern here
- Search-and-Replace all occurances of `"""!` with `r"""!`
- Manually change the strings in `logoToLog()` in boswatch/utils/header.py
This commit is contained in:
parent
1b95474bc2
commit
d4dcc75711
50 changed files with 327 additions and 327 deletions
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""!
|
||||
r"""!
|
||||
____ ____ ______ __ __ __ _____
|
||||
/ __ )/ __ \/ ___/ | / /___ _/ /______/ /_ |__ /
|
||||
/ __ / / / /\__ \| | /| / / __ `/ __/ ___/ __ \ /_ <
|
||||
|
|
@ -32,13 +32,13 @@ def setup_function(function):
|
|||
|
||||
@pytest.fixture
|
||||
def getClient():
|
||||
"""!Build and serve a TCPCLient"""
|
||||
r"""!Build and serve a TCPCLient"""
|
||||
return TCPClient()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def getServer():
|
||||
"""!Build and serve a TCPServer"""
|
||||
r"""!Build and serve a TCPServer"""
|
||||
dataQueue = queue.Queue()
|
||||
testServer = TCPServer(dataQueue)
|
||||
return testServer
|
||||
|
|
@ -46,7 +46,7 @@ def getServer():
|
|||
|
||||
@pytest.fixture
|
||||
def getRunningServer(getServer):
|
||||
"""!Build and serve a still running TCPServer"""
|
||||
r"""!Build and serve a still running TCPServer"""
|
||||
logging.debug("start server")
|
||||
assert getServer.start()
|
||||
while not getServer.isRunning:
|
||||
|
|
@ -58,40 +58,40 @@ def getRunningServer(getServer):
|
|||
|
||||
|
||||
def test_clientConnectFailed(getClient):
|
||||
"""!Connect to a non available server"""
|
||||
r"""!Connect to a non available server"""
|
||||
assert not getClient.connect()
|
||||
|
||||
|
||||
def test_clientDisconnectFailed(getClient):
|
||||
"""!Disconnect while no connection is established"""
|
||||
r"""!Disconnect while no connection is established"""
|
||||
assert getClient.disconnect()
|
||||
|
||||
|
||||
def test_clientTransmitFailed(getClient):
|
||||
"""!Transmit while no connection is established"""
|
||||
r"""!Transmit while no connection is established"""
|
||||
assert not getClient.transmit("test")
|
||||
|
||||
|
||||
def test_clientReceiveFailed(getClient):
|
||||
"""!Receive while no connection is established"""
|
||||
r"""!Receive while no connection is established"""
|
||||
assert not getClient.receive()
|
||||
|
||||
|
||||
def test_clientConnect(getClient, getRunningServer):
|
||||
"""!Connect to a server"""
|
||||
r"""!Connect to a server"""
|
||||
assert getClient.connect()
|
||||
assert getClient.disconnect()
|
||||
|
||||
|
||||
def test_doubleConnect(getClient, getRunningServer):
|
||||
"""!Connect to a server twice"""
|
||||
r"""!Connect to a server twice"""
|
||||
assert getClient.connect()
|
||||
assert getClient.connect()
|
||||
assert getClient.disconnect()
|
||||
|
||||
|
||||
def test_clientReconnect(getClient, getRunningServer):
|
||||
"""!Try a reconnect after a established connection"""
|
||||
r"""!Try a reconnect after a established connection"""
|
||||
assert getClient.connect()
|
||||
assert getClient.disconnect()
|
||||
assert getClient.connect()
|
||||
|
|
@ -99,7 +99,7 @@ def test_clientReconnect(getClient, getRunningServer):
|
|||
|
||||
|
||||
def test_clientMultiConnect(getClient, getRunningServer):
|
||||
"""!Connect with 2 clients to the server"""
|
||||
r"""!Connect with 2 clients to the server"""
|
||||
assert getClient.connect()
|
||||
testClient2 = TCPClient()
|
||||
assert testClient2.connect()
|
||||
|
|
@ -112,7 +112,7 @@ def test_clientMultiConnect(getClient, getRunningServer):
|
|||
|
||||
|
||||
def test_clientCommunicate(getClient, getRunningServer):
|
||||
"""!Try to send data to the server and check on '[ack]'"""
|
||||
r"""!Try to send data to the server and check on '[ack]'"""
|
||||
assert getClient.connect()
|
||||
assert getClient.transmit("test")
|
||||
assert getClient.receive() == "[ack]"
|
||||
|
|
@ -121,7 +121,7 @@ def test_clientCommunicate(getClient, getRunningServer):
|
|||
|
||||
@pytest.mark.skip("needs fixture for more than one client")
|
||||
def test_clientMultiCommunicate(getServer):
|
||||
"""!Try to send data to the server with 3 clients and check on '[ack]'"""
|
||||
r"""!Try to send data to the server with 3 clients and check on '[ack]'"""
|
||||
# connect all
|
||||
testClient1 = TCPClient()
|
||||
assert testClient1.connect()
|
||||
|
|
@ -146,26 +146,26 @@ def test_clientMultiCommunicate(getServer):
|
|||
|
||||
|
||||
def test_serverRestart(getRunningServer):
|
||||
"""!Test a stop and restart of the server"""
|
||||
r"""!Test a stop and restart of the server"""
|
||||
assert getRunningServer.stop()
|
||||
assert getRunningServer.start()
|
||||
assert getRunningServer.stop()
|
||||
|
||||
|
||||
def test_serverStopFailed(getServer):
|
||||
"""!Test to stop a stopped server"""
|
||||
r"""!Test to stop a stopped server"""
|
||||
assert getServer.stop()
|
||||
|
||||
|
||||
def test_serverDoubleStart(getServer):
|
||||
"""!Test to start the server twice"""
|
||||
r"""!Test to start the server twice"""
|
||||
assert getServer.start()
|
||||
assert getServer.start()
|
||||
assert getServer.stop()
|
||||
|
||||
|
||||
def test_serverStartTwoInstances():
|
||||
"""!Test to start two server different server instances"""
|
||||
r"""!Test to start two server different server instances"""
|
||||
dataQueue = queue.Queue()
|
||||
testServer1 = TCPServer(dataQueue)
|
||||
testServer2 = TCPServer(dataQueue)
|
||||
|
|
@ -179,7 +179,7 @@ def test_serverStartTwoInstances():
|
|||
|
||||
|
||||
def test_serverStopsWhileConnected(getRunningServer, getClient):
|
||||
"""!Shutdown server while client is connected"""
|
||||
r"""!Shutdown server while client is connected"""
|
||||
getClient.connect()
|
||||
getRunningServer.stop()
|
||||
timeout = 5
|
||||
|
|
@ -193,7 +193,7 @@ def test_serverStopsWhileConnected(getRunningServer, getClient):
|
|||
|
||||
@pytest.mark.skip("needs fixture for more than one client")
|
||||
def test_serverGetOutput(getRunningServer):
|
||||
"""!Send data to server with 2 clients, check '[ack]' and data on server queue"""
|
||||
r"""!Send data to server with 2 clients, check '[ack]' and data on server queue"""
|
||||
# connect all
|
||||
testClient1 = TCPClient()
|
||||
assert testClient1.connect()
|
||||
|
|
@ -217,7 +217,7 @@ def test_serverGetOutput(getRunningServer):
|
|||
|
||||
|
||||
def test_serverHighLoad(getRunningServer):
|
||||
"""!High load server test with 10 send threads each will send 100 msg with 324 bytes size"""
|
||||
r"""!High load server test with 10 send threads each will send 100 msg with 324 bytes size"""
|
||||
logging.debug("start sendThreads")
|
||||
threads = []
|
||||
for thr_id in range(10):
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""!
|
||||
r"""!
|
||||
____ ____ ______ __ __ __ _____
|
||||
/ __ )/ __ \/ ___/ | / /___ _/ /______/ /_ |__ /
|
||||
/ __ / / / /\__ \| | /| / / __ `/ __/ ___/ __ \ /_ <
|
||||
|
|
@ -29,7 +29,7 @@ def setup_function(function):
|
|||
|
||||
@pytest.fixture()
|
||||
def broadcastServer():
|
||||
"""!Server a BroadcastServer instance"""
|
||||
r"""!Server a BroadcastServer instance"""
|
||||
broadcastServer = BroadcastServer()
|
||||
yield broadcastServer
|
||||
if broadcastServer.isRunning:
|
||||
|
|
@ -40,36 +40,36 @@ def broadcastServer():
|
|||
|
||||
@pytest.fixture()
|
||||
def broadcastClient():
|
||||
"""!Server a BroadcastClient instance"""
|
||||
r"""!Server a BroadcastClient instance"""
|
||||
return BroadcastClient()
|
||||
|
||||
|
||||
def test_serverStartStop(broadcastServer):
|
||||
"""!Start a BroadcastServer, check if running and stop it"""
|
||||
r"""!Start a BroadcastServer, check if running and stop it"""
|
||||
assert broadcastServer.start()
|
||||
assert broadcastServer.isRunning
|
||||
assert broadcastServer.stop()
|
||||
|
||||
|
||||
def test_serverDoubleStart(broadcastServer):
|
||||
"""!Try to start a BroadcastServer twice"""
|
||||
r"""!Try to start a BroadcastServer twice"""
|
||||
assert broadcastServer.start()
|
||||
assert broadcastServer.start()
|
||||
assert broadcastServer.stop()
|
||||
|
||||
|
||||
def test_serverStopNotStarted(broadcastServer):
|
||||
"""!Try to stop a BroadcastServer where is not running"""
|
||||
r"""!Try to stop a BroadcastServer where is not running"""
|
||||
assert broadcastServer.stop()
|
||||
|
||||
|
||||
def test_clientWithoutServer(broadcastClient):
|
||||
"""!Use BroadcastClient with no server"""
|
||||
r"""!Use BroadcastClient with no server"""
|
||||
assert not broadcastClient.getConnInfo(1)
|
||||
|
||||
|
||||
def test_serverClientFetchConnInfo(broadcastClient, broadcastServer):
|
||||
"""!Fetch connection info from BroadcastServer"""
|
||||
r"""!Fetch connection info from BroadcastServer"""
|
||||
assert broadcastServer.start()
|
||||
assert broadcastClient.getConnInfo()
|
||||
assert broadcastServer.stop()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""!
|
||||
r"""!
|
||||
____ ____ ______ __ __ __ _____
|
||||
/ __ )/ __ \/ ___/ | / /___ _/ /______/ /_ |__ /
|
||||
/ __ / / / /\__ \| | /| / / __ `/ __/ ___/ __ \ /_ <
|
||||
|
|
@ -29,41 +29,41 @@ def setup_function(function):
|
|||
|
||||
@pytest.fixture
|
||||
def getConfig():
|
||||
"""!Build a config object"""
|
||||
r"""!Build a config object"""
|
||||
return ConfigYAML()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def getFilledConfig():
|
||||
"""!Build a config object and fill it with the config data"""
|
||||
r"""!Build a config object and fill it with the config data"""
|
||||
filledConfig = ConfigYAML()
|
||||
assert filledConfig.loadConfigFile(paths.TEST_PATH + "test_config.yaml") is True
|
||||
return filledConfig
|
||||
|
||||
|
||||
def test_loadConfigFile(getConfig):
|
||||
"""!load a config file"""
|
||||
r"""!load a config file"""
|
||||
assert getConfig.loadConfigFile(paths.TEST_PATH + "test_config.yaml") is True
|
||||
|
||||
|
||||
def test_loadConfigFileFailed(getConfig):
|
||||
"""!load a config file with syntax error"""
|
||||
r"""!load a config file with syntax error"""
|
||||
assert getConfig.loadConfigFile(paths.TEST_PATH + "test_configFailed.yaml") is False
|
||||
|
||||
|
||||
def test_loadConfigFileNotFound(getConfig):
|
||||
"""!load a config file where is not available"""
|
||||
r"""!load a config file where is not available"""
|
||||
assert getConfig.loadConfigFile(paths.TEST_PATH + "test_configNotFound.yaml") is False
|
||||
|
||||
|
||||
def test_getConfigAsString(getFilledConfig):
|
||||
"""!Get the string representation of the config"""
|
||||
r"""!Get the string representation of the config"""
|
||||
assert type(str(getFilledConfig)) is str
|
||||
logging.debug(getFilledConfig)
|
||||
|
||||
|
||||
def test_getTypes(getFilledConfig):
|
||||
"""!Get and check different data types in config"""
|
||||
r"""!Get and check different data types in config"""
|
||||
assert type(getFilledConfig.get("types")) is ConfigYAML
|
||||
assert type(getFilledConfig.get("types", "string")) is str
|
||||
assert type(getFilledConfig.get("types", "bool")) is bool
|
||||
|
|
@ -72,19 +72,19 @@ def test_getTypes(getFilledConfig):
|
|||
|
||||
|
||||
def test_getDefaultValue(getFilledConfig):
|
||||
"""!Get the default value of an not existent entry"""
|
||||
r"""!Get the default value of an not existent entry"""
|
||||
assert getFilledConfig.get("notExistent", default="defaultValue") == "defaultValue"
|
||||
|
||||
|
||||
def test_getNestedConfig(getFilledConfig):
|
||||
"""!Work with nested sub-config elements"""
|
||||
r"""!Work with nested sub-config elements"""
|
||||
nestedConfig = getFilledConfig.get("types")
|
||||
assert type(nestedConfig) is ConfigYAML
|
||||
assert nestedConfig.get("string") == "Hello World"
|
||||
|
||||
|
||||
def test_configIterationList(getFilledConfig):
|
||||
"""!Try to iterate over a list in the config"""
|
||||
r"""!Try to iterate over a list in the config"""
|
||||
counter = 0
|
||||
for item in getFilledConfig.get("list"):
|
||||
assert type(item) is str
|
||||
|
|
@ -93,7 +93,7 @@ def test_configIterationList(getFilledConfig):
|
|||
|
||||
|
||||
def test_configIterationListWithNestedList(getFilledConfig):
|
||||
"""!Try to iterate over a list in the config where its elements are lists itself"""
|
||||
r"""!Try to iterate over a list in the config where its elements are lists itself"""
|
||||
listCnt = 0
|
||||
strCnt = 0
|
||||
for item in getFilledConfig.get("list1"):
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""!
|
||||
r"""!
|
||||
____ ____ ______ __ __ __ _____
|
||||
/ __ )/ __ \/ ___/ | / /___ _/ /______/ /_ |__ /
|
||||
/ __ / / / /\__ \| | /| / / __ `/ __/ ___/ __ \ /_ <
|
||||
|
|
@ -26,19 +26,19 @@ def setup_function(function):
|
|||
|
||||
|
||||
def test_decoderNoData():
|
||||
"""!Test a empty string"""
|
||||
r"""!Test a empty string"""
|
||||
assert Decoder.decode("") is None
|
||||
|
||||
|
||||
def test_decoderZveiValid():
|
||||
"""!Test valid ZVEI"""
|
||||
r"""!Test valid ZVEI"""
|
||||
assert not Decoder.decode("ZVEI1: 12345") is None
|
||||
assert not Decoder.decode("ZVEI1: 12838") is None
|
||||
assert not Decoder.decode("ZVEI1: 34675") is None
|
||||
|
||||
|
||||
def test_decoderZveiDoubleTone():
|
||||
"""!Test doubleTone included ZVEI"""
|
||||
r"""!Test doubleTone included ZVEI"""
|
||||
assert not Decoder.decode("ZVEI1: 6E789") is None
|
||||
assert not Decoder.decode("ZVEI1: 975E7") is None
|
||||
assert not Decoder.decode("ZVEI1: 2E87E") is None
|
||||
|
|
@ -54,7 +54,7 @@ def test_decoderZveiInvalid():
|
|||
|
||||
|
||||
def test_decoderPocsagValid():
|
||||
"""!Test valid POCSAG"""
|
||||
r"""!Test valid POCSAG"""
|
||||
assert not Decoder.decode("POCSAG512: Address: 1000000 Function: 0") is None
|
||||
assert not Decoder.decode("POCSAG512: Address: 1000001 Function: 1") is None
|
||||
assert not Decoder.decode("POCSAG1200: Address: 1000002 Function: 2") is None
|
||||
|
|
@ -62,7 +62,7 @@ def test_decoderPocsagValid():
|
|||
|
||||
|
||||
def test_decoderPocsagText():
|
||||
"""!Test POCSAG with text"""
|
||||
r"""!Test POCSAG with text"""
|
||||
assert not Decoder.decode("POCSAG512: Address: 1000000 Function: 0 Alpha: test") is None
|
||||
assert not Decoder.decode("POCSAG512: Address: 1000001 Function: 1 Alpha: test") is None
|
||||
assert not Decoder.decode("POCSAG1200: Address: 1000002 Function: 2 Alpha: test") is None
|
||||
|
|
@ -70,7 +70,7 @@ def test_decoderPocsagText():
|
|||
|
||||
|
||||
def test_decoderPocsagShortRic():
|
||||
"""!Test short POCSAG"""
|
||||
r"""!Test short POCSAG"""
|
||||
assert not Decoder.decode("POCSAG512: Address: 3 Function: 0 Alpha: test") is None
|
||||
assert not Decoder.decode("POCSAG512: Address: 33 Function: 0 Alpha: test") is None
|
||||
assert not Decoder.decode("POCSAG1200: Address: 333 Function: 0 Alpha: test") is None
|
||||
|
|
@ -81,14 +81,14 @@ def test_decoderPocsagShortRic():
|
|||
|
||||
|
||||
def test_decoderPocsagInvalid():
|
||||
"""!Test invalid POCSAG"""
|
||||
r"""!Test invalid POCSAG"""
|
||||
assert Decoder.decode("POCSAG512: Address: 333333F Function: 0 Alpha: invalid") is None
|
||||
assert Decoder.decode("POCSAG512: Address: 333333F Function: 1 Alpha: invalid") is None
|
||||
assert Decoder.decode("POCSAG512: Address: 3333333 Function: 4 Alpha: invalid") is None
|
||||
|
||||
|
||||
def test_decoderFmsValid():
|
||||
"""!Test valid FMS"""
|
||||
r"""!Test valid FMS"""
|
||||
assert not Decoder.decode("""FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 0=FZG->LST 2=I (ohneNA,ohneSIGNAL)) CRC correct""") is None
|
||||
assert not Decoder.decode("""FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 1=LST->FZG 2=I (ohneNA,ohneSIGNAL)) CRC correct""") is None
|
||||
assert not Decoder.decode("""FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 0=FZG->LST 2=II (ohneNA,mit SIGNAL)) CRC correct""") is None
|
||||
|
|
@ -97,7 +97,7 @@ def test_decoderFmsValid():
|
|||
|
||||
|
||||
def test_decoderFmsInvalid():
|
||||
"""!Test invalid FMS"""
|
||||
r"""!Test invalid FMS"""
|
||||
assert Decoder.decode("""FMS: 14170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 1=LST->FZG 2=III(mit NA,ohneSIGNAL)) CRC correct""") is None
|
||||
assert Decoder.decode("""FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Sta 3=Einsatz Ab 0=FZG->LST 2=IV (mit NA,mit SIGNAL)) CRC correct""") is None
|
||||
assert Decoder.decode("""FMS: 14170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 1=LST->FZG 2=III(mit NA,ohneSIGNAL)) CRC incorrect""") is None
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""!
|
||||
r"""!
|
||||
____ ____ ______ __ __ __ _____
|
||||
/ __ )/ __ \/ ___/ | / /___ _/ /______/ /_ |__ /
|
||||
/ __ / / / /\__ \| | /| / / __ `/ __/ ___/ __ \ /_ <
|
||||
|
|
@ -26,10 +26,10 @@ def setup_function(function):
|
|||
|
||||
|
||||
def test_logoToLog():
|
||||
"""!Test logo to log"""
|
||||
r"""!Test logo to log"""
|
||||
assert header.logoToLog()
|
||||
|
||||
|
||||
def test_infoToLog():
|
||||
"""!Test info to log"""
|
||||
r"""!Test info to log"""
|
||||
assert header.infoToLog()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""!
|
||||
r"""!
|
||||
____ ____ ______ __ __ __ _____
|
||||
/ __ )/ __ \/ ___/ | / /___ _/ /______/ /_ |__ /
|
||||
/ __ / / / /\__ \| | /| / / __ `/ __/ ___/ __ \ /_ <
|
||||
|
|
@ -28,33 +28,33 @@ def setup_function(function):
|
|||
|
||||
@pytest.fixture()
|
||||
def buildPacket():
|
||||
"""!Build a BOSWatch packet and serve it to each test"""
|
||||
r"""!Build a BOSWatch packet and serve it to each test"""
|
||||
return Packet()
|
||||
|
||||
|
||||
def test_createPacket(buildPacket):
|
||||
"""!Create a packet"""
|
||||
r"""!Create a packet"""
|
||||
assert buildPacket != ""
|
||||
|
||||
|
||||
def test_copyPacket(buildPacket):
|
||||
"""!Copy a packet to an new instance"""
|
||||
r"""!Copy a packet to an new instance"""
|
||||
bwCopyPacket = Packet(buildPacket.__str__())
|
||||
assert bwCopyPacket != ""
|
||||
|
||||
|
||||
def test_getPacketString(buildPacket):
|
||||
"""!get the intern packet dict as string"""
|
||||
r"""!get the intern packet dict as string"""
|
||||
assert type(buildPacket.__str__()) is str
|
||||
assert buildPacket.__str__() != ""
|
||||
|
||||
|
||||
def test_getNotSetField(buildPacket):
|
||||
"""!try to get a not set field"""
|
||||
r"""!try to get a not set field"""
|
||||
assert not buildPacket.get("testfield")
|
||||
|
||||
|
||||
def test_setGetField(buildPacket):
|
||||
"""!set and get a field"""
|
||||
r"""!set and get a field"""
|
||||
buildPacket.set("testField", "test")
|
||||
assert buildPacket.get("testField") == "test"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""!
|
||||
r"""!
|
||||
____ ____ ______ __ __ __ _____
|
||||
/ __ )/ __ \/ ___/ | / /___ _/ /______/ /_ |__ /
|
||||
/ __ / / / /\__ \| | /| / / __ `/ __/ ___/ __ \ /_ <
|
||||
|
|
@ -27,23 +27,23 @@ def setup_function(function):
|
|||
|
||||
|
||||
def test_fileExists():
|
||||
"""!load a local config file"""
|
||||
r"""!load a local config file"""
|
||||
assert paths.fileExist("README.md")
|
||||
|
||||
|
||||
def test_fileNotExists():
|
||||
"""!load a local config file"""
|
||||
r"""!load a local config file"""
|
||||
assert not paths.fileExist("notFound.txt")
|
||||
|
||||
|
||||
def test_makeDirNotExisting():
|
||||
"""!load a local config file"""
|
||||
r"""!load a local config file"""
|
||||
assert paths.makeDirIfNotExist("UnItTeSt")
|
||||
os.removedirs("UnItTeSt")
|
||||
|
||||
|
||||
def test_makeDirExisting():
|
||||
"""!load a local config file"""
|
||||
r"""!load a local config file"""
|
||||
paths.makeDirIfNotExist("UnItTeSt")
|
||||
assert paths.makeDirIfNotExist("UnItTeSt")
|
||||
os.removedirs("UnItTeSt")
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""!
|
||||
r"""!
|
||||
____ ____ ______ __ __ __ _____
|
||||
/ __ )/ __ \/ ___/ | / /___ _/ /______/ /_ |__ /
|
||||
/ __ / / / /\__ \| | /| / / __ `/ __/ ___/ __ \ /_ <
|
||||
|
|
@ -28,12 +28,12 @@ def setup_function(function):
|
|||
|
||||
|
||||
def testTargetFast():
|
||||
"""!Fast worker thread"""
|
||||
r"""!Fast worker thread"""
|
||||
logging.debug("run testTargetFast")
|
||||
|
||||
|
||||
def testTargetSlow():
|
||||
"""!Slow worker thread"""
|
||||
r"""!Slow worker thread"""
|
||||
logging.debug("run testTargetSlow start")
|
||||
time.sleep(0.51)
|
||||
logging.debug("run testTargetSlow end")
|
||||
|
|
@ -41,7 +41,7 @@ def testTargetSlow():
|
|||
|
||||
@pytest.fixture()
|
||||
def useTimerFast():
|
||||
"""!Server a RepeatedTimer instance with fast worker"""
|
||||
r"""!Server a RepeatedTimer instance with fast worker"""
|
||||
testTimer = RepeatedTimer(0.1, testTargetFast)
|
||||
yield testTimer
|
||||
if testTimer.isRunning:
|
||||
|
|
@ -50,7 +50,7 @@ def useTimerFast():
|
|||
|
||||
@pytest.fixture()
|
||||
def useTimerSlow():
|
||||
"""!Server a RepeatedTimer instance slow worker"""
|
||||
r"""!Server a RepeatedTimer instance slow worker"""
|
||||
testTimer = RepeatedTimer(0.1, testTargetSlow)
|
||||
yield testTimer
|
||||
if testTimer.isRunning:
|
||||
|
|
@ -58,32 +58,32 @@ def useTimerSlow():
|
|||
|
||||
|
||||
def test_timerStartStop(useTimerFast):
|
||||
"""!Try to start and stop a timer"""
|
||||
r"""!Try to start and stop a timer"""
|
||||
assert useTimerFast.start()
|
||||
assert useTimerFast.stop()
|
||||
|
||||
|
||||
def test_timerDoubleStart(useTimerFast):
|
||||
"""!Try to start a timer twice"""
|
||||
r"""!Try to start a timer twice"""
|
||||
assert useTimerFast.start()
|
||||
assert useTimerFast.start()
|
||||
assert useTimerFast.stop()
|
||||
|
||||
|
||||
def test_timerStopNotStarted(useTimerFast):
|
||||
"""!Try to stop a timer where is not started"""
|
||||
r"""!Try to stop a timer where is not started"""
|
||||
assert useTimerFast.stop()
|
||||
|
||||
|
||||
def test_timerIsRunning(useTimerFast):
|
||||
"""!Check if a timer is running"""
|
||||
r"""!Check if a timer is running"""
|
||||
assert useTimerFast.start()
|
||||
assert useTimerFast.isRunning
|
||||
assert useTimerFast.stop()
|
||||
|
||||
|
||||
def test_timerRun(useTimerFast):
|
||||
"""!Run a timer and check overdue and lostEvents"""
|
||||
r"""!Run a timer and check overdue and lostEvents"""
|
||||
assert useTimerFast.start()
|
||||
time.sleep(0.2)
|
||||
assert useTimerFast.stop()
|
||||
|
|
@ -92,7 +92,7 @@ def test_timerRun(useTimerFast):
|
|||
|
||||
|
||||
def test_timerOverdue(useTimerSlow):
|
||||
"""!Run a timer and check overdue and lostEvents"""
|
||||
r"""!Run a timer and check overdue and lostEvents"""
|
||||
assert useTimerSlow.start()
|
||||
time.sleep(0.2)
|
||||
assert useTimerSlow.stop()
|
||||
|
|
@ -101,7 +101,7 @@ def test_timerOverdue(useTimerSlow):
|
|||
|
||||
|
||||
def test_timerOverdueLong(useTimerSlow):
|
||||
"""!Run a timer and check overdue and lostEvents"""
|
||||
r"""!Run a timer and check overdue and lostEvents"""
|
||||
assert useTimerSlow.start()
|
||||
time.sleep(1)
|
||||
assert useTimerSlow.stop()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""!
|
||||
r"""!
|
||||
____ ____ ______ __ __ __ _____
|
||||
/ __ )/ __ \/ ___/ | / /___ _/ /______/ /_ |__ /
|
||||
/ __ / / / /\__ \| | /| / / __ `/ __/ ___/ __ \ /_ <
|
||||
|
|
@ -31,7 +31,7 @@ def setup_method(method):
|
|||
|
||||
@pytest.fixture
|
||||
def makeDescriptor():
|
||||
"""!Build a descriptor object with loaded configuration"""
|
||||
r"""!Build a descriptor object with loaded configuration"""
|
||||
config = ConfigYAML()
|
||||
assert config.loadConfigFile(paths.TEST_PATH + "test_config.yaml") is True
|
||||
descriptor = Descriptor(config.get("descriptor_test"))
|
||||
|
|
@ -40,33 +40,33 @@ def makeDescriptor():
|
|||
|
||||
@pytest.fixture
|
||||
def makePacket():
|
||||
"""!Build a BW Packet object"""
|
||||
r"""!Build a BW Packet object"""
|
||||
packet = Packet()
|
||||
return packet
|
||||
|
||||
|
||||
def test_descriptorFoundFirst(makeDescriptor, makePacket):
|
||||
"""!Run descriptor on the first entry in list"""
|
||||
r"""!Run descriptor on the first entry in list"""
|
||||
makePacket.set("tone", "12345")
|
||||
makePacket = makeDescriptor.doWork(makePacket)
|
||||
assert makePacket.get("description") == "Test 12345"
|
||||
|
||||
|
||||
def test_descriptorFoundSecond(makeDescriptor, makePacket):
|
||||
"""!Run descriptor on the second entry in list"""
|
||||
r"""!Run descriptor on the second entry in list"""
|
||||
makePacket.set("tone", "23456")
|
||||
makePacket = makeDescriptor.doWork(makePacket)
|
||||
assert makePacket.get("description") == "Test 23456"
|
||||
|
||||
|
||||
def test_descriptorNotFound(makeDescriptor, makePacket):
|
||||
"""!Run descriptor no matching data found"""
|
||||
r"""!Run descriptor no matching data found"""
|
||||
makePacket.set("tone", "99999")
|
||||
makePacket = makeDescriptor.doWork(makePacket)
|
||||
assert makePacket.get("description") == "99999"
|
||||
|
||||
|
||||
def test_descriptorScanFieldNotAvailable(makeDescriptor, makePacket):
|
||||
"""!Run descriptor on a non existent scanField"""
|
||||
r"""!Run descriptor on a non existent scanField"""
|
||||
makePacket = makeDescriptor.doWork(makePacket)
|
||||
assert makePacket.get("description") is None
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""!
|
||||
r"""!
|
||||
____ ____ ______ __ __ __ _____
|
||||
/ __ )/ __ \/ ___/ | / /___ _/ /______/ /_ |__ /
|
||||
/ __ / / / /\__ \| | /| / / __ `/ __/ ___/ __ \ /_ <
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue