diff --git a/src/unimacro/natlinkutilsbj.py b/src/unimacro/natlinkutilsbj.py index 43b630e..274a9b9 100644 --- a/src/unimacro/natlinkutilsbj.py +++ b/src/unimacro/natlinkutilsbj.py @@ -1777,7 +1777,7 @@ def showInifile(self, body=None, grammarLists=None, ini=None, #print 'writing to and open:\n\t"%s"'% whatFile t = '\n'.join(L) rwfile = readwritefile.ReadWriteFile() - rwfile.writeAnything(whatFile, t) + rwfile.writeAnything(whatFile, t, encoding='utf-8') self.openFileDefault(whatFile, mode="edit") diff --git a/tests/test_grammar_lines.py b/tests/test_grammar_lines.py index 8efd48b..4bb7682 100644 --- a/tests/test_grammar_lines.py +++ b/tests/test_grammar_lines.py @@ -8,6 +8,10 @@ thisDir = Path(__file__).parent +def do_nothing(*args, **kwargs): + return None + + def test_getLineRelativeTo(): """test the relative to (modulo 100 or modulo 10) trick for getting line numbers """ @@ -45,6 +49,18 @@ def test_getLineRelativeTo(): result = _lines.getLineRelativeTo(relative, currentLine=current, modulo=modulo) assert result == expect +# def test_get_accented_numbers_info(unimacro_setup,monkeypatch): +# """problem with the numbers spoken forms of accented characters +# """ +# +# thisGrammar = _lines.ThisGrammar() +# monkeypatch.setattr(thisGrammar, 'switchOnOrOff', do_nothing) +# thisGrammar.startInifile() #modName = '_lines') +# thisGrammar.initialize() +# thisGrammar.showInifile() +# the showInifile did not show accented characters, seems ok now. +# pass + if __name__ == "__main__": pytest.main(['test_grammar_lines.py']) diff --git a/tests/test_spokenforms.py b/tests/test_spokenforms.py index 4e88439..0e4e38b 100644 --- a/tests/test_spokenforms.py +++ b/tests/test_spokenforms.py @@ -304,7 +304,7 @@ def test_make_mixed_list(unimacro_setup): numbers = spokenforms.SpokenForms('test') L = [1, 2, 4, 5, 6] - got = numbers.getMixedList(L) + # got = numbers.getMixedList(L) expected = ['on\xe9', 'two', 'too', 'four', 'for', 'five', 'six'] assert expected == numbers.getMixedList(L) @@ -312,7 +312,7 @@ def test_make_mixed_list(unimacro_setup): print('\nexpect messages from spokenforms.ini, as language is unknown') m = spokenforms.SpokenForms('othertest') - got = numbers.getMixedList(L) + # got = numbers.getMixedList(L) expected = ['1', '2', '4', '5', '6'] assert expected == m.getMixedList(L) @@ -331,8 +331,8 @@ def test_get_number_back_from_spoken_form(unimacro_setup): numbers = spokenforms.SpokenForms('test') expected = 1 - input = 'on\xe9' - assert expected == numbers.getNumberFromSpoken(input) + Input = 'on\xe9' + assert expected == numbers.getNumberFromSpoken(Input) expected = 5 assert expected == numbers.getNumberFromSpoken(5) @@ -361,12 +361,12 @@ def test_get_number_back_from_spoken_form(unimacro_setup): # originalList ints: originalList = [0,1,2] expected = None - input = 'four' - assert expected == numbers.getNumberFromSpoken(input, originalList) + Input = 'four' + assert expected == numbers.getNumberFromSpoken(Input, originalList) expected = 1 - input = 'on\xe9' - assert expected == numbers.getNumberFromSpoken(input, originalList) + Input = 'on\xe9' + assert expected == numbers.getNumberFromSpoken(Input, originalList) expected = 1 assert expected == numbers.getNumberFromSpoken(1, originalList) expected = None @@ -487,10 +487,10 @@ def test_get_list_of_spoken_forms_sorted_by_number_values(unimacro_setup): def test_format_spoken_forms_from_numbers_dict(unimacro_setup): - """ + """test spoken forms """ func = inivars.formatReverseNumbersDict - assert func({1: ['on\xe9'], 2: ['two'], 3: ['three']}) == 'on\xe9 ... three' + assert func({1: ['oné'], 2: ['two'], 3: ['three']}) == 'oné ... three' def test_get_punctuation_list(unimacro_setup): """test the punctuation from the punctuationreverse section