44"""
55
66import unittest
7+ import pytest
78
89import numpy
910
1011from diffpy .utils .parsers import loadData
11- from diffpy .utils .tests .testhelpers import datafile
12-
13- loaddata01 = datafile ("loaddata01.txt" )
14- loaddatawithheaders = datafile ("loaddatawithheaders.txt" )
1512
1613
1714##############################################################################
1815class TestLoadData (unittest .TestCase ):
16+ @pytest .fixture (autouse = True )
17+ def prepare_fixture (self , datafile ):
18+ self .datafile = datafile
19+
1920 def test_loadData_default (self ):
2021 """check loadData() with default options"""
22+ loaddata01 = self .datafile ("loaddata01.txt" )
2123 d2c = numpy .array ([[3 , 31 ], [4 , 32 ], [5 , 33 ]])
2224 self .assertRaises (IOError , loadData , "doesnotexist" )
2325 # the default minrows=10 makes it read from the third line
@@ -35,6 +37,7 @@ def test_loadData_default(self):
3537
3638 def test_loadData_1column (self ):
3739 """check loading of one-column data."""
40+ loaddata01 = self .datafile ("loaddata01.txt" )
3841 d1c = numpy .arange (1 , 6 )
3942 d = loadData (loaddata01 , usecols = [0 ], minrows = 1 )
4043 self .assertTrue (numpy .array_equal (d1c , d ))
@@ -46,6 +49,7 @@ def test_loadData_1column(self):
4649
4750 def test_loadData_headers (self ):
4851 """check loadData() with headers options enabled"""
52+ loaddatawithheaders = self .datafile ("loaddatawithheaders.txt" )
4953 hignore = ["# " , "// " , "[" ] # ignore lines beginning with these strings
5054 delimiter = ": " # what our data should be separated by
5155 hdata = loadData (loaddatawithheaders , headers = True , hdel = delimiter , hignore = hignore )
0 commit comments