test exotic input files

This commit is contained in:
Martin Diehl 2019-12-05 05:57:47 +01:00
parent 5fdf112f78
commit 2172e92e7e
3 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,4 @@
1 header
a b
1.0 hallo
0.1 "hallo test"

View File

@ -0,0 +1,6 @@
1 header
a b 1_c 2_c
1 2 3 4
5 6 7 8
9 10. 12. 12

View File

@ -1,14 +1,21 @@
import os
import pytest
import numpy as np
from damask import Table
@pytest.fixture
def default():
"""Simple Table."""
x = np.ones((5,13))
return Table(x,{'F':(3,3),'v':(3,),'s':(1,)},['test data','contains only ones'])
@pytest.fixture
def reference_dir(reference_dir_base):
"""Directory containing reference results."""
return os.path.join(reference_dir_base,'Table')
class TestTable:
@ -31,6 +38,11 @@ class TestTable:
with open(tmpdir.join('default.txt')) as f:
new = Table.from_ASCII(f)
assert all(default.data==new.data)
@pytest.mark.parametrize('fname',['datatype-mix.txt','whitespace-mix.txt'])
def test_read_strange(self,reference_dir,fname):
with open(os.path.join(reference_dir,fname)) as f:
new = Table.from_ASCII(f)
def test_set_array(self,default):
default.set_array('F',np.zeros((5,3,3)),'set to zero')