Skip to content

Commit

Permalink
compabibility with python2 (unicode)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmmaat committed Jul 26, 2018
1 parent afb099c commit e963c0a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions test/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,28 @@
# along with phonemizer. If not, see <http://www.gnu.org/licenses/>.
"""Test of the phonemizer.Phonemizer class"""

import codecs
import pytest
import tempfile
import shlex

from phonemizer import main, festival


def _test(input, output, args=''):
def _test(input, expected_output, args=''):
with tempfile.NamedTemporaryFile('w', delete=False) as finput:
finput.write(input)
finput.seek(0)

with tempfile.NamedTemporaryFile('w+', delete=False) as foutput:
opts = '{} -o {} {}'.format(finput.name, foutput.name, args)
main.main(shlex.split(opts))
assert foutput.read() == output + '\n'
output = foutput.read()
try: # python2 needs additional utf8 decoding
output = output.decode('utf8')
except AttributeError: # python3 is OK
pass
assert output == expected_output + '\n'

def test_help():
with pytest.raises(SystemExit):
Expand Down

0 comments on commit e963c0a

Please sign in to comment.