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
|
import pytest
from qolab.hardware.scpi import response2numStr
def test_separator_and_unit():
assert response2numStr("TDIV 2.00E-08S", firstSeparator=" ", unit="Z") == (
"TDIV",
"2.00E-08S",
None,
) # incorrect unit was specified
assert response2numStr("TDIV 2.00E-08S", firstSeparator=" ", unit="S") == (
"TDIV",
"2.00E-08",
"S",
)
assert response2numStr("TDIV,2.00E-08S", firstSeparator=",", unit="S") == (
"TDIV",
"2.00E-08",
"S",
)
def test_separator_and_empty_unit():
assert response2numStr("TDIV,2.00E-08", firstSeparator=",", unit=None) == (
"TDIV",
"2.00E-08",
None,
)
assert response2numStr("TDIV,2.00E-08", firstSeparator=",", unit="") == (
"TDIV",
"2.00E-08",
"",
)
def test_no_separator_with_unit():
assert response2numStr("2.00E-08S", firstSeparator=None, unit="S") == (
None,
"2.00E-08",
"S",
)
assert response2numStr("2.00E-08S", firstSeparator="", unit="S") == (
None,
"2.00E-08",
"S",
)
def test_no_separator_and_no_unit():
assert response2numStr("2.00E-08", firstSeparator=None, unit=None) == (
None,
"2.00E-08",
None,
)
assert response2numStr("2.00E-08", firstSeparator="", unit="") == (
None,
"2.00E-08",
"",
)
|