@@ -14,8 +14,9 @@ def test_loadData_default(datafile):
1414 loaddata01 = datafile ("loaddata01.txt" )
1515 d2c = np .array ([[3 , 31 ], [4 , 32 ], [5 , 33 ]])
1616
17- with pytest .raises (IOError ):
17+ with pytest .raises (IOError ) as err :
1818 loadData ("doesnotexist" )
19+ assert "No such file or directory" in str (err .value )
1920
2021 # The default minrows=10 makes it read from the third line
2122 d = loadData (loaddata01 )
@@ -51,22 +52,27 @@ def test_loadData_1column(datafile):
5152
5253def test_loadData_headers (datafile ):
5354 """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+
5472 loaddatawithheaders = datafile ("loaddatawithheaders.txt" )
5573 hignore = ["# " , "// " , "[" ] # ignore lines beginning with these strings
5674 delimiter = ": " # what our data should be separated by
5775
5876 # Load data with headers
5977 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