Skip to content

Commit 12a217b

Browse files
committed
Adding real_all io unittest, and verbose flag to unittest
1 parent 0d8ccb7 commit 12a217b

File tree

4 files changed

+71
-2
lines changed

4 files changed

+71
-2
lines changed

.github/workflows/development-pipeline.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,4 @@ jobs:
5959
pip install -e .
6060
- name: Tests
6161
run: |
62-
python -m unittest discover
62+
python -m unittest discover -v

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11

22

33
test:
4-
python -m unittest discover
4+
python -m unittest discover -v
326 Bytes
Binary file not shown.
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import unittest
2+
import glob
3+
import openfast_toolbox.io as weio
4+
import os
5+
import numpy as np
6+
from openfast_toolbox.io.tests.helpers_for_test import MyDir, reading_test
7+
8+
class Test(unittest.TestCase):
9+
def test_000_debug(self):
10+
#fileformat,F = weio.detectFormat('_tests/FASTIn_ED_bld.dat')
11+
#F = weio.CSVFile('_tests/CSVComma_Fail.csv')
12+
#F = weio.FASTInFile('../_tests/FASTIn_ExtPtfm_SubSef.dat')
13+
#F = weio.FASTLinFile('../_tests/FASTOutLin_New.lin')
14+
#F = weio.TecplotFile('example_files/TecplotASCII_1.dat')
15+
#dfs=F.toDataFrame()
16+
#print(F.toDataFrame())
17+
#print(F)
18+
#return
19+
#print(fileformat)
20+
pass
21+
22+
def test_001_read_all(self):
23+
DEBUG=True
24+
nError=0
25+
for f in glob.glob(os.path.join(MyDir,'*.*')):
26+
if os.path.splitext(f)[-1] in ['.py','.pyc'] or f.find('_TMP')>0:
27+
continue
28+
try:
29+
fileformat=None
30+
F=None
31+
fileformat,F = weio.detectFormat(f)
32+
#fr=weio.read(f,fileformat)
33+
dfs = F.toDataFrame()
34+
##
35+
if not isinstance(dfs,dict):
36+
if dfs is None:
37+
n = 0
38+
elif len(dfs)==0:
39+
n = 0
40+
else:
41+
n = 1
42+
else:
43+
n=len(dfs)
44+
##print(fr.toDataFrame())
45+
s=fileformat.name
46+
s=s.replace('file','')[:20]
47+
if DEBUG:
48+
print('[ OK ] {:30s}\t{:20s}\t{}'.format(os.path.basename(f)[:30],s,n))
49+
except weio.FormatNotDetectedError:
50+
nError += 1
51+
if DEBUG:
52+
print('[FAIL] {:30s}\tFormat not detected'.format(os.path.basename(f)[:30]))
53+
except weio.OptionalImportError:
54+
nError += 0 # Optional..
55+
if DEBUG:
56+
print('[FAIL] {:30s}\tOptional package missing'.format(os.path.basename(f)[:30]))
57+
except:
58+
nError += 1
59+
if DEBUG:
60+
print('[FAIL] {:30s}\tException occurred'.format(os.path.basename(f)[:30]))
61+
#raise
62+
63+
if nError>0:
64+
raise Exception('Some tests failed')
65+
66+
67+
if __name__ == '__main__':
68+
#Test().test_000_debug()
69+
unittest.main()

0 commit comments

Comments
 (0)