fix for new style and test

This commit is contained in:
Martin Diehl 2020-01-26 10:17:27 +01:00
parent 7f92418fc4
commit 6fed655500
2 changed files with 8 additions and 1 deletions

View File

@ -74,7 +74,7 @@ class Table():
f.seek(0) f.seek(0)
try: try:
N_comment_lines,keyword = f.readline().split() N_comment_lines,keyword = f.readline().strip().split(maxsplit=1)
if keyword != 'header': if keyword != 'header':
raise TypeError raise TypeError
else: else:

View File

@ -47,6 +47,13 @@ class TestTable:
new = Table.from_ASCII(f) new = Table.from_ASCII(f)
assert all(default.data==new.data) and default.shapes == new.shapes assert all(default.data==new.data) and default.shapes == new.shapes
def test_write_read_new_style(self,default,tmpdir):
with open(tmpdir.join('new_style.txt'),'w') as f:
default.to_ASCII(f,new=True)
with open(tmpdir.join('new_style.txt')) as f:
new = Table.from_ASCII(f)
assert all(default.data==new.data) and default.shapes == new.shapes
def test_read_ang_str(self,reference_dir): def test_read_ang_str(self,reference_dir):
new = Table.from_ang(os.path.join(reference_dir,'simple.ang')) new = Table.from_ang(os.path.join(reference_dir,'simple.ang'))
assert new.data.shape == (4,10) and \ assert new.data.shape == (4,10) and \