1 | """ |
---|
2 | Unit tests for fitting module |
---|
3 | """ |
---|
4 | import unittest |
---|
5 | import math |
---|
6 | import DataLoader |
---|
7 | from DataLoader.loader import Loader |
---|
8 | from DataLoader.readers import TXT3_Reader,TXT2_Reader |
---|
9 | from DataLoader.readers import DataReader,danse_reader,tiff_reader |
---|
10 | |
---|
11 | |
---|
12 | |
---|
13 | class testFitModule(unittest.TestCase): |
---|
14 | """ test fitting """ |
---|
15 | def testLoader(self): |
---|
16 | """ |
---|
17 | test module Load |
---|
18 | """ |
---|
19 | L=Loader() |
---|
20 | |
---|
21 | read1=TXT2_Reader.Reader() |
---|
22 | read2=TXT3_Reader.Reader() |
---|
23 | read3=DataReader.Reader() |
---|
24 | read4=danse_reader.Reader() |
---|
25 | read5=tiff_reader.Reader() |
---|
26 | |
---|
27 | L.setFormat('.txt',read1) |
---|
28 | L.setFormat('.txt',read2) |
---|
29 | |
---|
30 | L.setFormat('.dat',read2) |
---|
31 | L.setFormat('.dat',read1) |
---|
32 | |
---|
33 | L.setFormat('.ASC',read3) |
---|
34 | L.setFormat('.sans',read4) |
---|
35 | L.setFormat('.tif',read5) |
---|
36 | L.setFormat('.jpg',read5) |
---|
37 | L.setFormat('.png',read5) |
---|
38 | L.setFormat('.jpeg',read5) |
---|
39 | L.setFormat('.gif',read5) |
---|
40 | L.setFormat('.bmp',read5) |
---|
41 | |
---|
42 | |
---|
43 | self.assertEqual(L.loadData('empty.txt'),None) |
---|
44 | print L.loadData('test_2_columns.txt') |
---|
45 | self.assertEqual( L.getActiveReader('test_2_columns.txt'),DataLoader.readers.TXT2_Reader.Reader) |
---|
46 | print L.loadData('test_3_columns.txt') |
---|
47 | self.assertEqual( L.getActiveReader('test_3_columns.txt'),DataLoader.readers.TXT3_Reader.Reader) |
---|
48 | print L.loadData('test_2_columns.date') |
---|
49 | self.assertEqual( L.getActiveReader('test_2_columns.date'),None) |
---|
50 | print L.loadData('MAR07232_rest.ASC') |
---|
51 | self.assertEqual( L.getActiveReader('MAR07232_rest.ASC'),DataLoader.readers.DataReader.Reader) |
---|
52 | #error test |
---|
53 | print L.loadData('AR07232_rest.ASC') |
---|
54 | self.assertEqual( L.getActiveReader('test_3_columns.txt'),None) |
---|
55 | print L.loadData('MP_New.sans') |
---|
56 | self.assertEqual( L.getActiveReader('MP_New.sans'),DataLoader.readers.read4.Reader) |
---|
57 | print L.loadData('P_New.sans') |
---|
58 | self.assertEqual( L.getActiveReader('P_New.sans'),None) |
---|
59 | print L.loadData('angles_flat.png') |
---|
60 | self.assertEqual(L.getActiveReader('angles_flat.png'),DataLoader.readers.tiff_reader.Reader) |
---|
61 | |
---|
62 | |
---|
63 | |
---|