mirror of
https://github.com/BOSWatch/BW3-Core.git
synced 2026-04-05 14:25:45 +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"""!
|
||||
____ ____ ______ __ __ __ _____
|
||||
/ __ )/ __ \/ ___/ | / /___ _/ /______/ /_ |__ /
|
||||
/ __ / / / /\__ \| | /| / / __ `/ __/ ___/ __ \ /_ <
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue