1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
--- a/tests/test_items.py
+++ b/tests/test_items.py
@@ -4,6 +4,8 @@ import sys
import pytest
+import warnings
+
import hid_parser
@@ -129,13 +131,16 @@ def test_variableitem_compliance():
with pytest.warns(hid_parser.HIDComplianceWarning):
hid_parser.VariableItem(1, 2, 0, hid_parser.Usage(0x0001, 0x0001), -1, 1)
- with pytest.warns(None):
+ with warnings.catch_warnings():
+ warnings.simplefilter("error")
hid_parser.VariableItem(1, 2, 0, hid_parser.Usage(0x0001, 0x0030), -1, 1)
- with pytest.warns(None):
+ with warnings.catch_warnings():
+ warnings.simplefilter("error")
hid_parser.VariableItem(1, 2, 0, hid_parser.Usage(0x0001, 0x0000), -1, 1)
- with pytest.warns(None):
+ with warnings.catch_warnings():
+ warnings.simplefilter("error")
hid_parser.VariableItem(1, 2, 0, hid_parser.Usage(0x0000, 0x0000), -1, 1)
@@ -171,19 +176,27 @@ def test_arrayitem_repr():
def test_arrayitem_compliance():
- usages = [
+ usages_bad = [
hid_parser.Usage(0x0001, 0x0030),
hid_parser.Usage(0x0001, 0x0031),
]
+ usages_good = [
+ hid_parser.Usage(0x0000, 0x0000),
+ hid_parser.Usage(0x0001, 0x0000),
+ ]
+
with pytest.warns(hid_parser.HIDComplianceWarning):
- hid_parser.ArrayItem(1, 2, 0, usages, -1, 1)
+ hid_parser.ArrayItem(1, 2, 0, usages_bad, -1, 1)
- with pytest.warns(None):
- hid_parser.ArrayItem(1, 2, 0, usages, -1, 1)
+ with warnings.catch_warnings():
+ warnings.simplefilter("error")
+ hid_parser.ArrayItem(1, 2, 0, usages_good, -1, 1)
- with pytest.warns(None):
- hid_parser.ArrayItem(1, 2, 0, usages, -1, 1)
+ with warnings.catch_warnings():
+ warnings.simplefilter("error")
+ hid_parser.ArrayItem(1, 2, 0, usages_good, -1, 1)
- with pytest.warns(None):
- hid_parser.ArrayItem(1, 2, 0, usages, -1, 1)
+ with warnings.catch_warnings():
+ warnings.simplefilter("error")
+ hid_parser.ArrayItem(1, 2, 0, usages_good, -1, 1)
|