Skip to content

Commit dd4fccb

Browse files
committed
Add a fairly simple property-based test as a starting point
1 parent 32682b5 commit dd4fccb

3 files changed

Lines changed: 18 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ venv/
1515
__pycache__
1616
examples/__pycache__
1717
meshtastic.spec
18+
.hypothesis/

meshtastic/tests/test_util.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from unittest.mock import patch
77

88
import pytest
9+
from hypothesis import given, strategies as st
910

1011
from meshtastic.supported_device import SupportedDevice
1112
from meshtastic.mesh_pb2 import MyNodeInfo
@@ -577,3 +578,18 @@ def test_acknowledgement_reset():
577578
assert test_ack_obj.receivedTraceRoute is False
578579
assert test_ack_obj.receivedTelemetry is False
579580
assert test_ack_obj.receivedPosition is False
581+
582+
@given(a_string=st.text(
583+
alphabet=st.characters(
584+
codec='ascii',
585+
min_codepoint=0x5F,
586+
max_codepoint=0x7A,
587+
exclude_characters=r'`',
588+
)).filter(
589+
lambda x: x not in [''] and x[0] not in "_" and x[-1] not in '_' and not re.search(r'__', x)
590+
))
591+
def test_roundtrip_snake_to_camel_camel_to_snake(a_string):
592+
value0 = snake_to_camel(a_string=a_string)
593+
value1 = camel_to_snake(a_string=value0)
594+
assert a_string == value1, (a_string, value1)
595+

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ autopep8
1414
pylint
1515
pytest
1616
pytest-cov
17+
hypothesis
1718
pyyaml
1819
pytap2
1920
pdoc3

0 commit comments

Comments
 (0)