Skip to content

Commit 847bcf1

Browse files
committed
Fixed missing annotations in tests
1 parent 9a55815 commit 847bcf1

File tree

8 files changed

+40
-41
lines changed

8 files changed

+40
-41
lines changed

tests/helpers_geocom.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class DummyGeoComConnection(Connection):
2525
r"(?:(?P<params>.*))?$"
2626
)
2727

28-
def send(self, message: str):
28+
def send(self, message: str) -> None:
2929
return
3030

3131
def exchange(self, cmd: str) -> str:
@@ -40,7 +40,7 @@ def exchange(self, cmd: str) -> str:
4040

4141
class GeoComTester:
4242
@staticmethod
43-
def test_parse_response(instrument: GeoComProtocol):
43+
def test_parse_response(instrument: GeoComProtocol) -> None:
4444
cmd = "%R1Q,5008:"
4545
answer = "%R1P,0,0:0,1996,'07','19','10','13','2f'"
4646
parsers: Iterable[Callable[[str], Any]] = (
@@ -65,7 +65,6 @@ def test_parse_response(instrument: GeoComProtocol):
6565
parsers
6666
)
6767
assert response.params is None
68-
# assert len(response.params) == 0
6968

7069
parsers_faulty = (
7170
faulty_parser,
@@ -83,7 +82,7 @@ def test_parse_response(instrument: GeoComProtocol):
8382
assert response.params is None
8483

8584
@staticmethod
86-
def test_request(instrument: GeoComProtocol):
85+
def test_request(instrument: GeoComProtocol) -> None:
8786
response = instrument.request(
8887
5008,
8988
parsers=(

tests/helpers_gsionline.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class DummyGsiOnlineConnection(Connection):
2424
r"(?:[a-zA-Z0-9]{8}|[a-zA-Z0-9]{16}) $"
2525
)
2626

27-
def __init__(self, gsi16=False):
27+
def __init__(self, gsi16: bool = False):
2828
self._gsi16 = gsi16
2929

3030
def exchange(self, cmd: str) -> str:
@@ -53,14 +53,14 @@ def exchange(self, cmd: str) -> str:
5353

5454
class GsiOnlineTester:
5555
@staticmethod
56-
def test_request(instrument: GsiOnlineProtocol):
56+
def test_request(instrument: GsiOnlineProtocol) -> None:
5757
response = instrument.request("d")
5858
assert not response.value
5959
response = instrument.request("a")
6060
assert response.value
6161

6262
@staticmethod
63-
def test_setrequest(instrument: GsiOnlineProtocol):
63+
def test_setrequest(instrument: GsiOnlineProtocol) -> None:
6464
response = instrument.setrequest(0, 0)
6565
assert not response.value
6666
assert response.comment == "INSTRUMENT"
@@ -70,7 +70,7 @@ def test_setrequest(instrument: GsiOnlineProtocol):
7070
assert response.value
7171

7272
@staticmethod
73-
def test_confrequest(instrument: GsiOnlineProtocol):
73+
def test_confrequest(instrument: GsiOnlineProtocol) -> None:
7474
response = instrument.confrequest(0, int)
7575
assert not response.value
7676
assert response.comment == "INSTRUMENT"
@@ -86,7 +86,7 @@ def test_confrequest(instrument: GsiOnlineProtocol):
8686
assert response.value == 0
8787

8888
@staticmethod
89-
def test_putrequest(instrument: GsiOnlineProtocol):
89+
def test_putrequest(instrument: GsiOnlineProtocol) -> None:
9090
response = instrument.putrequest(0, "0.....+00000000 ")
9191
assert not response.value
9292
assert response.comment == "INSTRUMENT"
@@ -96,7 +96,7 @@ def test_putrequest(instrument: GsiOnlineProtocol):
9696
assert response.value
9797

9898
@staticmethod
99-
def test_getrequest(instrument: GsiOnlineProtocol):
99+
def test_getrequest(instrument: GsiOnlineProtocol) -> None:
100100
response = instrument.getrequest("I", 0, int)
101101
assert response.value is None
102102
assert response.response == "@W427"

tests/test_data.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,21 @@ class A(Enum):
2121

2222

2323
class TestFunctions:
24-
def test_toenum(self):
24+
def test_toenum(self) -> None:
2525
assert toenum(A, "MEMBER") is A.MEMBER
2626
assert toenum(A, A.MEMBER) is A.MEMBER
2727

28-
def test_enumparser(self):
28+
def test_enumparser(self) -> None:
2929
assert callable(enumparser(A))
3030
assert enumparser(A)("1") is A.MEMBER
3131

32-
def test_parsestr(self):
32+
def test_parsestr(self) -> None:
3333
assert parsestr("value") == "value"
3434
assert parsestr("\"value") == "\"value"
3535
assert parsestr("value\"") == "value\""
3636
assert parsestr("\"value\"") == "value"
3737

38-
def test_gsiword(self):
38+
def test_gsiword(self) -> None:
3939
assert gsiword(11, "1") == "11....+00000001 "
4040
assert gsiword(11, "1", gsi16=True) == "*11....+0000000000000001 "
4141
assert gsiword(
@@ -47,7 +47,7 @@ def test_gsiword(self):
4747

4848

4949
class TestAngle:
50-
def test_init(self):
50+
def test_init(self) -> None:
5151
assert float(Angle(1)) == approx(float(Angle(1, AngleUnit.RAD)))
5252

5353
units = AngleUnit._member_names_.copy()
@@ -60,12 +60,12 @@ def test_init(self):
6060
== approx(float(Angle(1, unit)))
6161
)
6262

63-
def test_asunit(self):
63+
def test_asunit(self) -> None:
6464
value = Angle(180, 'DEG')
6565
assert value.asunit('DEG') == approx(180)
6666
assert value.asunit() == value.asunit('RAD')
6767

68-
def test_normalize(self):
68+
def test_normalize(self) -> None:
6969
assert (
7070
Angle(
7171
370,
@@ -98,7 +98,7 @@ def test_normalize(self):
9898
== approx(Angle(370, 'DEG').normalized().asunit('DEG'))
9999
)
100100

101-
def test_arithmetic(self):
101+
def test_arithmetic(self) -> None:
102102
a1 = Angle(90, 'DEG')
103103
a2 = Angle(90, 'DEG')
104104
assert (
@@ -125,21 +125,21 @@ def test_arithmetic(self):
125125

126126

127127
class TestByte:
128-
def test_init(self):
128+
def test_init(self) -> None:
129129
with pytest.raises(ValueError):
130130
Byte(-1)
131131

132132
with pytest.raises(ValueError):
133133
Byte(256)
134134

135-
def test_str(self):
135+
def test_str(self) -> None:
136136
value = Byte(12)
137137
assert int(value) == 12
138138
assert str(value) == "'0C'"
139139

140140

141141
class TestCoordinate:
142-
def test_init(self):
142+
def test_init(self) -> None:
143143
value = Coordinate(1, 2, 3)
144144
assert value.x == 1
145145
assert value.y == 2
@@ -148,7 +148,7 @@ def test_init(self):
148148
x, _, _ = value
149149
assert x == value.x
150150

151-
def test_arithmetic(self):
151+
def test_arithmetic(self) -> None:
152152
c1 = Coordinate(1, 1, 1)
153153
c2 = Coordinate(1, 2, 3)
154154

@@ -158,7 +158,7 @@ def test_arithmetic(self):
158158
c3 = +c1
159159
assert c3 is not c1
160160

161-
def test_polar(self):
161+
def test_polar(self) -> None:
162162
c1 = Coordinate(-1, -1, -1)
163163
p1 = c1.to_polar()
164164

tests/test_dna.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def dna() -> DNA:
1515

1616

1717
class TestDNA:
18-
def test_init(self):
18+
def test_init(self) -> None:
1919
conn_bad = Connection()
2020
with pytest.raises(ConnectionError):
2121
DNA(conn_bad, retry=1)
@@ -24,17 +24,17 @@ def test_init(self):
2424
dna = DNA(conn_good)
2525
assert dna._gsi16
2626

27-
def test_request(self, dna: DNA):
27+
def test_request(self, dna: DNA) -> None:
2828
GsiOnlineTester.test_request(dna)
2929

30-
def test_setrequest(self, dna: DNA):
30+
def test_setrequest(self, dna: DNA) -> None:
3131
GsiOnlineTester.test_setrequest(dna)
3232

33-
def test_confrequest(self, dna: DNA):
33+
def test_confrequest(self, dna: DNA) -> None:
3434
GsiOnlineTester.test_confrequest(dna)
3535

36-
def test_putrequest(self, dna: DNA):
36+
def test_putrequest(self, dna: DNA) -> None:
3737
GsiOnlineTester.test_putrequest(dna)
3838

39-
def test_getrequest(self, dna: DNA):
39+
def test_getrequest(self, dna: DNA) -> None:
4040
GsiOnlineTester.test_getrequest(dna)

tests/test_tps1000.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def tps() -> TPS1000:
1515

1616

1717
class TestTPS1000:
18-
def test_init(self):
18+
def test_init(self) -> None:
1919
conn_bad = Connection()
2020
with pytest.raises(ConnectionError):
2121
TPS1000(conn_bad, retry=1)
@@ -24,8 +24,8 @@ def test_init(self):
2424
instrument = TPS1000(conn_good)
2525
assert instrument._precision == 15
2626

27-
def test_parse_response(self, tps: TPS1000):
27+
def test_parse_response(self, tps: TPS1000) -> None:
2828
GeoComTester.test_parse_response(tps)
2929

30-
def test_request(self, tps: TPS1000):
30+
def test_request(self, tps: TPS1000) -> None:
3131
GeoComTester.test_request(tps)

tests/test_tps1100.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def tps() -> TPS1100:
1515

1616

1717
class TestTPS1100:
18-
def test_init(self):
18+
def test_init(self) -> None:
1919
conn_bad = Connection()
2020
with pytest.raises(ConnectionError):
2121
TPS1100(conn_bad, retry=1)
@@ -24,8 +24,8 @@ def test_init(self):
2424
instrument = TPS1100(conn_good)
2525
assert instrument._precision == 15
2626

27-
def test_parse_response(self, tps: TPS1100):
27+
def test_parse_response(self, tps: TPS1100) -> None:
2828
GeoComTester.test_parse_response(tps)
2929

30-
def test_request(self, tps: TPS1100):
30+
def test_request(self, tps: TPS1100) -> None:
3131
GeoComTester.test_request(tps)

tests/test_tps1200p.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def tps() -> TPS1200P:
1515

1616

1717
class TestTPS1200P:
18-
def test_init(self):
18+
def test_init(self) -> None:
1919
conn_bad = Connection()
2020
with pytest.raises(ConnectionError):
2121
TPS1200P(conn_bad, retry=1)
@@ -24,8 +24,8 @@ def test_init(self):
2424
instrument = TPS1200P(conn_good)
2525
assert instrument._precision == 15
2626

27-
def test_parse_response(self, tps: TPS1200P):
27+
def test_parse_response(self, tps: TPS1200P) -> None:
2828
GeoComTester.test_parse_response(tps)
2929

30-
def test_request(self, tps: TPS1200P):
30+
def test_request(self, tps: TPS1200P) -> None:
3131
GeoComTester.test_request(tps)

tests/test_vivatps.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def tps() -> VivaTPS:
1515

1616

1717
class TestVivaTPS:
18-
def test_init(self):
18+
def test_init(self) -> None:
1919
conn_bad = Connection()
2020
with pytest.raises(ConnectionError):
2121
VivaTPS(conn_bad, retry=1)
@@ -24,8 +24,8 @@ def test_init(self):
2424
instrument = VivaTPS(conn_good)
2525
assert instrument._precision == 15
2626

27-
def test_parse_response(self, tps: VivaTPS):
27+
def test_parse_response(self, tps: VivaTPS) -> None:
2828
GeoComTester.test_parse_response(tps)
2929

30-
def test_request(self, tps: VivaTPS):
30+
def test_request(self, tps: VivaTPS) -> None:
3131
GeoComTester.test_request(tps)

0 commit comments

Comments
 (0)