From 22587cf94dd399fc0d1990e16121eeeb99aac7de Mon Sep 17 00:00:00 2001 From: madsmpedersen <m@madsp.dk> Date: Fri, 29 Jan 2016 12:53:34 +0100 Subject: [PATCH] fixed utf8 problem --- wetb/hawc2/htc_file.py | 2 +- .../test_files/htcfiles/continue_in_file.htc | 2 +- wetb/hawc2/tests/test_htc_file.py | 38 +++++++++---------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/wetb/hawc2/htc_file.py b/wetb/hawc2/htc_file.py index e8a7f94..f6f6209 100644 --- a/wetb/hawc2/htc_file.py +++ b/wetb/hawc2/htc_file.py @@ -51,7 +51,7 @@ class HTCFile(HTCContents, HTCDefaults): def readlines(self, filename): self.htc_inputfiles.append(filename) htc_lines = [] - with open(filename, encoding='utf-8') as fid: + with open(filename) as fid: lines = fid.readlines() for l in lines: if l.lower().lstrip().startswith('continue_in_file'): diff --git a/wetb/hawc2/tests/test_files/htcfiles/continue_in_file.htc b/wetb/hawc2/tests/test_files/htcfiles/continue_in_file.htc index 4391a8d..a4f05b7 100644 --- a/wetb/hawc2/tests/test_files/htcfiles/continue_in_file.htc +++ b/wetb/hawc2/tests/test_files/htcfiles/continue_in_file.htc @@ -1,4 +1,4 @@ -begin Simulation; +begin Simulation; time_stop 10 ; solvertype 1 ; (newmark) on_no_convergence continue ; diff --git a/wetb/hawc2/tests/test_htc_file.py b/wetb/hawc2/tests/test_htc_file.py index 04eb595..5699a1c 100644 --- a/wetb/hawc2/tests/test_htc_file.py +++ b/wetb/hawc2/tests/test_htc_file.py @@ -24,25 +24,25 @@ class TestHtcFile(unittest.TestCase): def check_htc_file(self, f): - with open(f) as fid: - orglines = fid.readlines() - - htcfile = HTCFile(f) - newlines = str(htcfile).split("\n") - htcfile.save(self.testfilepath + 'tmp.htc') - #with open(self.testfilepath + 'tmp.htc') as fid: - # newlines = fid.readlines() - - for i, (org, new) in enumerate(zip(orglines, newlines), 1): - fmt = lambda x : x.strip().replace("\t", " ").replace(" ", " ").replace(" ", " ").replace(" ", " ").replace(" ", " ") - if fmt(org) != fmt(new): - print ("----------%d-------------" % i) - print (fmt(org)) - print (fmt(new)) - self.assertEqual(fmt(org), fmt(new)) - break - print () - assert len(orglines) == len(newlines) + with open(f) as fid: + orglines = fid.readlines() + + htcfile = HTCFile(f) + newlines = str(htcfile).split("\n") + htcfile.save(self.testfilepath + 'tmp.htc') + #with open(self.testfilepath + 'tmp.htc') as fid: + # newlines = fid.readlines() + + for i, (org, new) in enumerate(zip(orglines, newlines), 1): + fmt = lambda x : x.strip().replace("\t", " ").replace(" ", " ").replace(" ", " ").replace(" ", " ").replace(" ", " ") + if fmt(org) != fmt(new): + print ("----------%d-------------" % i) + print (fmt(org)) + print (fmt(new)) + self.assertEqual(fmt(org), fmt(new)) + break + print () + assert len(orglines) == len(newlines) def test_htc_files(self): for f in ['test3.htc']: -- GitLab