From 79a3d02b7ca5df27e7f4943ed1e395a98148499b Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Tue, 28 Mar 2017 13:15:30 -0700 Subject: [PATCH 01/12] Locale tests redo --- tests/test_locale/file_dialog.py | 93 +++++++++++++++++++ tests/test_locale/readme.md | 1 + .../test_Pyfa/test_codec_english.py | 36 +++++++ tests/test_locale/test_Pyfa/testcodec | 1 + tests/test_locale/test_os_walk.py | 32 +++++++ .../test_codec_russian.py" | 30 ++++++ .../testcodec" | 1 + .../test_codec_hebrew.py" | 30 ++++++ .../testcodec" | 1 + .../test_codec_chinese_simplified.py" | 30 ++++++ .../test_\346\265\213\350\257\225/testcodec" | 1 + .../test_codec_russian.py" | 30 ++++++ .../testcodec" | 1 + 13 files changed, 287 insertions(+) create mode 100644 tests/test_locale/file_dialog.py create mode 100644 tests/test_locale/readme.md create mode 100644 tests/test_locale/test_Pyfa/test_codec_english.py create mode 100644 tests/test_locale/test_Pyfa/testcodec create mode 100644 tests/test_locale/test_os_walk.py create mode 100644 "tests/test_locale/test_\320\267\320\275\320\260\321\204/test_codec_russian.py" create mode 100644 "tests/test_locale/test_\320\267\320\275\320\260\321\204/testcodec" create mode 100644 "tests/test_locale/test_\327\244\327\230\327\233\327\251/test_codec_hebrew.py" create mode 100644 "tests/test_locale/test_\327\244\327\230\327\233\327\251/testcodec" create mode 100644 "tests/test_locale/test_\346\265\213\350\257\225/test_codec_chinese_simplified.py" create mode 100644 "tests/test_locale/test_\346\265\213\350\257\225/testcodec" create mode 100644 "tests/test_locale/\320\267\320\275\320\260\321\204/test_codec_russian.py" create mode 100644 "tests/test_locale/\320\267\320\275\320\260\321\204/testcodec" diff --git a/tests/test_locale/file_dialog.py b/tests/test_locale/file_dialog.py new file mode 100644 index 0000000000..6ef38f12a6 --- /dev/null +++ b/tests/test_locale/file_dialog.py @@ -0,0 +1,93 @@ +# noinspection PyPackageRequirements +import wx +import sys +import os +import sys + +script_dir = os.path.dirname(os.path.abspath(__file__)) +# Add root to python paths, this allows us to import submodules +sys.path.append(os.path.realpath(os.path.join(script_dir, '..', '..'))) + +from _development.helpers_locale import GetPath, GetUnicodePath + +class MyForm(wx.Frame): + # ---------------------------------------------------------------------- + def __init__(self): + wx.Frame.__init__(self, None, wx.ID_ANY, "CTRL-O to open, CTRL-S to save", size=(500, 500)) + + # Add a panel so it looks the correct on all platforms + panel = wx.Panel(self, wx.ID_ANY) + + SAVE_FILE_ID = wx.NewId() + self.Bind(wx.EVT_MENU, self.saveFile, id=SAVE_FILE_ID) + + LOAD_FILE_ID = wx.NewId() + self.Bind(wx.EVT_MENU, self.loadFile, id=LOAD_FILE_ID) + + accel_tbl = wx.AcceleratorTable([(wx.ACCEL_CTRL, ord('O'), LOAD_FILE_ID), + (wx.ACCEL_CTRL, ord('S'), SAVE_FILE_ID)] + ) + self.SetAcceleratorTable(accel_tbl) + + # ---------------------------------------------------------------------- + def loadFile(self, event): + openFileDialog = wx.FileDialog(self, "Open", "", "", + "Python files (*.py)|*.py", + wx.FD_OPEN | wx.FD_FILE_MUST_EXIST) + openFileDialog.ShowModal() + path = openFileDialog.GetPath() + try: + os_walk_without_codec = GetPath(path) + except (UnicodeEncodeError, UnicodeTranslateError, UnicodeError, UnicodeDecodeError, UnicodeWarning, TypeError) as e: + os_walk_without_codec = e + + try: + os_walk_with_system_codec = GetPath(path, None, sys.getdefaultencoding()) + except (UnicodeEncodeError, UnicodeTranslateError, UnicodeError, UnicodeDecodeError, UnicodeWarning, TypeError) as e: + os_walk_with_system_codec = e + + try: + os_walk_unicode_without_codec = GetUnicodePath(path) + except (UnicodeEncodeError, UnicodeTranslateError, UnicodeError, UnicodeDecodeError, UnicodeWarning, TypeError) as e: + os_walk_unicode_without_codec = e + + try: + os_walk_unicode_with_system_codec = GetUnicodePath(path, None, sys.getdefaultencoding()) + except (UnicodeEncodeError, UnicodeTranslateError, UnicodeError, UnicodeDecodeError, UnicodeWarning, TypeError) as e: + os_walk_unicode_with_system_codec = e + + print("Simple print:") + print(path) + + print("Type:") + print(type(path)) + + print("OS Walk: No Codec:") + print(os_walk_without_codec) + + print("OS Walk: Default System Codec:") + print(os_walk_with_system_codec) + + print("OS Unicode Walk: No Codec:") + print(os_walk_unicode_without_codec) + + print("OS Unicode Walk: Default System Codec:") + print(os_walk_unicode_with_system_codec) + openFileDialog.Destroy() + + # ---------------------------------------------------------------------- + def saveFile(self, event): + saveFileDialog = wx.FileDialog(self, "Save As", "", "", + "Python files (*.py)|*.py", + wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT) + saveFileDialog.ShowModal() + saveFileDialog.GetPath() + saveFileDialog.Destroy() + + +# Run the program +if __name__ == "__main__": + app = wx.App(False) + frame = MyForm() + frame.Show() + app.MainLoop() diff --git a/tests/test_locale/readme.md b/tests/test_locale/readme.md new file mode 100644 index 0000000000..bf413bae36 --- /dev/null +++ b/tests/test_locale/readme.md @@ -0,0 +1 @@ +Use this to dynamically test languages. \ No newline at end of file diff --git a/tests/test_locale/test_Pyfa/test_codec_english.py b/tests/test_locale/test_Pyfa/test_codec_english.py new file mode 100644 index 0000000000..6a129aa3f1 --- /dev/null +++ b/tests/test_locale/test_Pyfa/test_codec_english.py @@ -0,0 +1,36 @@ +# English + +import os +import platform +import sys + +script_dir = os.path.dirname(os.path.abspath(__file__)) +# Add root to python paths, this allows us to import submodules +sys.path.append(os.path.realpath(os.path.join(script_dir, '..', '..'))) + +from _development.helpers_locale import GetPath + + +def test_codec_english(): + use_codec = { + "Windows": "cp1252", + "Linux" : "utf8", + "Darwin" : "utf8", + } + + os_name = platform.system() + current_directory = os.path.dirname(os.path.abspath(__file__)) + + try: + decoded_file = GetPath(current_directory, "testcodec", use_codec[os_name]) + except: + assert False, "Specified codec (" + use_codec[os_name] + ") failed to decrypt file path." + + try: + with open(decoded_file, 'r') as f: + read_data = f.read() + f.closed + except: + assert False, "Specified codec (" + use_codec[os_name] + ") failed to read file." + + assert read_data == "True" diff --git a/tests/test_locale/test_Pyfa/testcodec b/tests/test_locale/test_Pyfa/testcodec new file mode 100644 index 0000000000..4791ed5559 --- /dev/null +++ b/tests/test_locale/test_Pyfa/testcodec @@ -0,0 +1 @@ +True \ No newline at end of file diff --git a/tests/test_locale/test_os_walk.py b/tests/test_locale/test_os_walk.py new file mode 100644 index 0000000000..90fffed0eb --- /dev/null +++ b/tests/test_locale/test_os_walk.py @@ -0,0 +1,32 @@ +import os +import sys + +script_dir = os.path.dirname(os.path.abspath(__file__)) +# Add root to python paths, this allows us to import submodules +sys.path.append(os.path.realpath(os.path.join(script_dir, '..', '..'))) + +from _development.helpers_locale import GetPath + +def test_os_walk(): + current_directory = os.path.dirname(os.path.abspath(unicode(__file__))) + subfolders = os.listdir(current_directory) + subfolders = [e for e in subfolders if not (e.endswith(".py") or e.endswith(".pyc") or e.endswith(".md"))] + + subfolder_count = 0 + for subfolder in subfolders: + subdir = GetPath(current_directory, subfolder) + testfile = GetPath(subdir, "testcodec") + + # noinspection PyBroadException + try: + with open(testfile, 'r') as f: + read_data = f.read() + # noinspection PyStatementEffect + f.closed + except: + assert False, "Failed to read file." + + assert read_data == "True" + subfolder_count += 1 + + assert len(subfolders) == subfolder_count diff --git "a/tests/test_locale/test_\320\267\320\275\320\260\321\204/test_codec_russian.py" "b/tests/test_locale/test_\320\267\320\275\320\260\321\204/test_codec_russian.py" new file mode 100644 index 0000000000..30dd8c709e --- /dev/null +++ "b/tests/test_locale/test_\320\267\320\275\320\260\321\204/test_codec_russian.py" @@ -0,0 +1,30 @@ +# Russian + +import os +import platform +from tests.test_locale.locale_functions import GetPath + + +def test_codec_russian(): + use_codec = { + "Windows": "cp1251", + "Linux" : "utf8", + "Darwin" : "mac_cyrillic", + } + + os_name = platform.system() + current_directory = os.path.dirname(os.path.abspath(__file__)) + + try: + decoded_file = GetPath(current_directory, "testcodec", use_codec[os_name]) + except: + assert False, "Specified codec (" + use_codec[os_name] + ") failed to decrypt file path." + + try: + with open(decoded_file, 'r') as f: + read_data = f.read() + f.closed + except: + assert False, "Specified codec (" + use_codec[os_name] + ") failed to read file." + + assert read_data == "True" diff --git "a/tests/test_locale/test_\320\267\320\275\320\260\321\204/testcodec" "b/tests/test_locale/test_\320\267\320\275\320\260\321\204/testcodec" new file mode 100644 index 0000000000..4791ed5559 --- /dev/null +++ "b/tests/test_locale/test_\320\267\320\275\320\260\321\204/testcodec" @@ -0,0 +1 @@ +True \ No newline at end of file diff --git "a/tests/test_locale/test_\327\244\327\230\327\233\327\251/test_codec_hebrew.py" "b/tests/test_locale/test_\327\244\327\230\327\233\327\251/test_codec_hebrew.py" new file mode 100644 index 0000000000..d6c94812de --- /dev/null +++ "b/tests/test_locale/test_\327\244\327\230\327\233\327\251/test_codec_hebrew.py" @@ -0,0 +1,30 @@ +# Hebrew + +import os +import platform +from tests.test_locale.locale_functions import GetPath + + +def test_codec_hebrew(): + use_codec = { + "Windows": "cp1252", + "Linux" : "utf8", + "Darwin" : "utf8", + } + + os_name = platform.system() + current_directory = os.path.dirname(os.path.abspath(__file__)) + + try: + decoded_file = GetPath(current_directory, "testcodec", use_codec[os_name]) + except: + assert False, "Specified codec (" + use_codec[os_name] + ") failed to decrypt file path." + + try: + with open(decoded_file, 'r') as f: + read_data = f.read() + f.closed + except: + assert False, "Specified codec (" + use_codec[os_name] + ") failed to read file." + + assert read_data == "True" diff --git "a/tests/test_locale/test_\327\244\327\230\327\233\327\251/testcodec" "b/tests/test_locale/test_\327\244\327\230\327\233\327\251/testcodec" new file mode 100644 index 0000000000..4791ed5559 --- /dev/null +++ "b/tests/test_locale/test_\327\244\327\230\327\233\327\251/testcodec" @@ -0,0 +1 @@ +True \ No newline at end of file diff --git "a/tests/test_locale/test_\346\265\213\350\257\225/test_codec_chinese_simplified.py" "b/tests/test_locale/test_\346\265\213\350\257\225/test_codec_chinese_simplified.py" new file mode 100644 index 0000000000..0a33605f41 --- /dev/null +++ "b/tests/test_locale/test_\346\265\213\350\257\225/test_codec_chinese_simplified.py" @@ -0,0 +1,30 @@ +# Chinese (Simplified) + +import os +import platform +from tests.test_locale.locale_functions import GetPath + + +def test_codec_chinese_simplified(): + use_codec = { + "Windows": "cp1252", + "Linux" : "utf8", + "Darwin" : "utf8", + } + + os_name = platform.system() + current_directory = os.path.dirname(os.path.abspath(__file__)) + + try: + decoded_file = GetPath(current_directory, "testcodec", use_codec[os_name]) + except: + assert False, "Specified codec (" + use_codec[os_name] + ") failed to decrypt file path." + + try: + with open(decoded_file, 'r') as f: + read_data = f.read() + f.closed + except: + assert False, "Specified codec (" + use_codec[os_name] + ") failed to read file." + + assert read_data == "True" diff --git "a/tests/test_locale/test_\346\265\213\350\257\225/testcodec" "b/tests/test_locale/test_\346\265\213\350\257\225/testcodec" new file mode 100644 index 0000000000..4791ed5559 --- /dev/null +++ "b/tests/test_locale/test_\346\265\213\350\257\225/testcodec" @@ -0,0 +1 @@ +True \ No newline at end of file diff --git "a/tests/test_locale/\320\267\320\275\320\260\321\204/test_codec_russian.py" "b/tests/test_locale/\320\267\320\275\320\260\321\204/test_codec_russian.py" new file mode 100644 index 0000000000..30dd8c709e --- /dev/null +++ "b/tests/test_locale/\320\267\320\275\320\260\321\204/test_codec_russian.py" @@ -0,0 +1,30 @@ +# Russian + +import os +import platform +from tests.test_locale.locale_functions import GetPath + + +def test_codec_russian(): + use_codec = { + "Windows": "cp1251", + "Linux" : "utf8", + "Darwin" : "mac_cyrillic", + } + + os_name = platform.system() + current_directory = os.path.dirname(os.path.abspath(__file__)) + + try: + decoded_file = GetPath(current_directory, "testcodec", use_codec[os_name]) + except: + assert False, "Specified codec (" + use_codec[os_name] + ") failed to decrypt file path." + + try: + with open(decoded_file, 'r') as f: + read_data = f.read() + f.closed + except: + assert False, "Specified codec (" + use_codec[os_name] + ") failed to read file." + + assert read_data == "True" diff --git "a/tests/test_locale/\320\267\320\275\320\260\321\204/testcodec" "b/tests/test_locale/\320\267\320\275\320\260\321\204/testcodec" new file mode 100644 index 0000000000..0ca95142bb --- /dev/null +++ "b/tests/test_locale/\320\267\320\275\320\260\321\204/testcodec" @@ -0,0 +1 @@ +True From b788d6b12b2c1759f98d0f02bf8264a83b1079a6 Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Tue, 28 Mar 2017 13:18:15 -0700 Subject: [PATCH 02/12] Add helper --- _development/helpers_locale.py | 101 +++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 _development/helpers_locale.py diff --git a/_development/helpers_locale.py b/_development/helpers_locale.py new file mode 100644 index 0000000000..4d4d29f4ed --- /dev/null +++ b/_development/helpers_locale.py @@ -0,0 +1,101 @@ +import os + +# https://msdn.microsoft.com/en-us/library/windows/desktop/dd317756(v=vs.85).aspx +windows_codecs = { + 'cp1252', # Standard Windows + 'cp1251', # Russian + 'cp037', + 'cp424', + 'cp437', + 'cp500', + 'cp720', + 'cp737', + 'cp775', + 'cp850', + 'cp852', + 'cp855', + 'cp856', + 'cp857', + 'cp858', + 'cp860', + 'cp861', + 'cp862', + 'cp863', + 'cp864', + 'cp865', + 'cp866', + 'cp869', + 'cp874', + 'cp875', + 'cp932', + 'cp949', + 'cp950', + 'cp1006', + 'cp1026', + 'cp1140', + 'cp1250', + 'cp1253', + 'cp1254', + 'cp1255', + 'cp1256', + 'cp1257', + 'cp1258', +} + +linux_codecs = { + 'utf_8', # Generic Linux/Mac +} + +mac_codecs = [ + 'utf_8', # Generic Linux/Mac + 'mac_cyrillic', + 'mac_greek', + 'mac_iceland', + 'mac_latin2', + 'mac_roman', + 'mac_turkish', +] + +universal_codecs = [ + 'utf_16', 'utf_32', 'utf_32_be', 'utf_32_le', 'utf_16_be', 'utf_16_le', 'utf_7', 'utf_8_sig', +] + +other_codecs = [ + 'scii', 'big5', 'big5hkscs', 'euc_jp', 'euc_jis_2004', 'euc_jisx0213', 'euc_kr', 'gb2312', 'gbk', 'gb18030', 'hz', 'iso2022_jp', 'iso2022_jp_1', + 'iso2022_jp_2', 'iso2022_jp_2004', 'iso2022_jp_3', 'iso2022_jp_ext', 'iso2022_kr', 'latin_1', 'iso8859_2', 'iso8859_3', 'iso8859_4', 'iso8859_5', + 'iso8859_6', 'iso8859_7', 'iso8859_8', 'iso8859_9', 'iso8859_10', 'iso8859_11', 'iso8859_13', 'iso8859_14', 'iso8859_15', 'iso8859_16', 'johab', 'koi8_r', + 'koi8_u', 'ptcp154', 'shift_jis', 'shift_jis_2004', 'shift_jisx0213' +] + +system_names = { + 'Windows': windows_codecs, + 'Linux': linux_codecs, + 'Darwin': mac_codecs, +} + + +def GetPath(root, file=None, codec=None): + # Replace this with the function we actually use for this + path = os.path.realpath(os.path.abspath(root)) + + if file: + path = os.path.join(path, file) + + if codec: + path = path.decode(codec) + + return path + +def GetUnicodePath(root, file=None, codec=None): + # Replace this with the function we actually use for this + path = os.path.realpath(os.path.abspath(root)) + + if file: + path = os.path.join(path, file) + + if codec: + path = unicode(path, codec) + else: + path = unicode(path) + + return path From dc929245c4f8e082d96c5589165d7db9f6d472a5 Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Tue, 28 Mar 2017 13:26:02 -0700 Subject: [PATCH 03/12] Remove line break if found. --- tests/test_locale/test_os_walk.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_locale/test_os_walk.py b/tests/test_locale/test_os_walk.py index 90fffed0eb..f736ac7d43 100644 --- a/tests/test_locale/test_os_walk.py +++ b/tests/test_locale/test_os_walk.py @@ -26,6 +26,7 @@ def test_os_walk(): except: assert False, "Failed to read file." + read_data = read_data.replace("\n", "") assert read_data == "True" subfolder_count += 1 From 180b3c5319df3f05f8a70fc19ad2c8627238c1f4 Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Tue, 28 Mar 2017 13:29:29 -0700 Subject: [PATCH 04/12] Fix imports --- tests/test_locale/test_Pyfa/test_codec_english.py | 4 ++-- .../test_codec_russian.py" | 10 ++++++++-- .../test_codec_hebrew.py" | 10 ++++++++-- .../test_codec_chinese_simplified.py" | 10 ++++++++-- 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/tests/test_locale/test_Pyfa/test_codec_english.py b/tests/test_locale/test_Pyfa/test_codec_english.py index 6a129aa3f1..282222d88a 100644 --- a/tests/test_locale/test_Pyfa/test_codec_english.py +++ b/tests/test_locale/test_Pyfa/test_codec_english.py @@ -6,7 +6,7 @@ script_dir = os.path.dirname(os.path.abspath(__file__)) # Add root to python paths, this allows us to import submodules -sys.path.append(os.path.realpath(os.path.join(script_dir, '..', '..'))) +sys.path.append(os.path.realpath(os.path.join(script_dir, '..', '..', '..'))) from _development.helpers_locale import GetPath @@ -19,7 +19,7 @@ def test_codec_english(): } os_name = platform.system() - current_directory = os.path.dirname(os.path.abspath(__file__)) + current_directory = os.path.dirname(os.path.abspath(unicode(__file__))) try: decoded_file = GetPath(current_directory, "testcodec", use_codec[os_name]) diff --git "a/tests/test_locale/test_\320\267\320\275\320\260\321\204/test_codec_russian.py" "b/tests/test_locale/test_\320\267\320\275\320\260\321\204/test_codec_russian.py" index 30dd8c709e..dff855ed61 100644 --- "a/tests/test_locale/test_\320\267\320\275\320\260\321\204/test_codec_russian.py" +++ "b/tests/test_locale/test_\320\267\320\275\320\260\321\204/test_codec_russian.py" @@ -2,7 +2,13 @@ import os import platform -from tests.test_locale.locale_functions import GetPath +import sys + +script_dir = os.path.dirname(os.path.abspath(__file__)) +# Add root to python paths, this allows us to import submodules +sys.path.append(os.path.realpath(os.path.join(script_dir, '..', '..', '..'))) + +from _development.helpers_locale import GetPath def test_codec_russian(): @@ -13,7 +19,7 @@ def test_codec_russian(): } os_name = platform.system() - current_directory = os.path.dirname(os.path.abspath(__file__)) + current_directory = os.path.dirname(os.path.abspath(unicode(__file__))) try: decoded_file = GetPath(current_directory, "testcodec", use_codec[os_name]) diff --git "a/tests/test_locale/test_\327\244\327\230\327\233\327\251/test_codec_hebrew.py" "b/tests/test_locale/test_\327\244\327\230\327\233\327\251/test_codec_hebrew.py" index d6c94812de..781f6baed5 100644 --- "a/tests/test_locale/test_\327\244\327\230\327\233\327\251/test_codec_hebrew.py" +++ "b/tests/test_locale/test_\327\244\327\230\327\233\327\251/test_codec_hebrew.py" @@ -2,7 +2,13 @@ import os import platform -from tests.test_locale.locale_functions import GetPath +import sys + +script_dir = os.path.dirname(os.path.abspath(__file__)) +# Add root to python paths, this allows us to import submodules +sys.path.append(os.path.realpath(os.path.join(script_dir, '..', '..', '..'))) + +from _development.helpers_locale import GetPath def test_codec_hebrew(): @@ -13,7 +19,7 @@ def test_codec_hebrew(): } os_name = platform.system() - current_directory = os.path.dirname(os.path.abspath(__file__)) + current_directory = os.path.dirname(os.path.abspath(unicode(__file__))) try: decoded_file = GetPath(current_directory, "testcodec", use_codec[os_name]) diff --git "a/tests/test_locale/test_\346\265\213\350\257\225/test_codec_chinese_simplified.py" "b/tests/test_locale/test_\346\265\213\350\257\225/test_codec_chinese_simplified.py" index 0a33605f41..c90ac6ced1 100644 --- "a/tests/test_locale/test_\346\265\213\350\257\225/test_codec_chinese_simplified.py" +++ "b/tests/test_locale/test_\346\265\213\350\257\225/test_codec_chinese_simplified.py" @@ -2,7 +2,13 @@ import os import platform -from tests.test_locale.locale_functions import GetPath +import sys + +script_dir = os.path.dirname(os.path.abspath(__file__)) +# Add root to python paths, this allows us to import submodules +sys.path.append(os.path.realpath(os.path.join(script_dir, '..', '..', '..'))) + +from _development.helpers_locale import GetPath def test_codec_chinese_simplified(): @@ -13,7 +19,7 @@ def test_codec_chinese_simplified(): } os_name = platform.system() - current_directory = os.path.dirname(os.path.abspath(__file__)) + current_directory = os.path.dirname(os.path.abspath(unicode(__file__))) try: decoded_file = GetPath(current_directory, "testcodec", use_codec[os_name]) From 498b794163b880761e0abe8233fd05ede81adc82 Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Tue, 28 Mar 2017 13:35:44 -0700 Subject: [PATCH 05/12] Remove copy that snuck in --- .../test_codec_russian.py" | 30 ------------------- .../testcodec" | 1 - 2 files changed, 31 deletions(-) delete mode 100644 "tests/test_locale/\320\267\320\275\320\260\321\204/test_codec_russian.py" delete mode 100644 "tests/test_locale/\320\267\320\275\320\260\321\204/testcodec" diff --git "a/tests/test_locale/\320\267\320\275\320\260\321\204/test_codec_russian.py" "b/tests/test_locale/\320\267\320\275\320\260\321\204/test_codec_russian.py" deleted file mode 100644 index 30dd8c709e..0000000000 --- "a/tests/test_locale/\320\267\320\275\320\260\321\204/test_codec_russian.py" +++ /dev/null @@ -1,30 +0,0 @@ -# Russian - -import os -import platform -from tests.test_locale.locale_functions import GetPath - - -def test_codec_russian(): - use_codec = { - "Windows": "cp1251", - "Linux" : "utf8", - "Darwin" : "mac_cyrillic", - } - - os_name = platform.system() - current_directory = os.path.dirname(os.path.abspath(__file__)) - - try: - decoded_file = GetPath(current_directory, "testcodec", use_codec[os_name]) - except: - assert False, "Specified codec (" + use_codec[os_name] + ") failed to decrypt file path." - - try: - with open(decoded_file, 'r') as f: - read_data = f.read() - f.closed - except: - assert False, "Specified codec (" + use_codec[os_name] + ") failed to read file." - - assert read_data == "True" diff --git "a/tests/test_locale/\320\267\320\275\320\260\321\204/testcodec" "b/tests/test_locale/\320\267\320\275\320\260\321\204/testcodec" deleted file mode 100644 index 0ca95142bb..0000000000 --- "a/tests/test_locale/\320\267\320\275\320\260\321\204/testcodec" +++ /dev/null @@ -1 +0,0 @@ -True From 17c63ec4baf71eda8248d2c28eec8db997601ae8 Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Tue, 28 Mar 2017 13:43:49 -0700 Subject: [PATCH 06/12] Install language packs --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 497b67b082..1b14d97299 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,6 +18,9 @@ before_install: install: - pip install -r requirements.txt - pip install -r requirements_test.txt + - sudo apt-get -y install `check-language-support -l ru` + - sudo apt-get -y install `check-language-support -l he` + - sudo apt-get -y install `check-language-support -l cn` script: - tox - py.test --cov=./ From 9eb540a1178e32d7b9a51f35bf48125f1dcf02d7 Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Tue, 28 Mar 2017 13:48:57 -0700 Subject: [PATCH 07/12] Change language pack install --- .travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1b14d97299..c9a18d7918 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,12 +15,10 @@ addons: - wx2.8-i18n before_install: - pip install -U tox + - sudo apt-get update && sudo apt-get --reinstall install -qq language-pack-en language-pack-ru language-pack-he language-pack-cn install: - pip install -r requirements.txt - pip install -r requirements_test.txt - - sudo apt-get -y install `check-language-support -l ru` - - sudo apt-get -y install `check-language-support -l he` - - sudo apt-get -y install `check-language-support -l cn` script: - tox - py.test --cov=./ From 408ecc00b4d255bdf4d8cf9429590bcb1b3e8907 Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Tue, 28 Mar 2017 13:53:27 -0700 Subject: [PATCH 08/12] fix china language pack --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c9a18d7918..b5fc4049c2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ addons: - wx2.8-i18n before_install: - pip install -U tox - - sudo apt-get update && sudo apt-get --reinstall install -qq language-pack-en language-pack-ru language-pack-he language-pack-cn + - sudo apt-get update && sudo apt-get --reinstall install -qq language-pack-en language-pack-ru language-pack-he language-pack-zh-hans install: - pip install -r requirements.txt - pip install -r requirements_test.txt From 8494dd1d94d044df1dba88dffc6ff853780e5f78 Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Tue, 28 Mar 2017 14:00:35 -0700 Subject: [PATCH 09/12] Fix tests that I accidentially broke --- tests/test_locale/test_Pyfa/test_codec_english.py | 2 +- .../test_codec_russian.py" | 2 +- .../test_\327\244\327\230\327\233\327\251/test_codec_hebrew.py" | 2 +- .../test_codec_chinese_simplified.py" | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_locale/test_Pyfa/test_codec_english.py b/tests/test_locale/test_Pyfa/test_codec_english.py index 282222d88a..b2f03f69fb 100644 --- a/tests/test_locale/test_Pyfa/test_codec_english.py +++ b/tests/test_locale/test_Pyfa/test_codec_english.py @@ -19,7 +19,7 @@ def test_codec_english(): } os_name = platform.system() - current_directory = os.path.dirname(os.path.abspath(unicode(__file__))) + current_directory = os.path.dirname(os.path.abspath(__file__)) try: decoded_file = GetPath(current_directory, "testcodec", use_codec[os_name]) diff --git "a/tests/test_locale/test_\320\267\320\275\320\260\321\204/test_codec_russian.py" "b/tests/test_locale/test_\320\267\320\275\320\260\321\204/test_codec_russian.py" index dff855ed61..1572b6bd5e 100644 --- "a/tests/test_locale/test_\320\267\320\275\320\260\321\204/test_codec_russian.py" +++ "b/tests/test_locale/test_\320\267\320\275\320\260\321\204/test_codec_russian.py" @@ -19,7 +19,7 @@ def test_codec_russian(): } os_name = platform.system() - current_directory = os.path.dirname(os.path.abspath(unicode(__file__))) + current_directory = os.path.dirname(os.path.abspath(__file__)) try: decoded_file = GetPath(current_directory, "testcodec", use_codec[os_name]) diff --git "a/tests/test_locale/test_\327\244\327\230\327\233\327\251/test_codec_hebrew.py" "b/tests/test_locale/test_\327\244\327\230\327\233\327\251/test_codec_hebrew.py" index 781f6baed5..6b806cbe85 100644 --- "a/tests/test_locale/test_\327\244\327\230\327\233\327\251/test_codec_hebrew.py" +++ "b/tests/test_locale/test_\327\244\327\230\327\233\327\251/test_codec_hebrew.py" @@ -19,7 +19,7 @@ def test_codec_hebrew(): } os_name = platform.system() - current_directory = os.path.dirname(os.path.abspath(unicode(__file__))) + current_directory = os.path.dirname(os.path.abspath(__file__)) try: decoded_file = GetPath(current_directory, "testcodec", use_codec[os_name]) diff --git "a/tests/test_locale/test_\346\265\213\350\257\225/test_codec_chinese_simplified.py" "b/tests/test_locale/test_\346\265\213\350\257\225/test_codec_chinese_simplified.py" index c90ac6ced1..30d879391d 100644 --- "a/tests/test_locale/test_\346\265\213\350\257\225/test_codec_chinese_simplified.py" +++ "b/tests/test_locale/test_\346\265\213\350\257\225/test_codec_chinese_simplified.py" @@ -19,7 +19,7 @@ def test_codec_chinese_simplified(): } os_name = platform.system() - current_directory = os.path.dirname(os.path.abspath(unicode(__file__))) + current_directory = os.path.dirname(os.path.abspath(__file__)) try: decoded_file = GetPath(current_directory, "testcodec", use_codec[os_name]) From 7eec7c7ef0e9ab3247592900b1c335882a0af0e5 Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Tue, 28 Mar 2017 14:04:57 -0700 Subject: [PATCH 10/12] Add debug print --- tests/test_locale/test_os_walk.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_locale/test_os_walk.py b/tests/test_locale/test_os_walk.py index f736ac7d43..e154c3eb3b 100644 --- a/tests/test_locale/test_os_walk.py +++ b/tests/test_locale/test_os_walk.py @@ -24,6 +24,8 @@ def test_os_walk(): # noinspection PyStatementEffect f.closed except: + print("Test File:") + print(testfile) assert False, "Failed to read file." read_data = read_data.replace("\n", "") From 01c53f481a150011b79fb5c8ec5992d920a3ee4f Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Tue, 28 Mar 2017 14:10:54 -0700 Subject: [PATCH 11/12] Don't try and parse Travis cache dirs --- tests/test_locale/test_os_walk.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/test_locale/test_os_walk.py b/tests/test_locale/test_os_walk.py index e154c3eb3b..6a68bc2ac8 100644 --- a/tests/test_locale/test_os_walk.py +++ b/tests/test_locale/test_os_walk.py @@ -17,6 +17,10 @@ def test_os_walk(): subdir = GetPath(current_directory, subfolder) testfile = GetPath(subdir, "testcodec") + if "__pycache__" in testfile: + # Grabbed a Travis temp folder, skip it. + continue + # noinspection PyBroadException try: with open(testfile, 'r') as f: From fb146f2db71405062de32a5c81589423b9e662b5 Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Tue, 28 Mar 2017 14:14:44 -0700 Subject: [PATCH 12/12] Fix counting --- tests/test_locale/test_os_walk.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_locale/test_os_walk.py b/tests/test_locale/test_os_walk.py index 6a68bc2ac8..4ed377acc3 100644 --- a/tests/test_locale/test_os_walk.py +++ b/tests/test_locale/test_os_walk.py @@ -18,7 +18,8 @@ def test_os_walk(): testfile = GetPath(subdir, "testcodec") if "__pycache__" in testfile: - # Grabbed a Travis temp folder, skip it. + # Grabbed a Travis temp folder, skip any assertions, but count it. + subfolder_count += 1 continue # noinspection PyBroadException