- Timestamp:
- Oct 25, 2017 10:58:11 AM (7 years ago)
- Branches:
- master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 1576693
- Parents:
- fe15198
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
test/sasdataloader/test/utest_generic_file_reader_class.py
rbeba407 r3648cbf 17 17 18 18 def setUp(self): 19 self.reader = FileReader()19 self.reader = TestFileReader() 20 20 self.bad_file = "ACB123.txt" 21 21 self.good_file = "123ABC.txt" 22 self.msg = "Unable to find file at: {}\n".format(self.bad_file)23 self.msg += "Please check your file path and try again."24 x = np.zeros(0)25 y = np.zeros(0)26 self.reader.current_dataset = plottable_1D(x, y)27 self.reader.current_datainfo = DataInfo()28 self.reader.send_to_output()29 22 30 23 def test_bad_file_path(self): 31 24 output = self.reader.read(self.bad_file) 32 self.assertEqual(len(output[0].errors), 1) 33 self.assertEqual(output[0].errors[0], self.msg) 25 self.assertEqual(output, []) 34 26 35 27 def test_good_file_path(self): 36 f_open = open(self.good_file, 'w') 37 f_open.close() 28 f = open(self.good_file, 'w') 29 f.write('123ABC exists!') 30 f.close() 38 31 output = self.reader.read(self.good_file) 39 self.assertEqual(len(output [0].errors), 1)40 self.assertEqual(output[0]. errors[0], self.msg)32 self.assertEqual(len(output), 1) 33 self.assertEqual(output[0].meta_data["blah"], '123ABC exists!') 41 34 42 35 def tearDown(self): … … 45 38 if os.path.isfile(self.good_file): 46 39 os.remove(self.good_file) 40 41 class TestFileReader(FileReader): 42 def get_file_contents(self): 43 """ 44 Reader specific class to access the contents of the file 45 All reader classes that inherit from FileReader must implement 46 """ 47 x = np.zeros(0) 48 y = np.zeros(0) 49 self.current_dataset = plottable_1D(x,y) 50 self.current_datainfo = DataInfo() 51 self.current_datainfo.meta_data["blah"] = self.nextline() 52 self.send_to_output()
Note: See TracChangeset
for help on using the changeset viewer.