@@ -14,8 +14,9 @@ def test_loadData_default(datafile):
14
14
loaddata01 = datafile ("loaddata01.txt" )
15
15
d2c = np .array ([[3 , 31 ], [4 , 32 ], [5 , 33 ]])
16
16
17
- with pytest .raises (IOError ):
17
+ with pytest .raises (IOError ) as err :
18
18
loadData ("doesnotexist" )
19
+ assert "No such file or directory" in str (err .value )
19
20
20
21
# The default minrows=10 makes it read from the third line
21
22
d = loadData (loaddata01 )
@@ -51,22 +52,27 @@ def test_loadData_1column(datafile):
51
52
52
53
def test_loadData_headers (datafile ):
53
54
"""check loadData() with headers options enabled"""
55
+ expected = {
56
+ "wavelength" : 0.1 ,
57
+ "dataformat" : "Qnm" ,
58
+ "inputfile" : "darkSub_rh20_C_01.chi" ,
59
+ "mode" : "xray" ,
60
+ "bgscale" : 1.2998929285 ,
61
+ "composition" : "0.800.20" ,
62
+ "outputtype" : "gr" ,
63
+ "qmaxinst" : 25.0 ,
64
+ "qmin" : 0.1 ,
65
+ "qmax" : 25.0 ,
66
+ "rmax" : "100.0r" ,
67
+ "rmin" : "0.0r" ,
68
+ "rstep" : "0.01r" ,
69
+ "rpoly" : "0.9r" ,
70
+ }
71
+
54
72
loaddatawithheaders = datafile ("loaddatawithheaders.txt" )
55
73
hignore = ["# " , "// " , "[" ] # ignore lines beginning with these strings
56
74
delimiter = ": " # what our data should be separated by
57
75
58
76
# Load data with headers
59
77
hdata = loadData (loaddatawithheaders , headers = True , hdel = delimiter , hignore = hignore )
60
-
61
- # Only fourteen lines of data are formatted properly
62
- assert len (hdata ) == 14
63
-
64
- # Check the following are floats
65
- vfloats = ["wavelength" , "qmaxinst" , "qmin" , "qmax" , "bgscale" ]
66
- for name in vfloats :
67
- assert isinstance (hdata .get (name ), float )
68
-
69
- # Check the following are NOT floats
70
- vnfloats = ["composition" , "rmax" , "rmin" , "rstep" , "rpoly" ]
71
- for name in vnfloats :
72
- assert not isinstance (hdata .get (name ), float )
78
+ assert hdata == expected
0 commit comments