diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7d91954a4..bb01aabfe 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -25,12 +25,6 @@ jobs: fail-fast: false matrix: include: - - tox_env: py27-m_ans-ans2.10 - - tox_env: py27-m_ans-ans4 - - - tox_env: py36-m_ans-ans2.10 - - tox_env: py36-m_ans-ans4 - - tox_env: py27-m_mtg - tox_env: py36-m_mtg @@ -86,34 +80,6 @@ jobs: fail-fast: false matrix: include: - - tox_env: py311-m_ans-ans2.10 - python_version: '3.11' - - tox_env: py311-m_ans-ans3 - python_version: '3.11' - - tox_env: py311-m_ans-ans4 - python_version: '3.11' - - tox_env: py311-m_ans-ans5 - python_version: '3.11' - - tox_env: py313-m_ans-ans6 - python_version: '3.13' - - tox_env: py313-m_ans-ans7 - python_version: '3.13' - - tox_env: py313-m_ans-ans8 - python_version: '3.13' - - tox_env: py314-m_ans-ans9 - python_version: '3.14' - - tox_env: py314-m_ans-ans10 - python_version: '3.14' - - tox_env: py314-m_ans-ans11 - python_version: '3.14' - - tox_env: py314-m_ans-ans12 - python_version: '3.14' - - tox_env: py314-m_ans-ans13 - python_version: '3.14' - - - tox_env: py314-m_ans-ans13-s_lin - python_version: '3.14' - - tox_env: py314-m_mtg python_version: '3.14' @@ -161,11 +127,6 @@ jobs: fail-fast: false matrix: include: - - tox_env: py314-m_lcl-ans13 - python_version: '3.14' - - tox_env: py314-m_lcl-ans13-s_lin - python_version: '3.14' - - tox_env: py314-m_mtg python_version: '3.14' diff --git a/tests/data/importer/nonascii_pkg/__init__.py b/tests/data/importer/nonascii_pkg/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git "a/tests/data/importer/nonascii_pkg/hej_v\303\244rlden.py" "b/tests/data/importer/nonascii_pkg/hej_v\303\244rlden.py" new file mode 100644 index 000000000..54b839423 --- /dev/null +++ "b/tests/data/importer/nonascii_pkg/hej_v\303\244rlden.py" @@ -0,0 +1,2 @@ +def hej(): + return "This module is named 'Hello world', in Swedish" diff --git a/tests/data/importer/nonascii_pkg/undeclared/__init__.py b/tests/data/importer/nonascii_pkg/undeclared/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/data/importer/nonascii_pkg/undeclared/ascii.py b/tests/data/importer/nonascii_pkg/undeclared/ascii.py new file mode 100644 index 000000000..a0de31223 --- /dev/null +++ b/tests/data/importer/nonascii_pkg/undeclared/ascii.py @@ -0,0 +1,10 @@ +""" +>>> print(string_literal()) +Sphinx of black quartz, judge my vow. +""" + +def doc_string(): + return __doc__ + +def string_literal(): + return u'Sphinx of black quartz, judge my vow.' diff --git a/tests/data/importer/nonascii_pkg/undeclared/utf8.py b/tests/data/importer/nonascii_pkg/undeclared/utf8.py new file mode 100644 index 000000000..e77bf3fff --- /dev/null +++ b/tests/data/importer/nonascii_pkg/undeclared/utf8.py @@ -0,0 +1,10 @@ +""" +>>> print(string_literal()) +Hello world, Καλημέρα κόσμε, コンニチハ +""" + +def doc_string(): + return __doc__ + +def string_literal(): + return u'Hello world, Καλημέρα κόσμε, コンニチハ' diff --git a/tests/data/importer/nonascii_pkg/with_bom/__init__.py b/tests/data/importer/nonascii_pkg/with_bom/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/data/importer/nonascii_pkg/with_bom/utf8.py b/tests/data/importer/nonascii_pkg/with_bom/utf8.py new file mode 100644 index 000000000..4569cb899 --- /dev/null +++ b/tests/data/importer/nonascii_pkg/with_bom/utf8.py @@ -0,0 +1,10 @@ +""" +>>> print(string_literal()) +Hello world, Καλημέρα κόσμε, コンニチハ +""" + +def doc_string(): + return __doc__ + +def string_literal(): + return u'Hello world, Καλημέρα κόσμε, コンニチハ' diff --git a/tests/data/importer/nonascii_pkg/with_coding/__init__.py b/tests/data/importer/nonascii_pkg/with_coding/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/data/importer/nonascii_pkg/with_coding/ascii.py b/tests/data/importer/nonascii_pkg/with_coding/ascii.py new file mode 100644 index 000000000..37242c116 --- /dev/null +++ b/tests/data/importer/nonascii_pkg/with_coding/ascii.py @@ -0,0 +1,11 @@ +# -*- coding: ascii -*- +""" +>>> print(string_literal()) +Sphinx of black quartz, judge my vow. +""" + +def doc_string(): + return __doc__ + +def string_literal(): + return u'Sphinx of black quartz, judge my vow.' diff --git a/tests/data/importer/nonascii_pkg/with_coding/cp1252.py b/tests/data/importer/nonascii_pkg/with_coding/cp1252.py new file mode 100644 index 000000000..6ab5c7177 --- /dev/null +++ b/tests/data/importer/nonascii_pkg/with_coding/cp1252.py @@ -0,0 +1,11 @@ +# -*- coding: cp1252 -*- +""" +>>> print(string_literal()) +Hello euro sign, Ol , Hello trademark, Hello +""" + +def doc_string(): + return __doc__ + +def string_literal(): + return u'Hello euro sign, Ol , Hello trademark, Hello ' diff --git a/tests/data/importer/nonascii_pkg/with_coding/iso8859_15.py b/tests/data/importer/nonascii_pkg/with_coding/iso8859_15.py new file mode 100644 index 000000000..8489d95bc --- /dev/null +++ b/tests/data/importer/nonascii_pkg/with_coding/iso8859_15.py @@ -0,0 +1,11 @@ +# -*- coding: iso-8859-15 -*- +""" +>>> print(string_literal()) +Hello euro sign, Hello +""" + +def doc_string(): + return __doc__ + +def string_literal(): + return u'Hello euro sign, Hello ' diff --git a/tests/data/importer/nonascii_pkg/with_coding/latin1.py b/tests/data/importer/nonascii_pkg/with_coding/latin1.py new file mode 100644 index 000000000..bccc8ceeb --- /dev/null +++ b/tests/data/importer/nonascii_pkg/with_coding/latin1.py @@ -0,0 +1,11 @@ +# -*- coding: latin1 -*- +""" +>>> print(string_literal()) +Hello world, Ol mundo, Hej vrlden +""" + +def doc_string(): + return __doc__ + +def string_literal(): + return u'Hello world, Ol mundo, Hej vrlden' diff --git a/tests/data/importer/nonascii_pkg/with_coding/utf8.py b/tests/data/importer/nonascii_pkg/with_coding/utf8.py new file mode 100644 index 000000000..ee700fc42 --- /dev/null +++ b/tests/data/importer/nonascii_pkg/with_coding/utf8.py @@ -0,0 +1,11 @@ +# -*- coding: utf-8 -*- +""" +>>> print(string_literal()) +Hello world, Καλημέρα κόσμε, コンニチハ +""" + +def doc_string(): + return __doc__ + +def string_literal(): + return u'Hello world, Καλημέρα κόσμε, コンニチハ' diff --git a/tests/import_encoding_test.py b/tests/import_encoding_test.py new file mode 100644 index 000000000..5378a7db1 --- /dev/null +++ b/tests/import_encoding_test.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +import sys +import unittest + +import testlib + +import nonascii_pkg.with_bom.utf8 +import nonascii_pkg.with_coding.cp1252 +import nonascii_pkg.with_coding.iso8859_15 +import nonascii_pkg.with_coding.latin1 +import nonascii_pkg.with_coding.utf8 + + +class UndeclaredTest(testlib.RouterMixin, testlib.TestCase): + @unittest.skipIf(sys.version_info < (3, 0), 'Python 2.x, default source encoding is ascii') + def test_utf8(self): + import nonascii_pkg.undeclared.utf8 + conn = self.router.local(python_path='python3') + self.assertEqual( + u'Hello world, Καλημέρα κόσμε, コンニチハ', + conn.call(nonascii_pkg.with_bom.utf8.string_literal), + ) + + +class WithBomTest(testlib.RouterMixin, testlib.TestCase): + def test_utf8(self): + conn = self.router.local() + self.assertEqual( + u'Hello world, Καλημέρα κόσμε, コンニチハ', + conn.call(nonascii_pkg.with_bom.utf8.string_literal), + ) + + +class WithCodingTest(testlib.RouterMixin, testlib.TestCase): + def test_cp1252(self): + conn = self.router.local() + self.assertEqual( + u'Hello euro sign, Olá €, Hello trademark, Hello ™', + conn.call(nonascii_pkg.with_coding.cp1252.string_literal), + ) + + def test_iso8859_15(self): + conn = self.router.local() + self.assertEqual( + u'Hello euro sign, Hello €', + conn.call(nonascii_pkg.with_coding.iso8859_15.string_literal), + ) + + def test_latin1(self): + conn = self.router.local() + self.assertEqual( + u'Hello world, Olá mundo, Hej världen', + conn.call(nonascii_pkg.with_coding.latin1.string_literal), + ) + + def test_utf8(self): + conn = self.router.local() + self.assertEqual( + u'Hello world, Καλημέρα κόσμε, コンニチハ', + conn.call(nonascii_pkg.with_coding.utf8.string_literal), + )