Skip to content

Commit 0d57449

Browse files
committed
Begin to rationalise test data.
Also refactor to silence some CI issues.
1 parent 067cddd commit 0d57449

3 files changed

Lines changed: 18 additions & 9 deletions

File tree

meshtastic/globals.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
def reset():
1717
"""
18+
Restore the namespace to pristine condition.
1819
"""
1920
global args, parser, channel_index, logfile, tunnelInstance, camel_case
2021
args = None
@@ -25,4 +26,11 @@ def reset():
2526
# TODO: to migrate to camel_case for v1.3 change this value to True
2627
camel_case = False
2728

28-
reset()
29+
# These assignments are used instead of calling reset()
30+
# purely to shut pylint up.
31+
args = None
32+
parser = None
33+
channel_index = None
34+
logfile = None
35+
tunnelInstance = None
36+
camel_case = False

meshtastic/tests/test_mesh_interface.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ def test_MeshInterface(capsys):
2121
"""Test that we can instantiate a MeshInterface"""
2222
iface = MeshInterface(noProto=True)
2323

24-
nodes = {
25-
"!9388f81c": {
26-
"num": 2475227164,
24+
NODE_ID = "!9388f81c"
25+
NODE_NUM = 2475227164
26+
node = {
27+
"num": NODE_NUM,
2728
"user": {
28-
"id": "!9388f81c",
29+
"id": NODE_ID,
2930
"longName": "Unknown f81c",
3031
"shortName": "?1C",
3132
"macaddr": "RBeTiPgc",
@@ -34,10 +35,9 @@ def test_MeshInterface(capsys):
3435
"position": {},
3536
"lastHeard": 1640204888,
3637
}
37-
}
3838

39-
iface.nodesByNum = {2475227164: nodes["!9388f81c"]}
40-
iface.nodes = nodes
39+
iface.nodes = {NODE_ID: node}
40+
iface.nodesByNum = {NODE_NUM: node}
4141

4242
myInfo = MagicMock()
4343
iface.myInfo = myInfo

meshtastic/tests/test_tunnel.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
"""Meshtastic unit tests for tunnel.py"""
2-
from meshtastic import globals
32
import logging
43
import re
54
import sys
65
from unittest.mock import MagicMock, patch
76

87
import pytest
98

9+
from meshtastic import globals
10+
1011
from ..tcp_interface import TCPInterface
1112
from ..tunnel import Tunnel, onTunnelReceive
1213

0 commit comments

Comments
 (0)