diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2017-01-18 22:05:41 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-01-18 21:45:12 -0500 |
| commit | a5563963397aeee30c32e3c1dab31bfe453ca89f (patch) | |
| tree | 6fe111ef4ea95da191037341729c7d39b87c07d7 /tests | |
| parent | eb422e476f3c0070dbf200bd62d97d12150c6fd9 (diff) | |
Refs #23919 -- Replaced io.open() with open().
io.open() is an alias for open() on Python 3.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/cache/tests.py | 2 | ||||
| -rw-r--r-- | tests/i18n/test_extraction.py | 11 | ||||
| -rw-r--r-- | tests/migrations/test_commands.py | 10 | ||||
| -rw-r--r-- | tests/validators/tests.py | 5 |
4 files changed, 13 insertions, 15 deletions
diff --git a/tests/cache/tests.py b/tests/cache/tests.py index 3bf39e2476..dd886cd11b 100644 --- a/tests/cache/tests.py +++ b/tests/cache/tests.py @@ -1370,7 +1370,7 @@ class FileBasedCacheTests(BaseCacheTests, TestCase): self.assertEqual(cache.get('foo', 'baz'), 'baz') def test_get_does_not_ignore_non_enoent_errno_values(self): - with mock.patch.object(io, 'open', side_effect=IOError): + with mock.patch('builtins.open', side_effect=IOError): with self.assertRaises(IOError): cache.get('foo') diff --git a/tests/i18n/test_extraction.py b/tests/i18n/test_extraction.py index aaa2a4e8b5..4189a9e168 100644 --- a/tests/i18n/test_extraction.py +++ b/tests/i18n/test_extraction.py @@ -1,4 +1,3 @@ -import io import os import re import shutil @@ -133,7 +132,7 @@ class BasicExtractorTests(ExtractorTests): """ management.call_command('makemessages', locale=[LOCALE], verbosity=0) self.assertTrue(os.path.exists(self.PO_FILE)) - with io.open(self.PO_FILE, 'r', encoding='utf-8') as fp: + with open(self.PO_FILE, 'r', encoding='utf-8') as fp: po_contents = fp.read() # Check two random strings self.assertIn('#. Translators: One-line translator comment #1', po_contents) @@ -142,7 +141,7 @@ class BasicExtractorTests(ExtractorTests): def test_comments_extractor(self): management.call_command('makemessages', locale=[LOCALE], verbosity=0) self.assertTrue(os.path.exists(self.PO_FILE)) - with io.open(self.PO_FILE, 'r', encoding='utf-8') as fp: + with open(self.PO_FILE, 'r', encoding='utf-8') as fp: po_contents = fp.read() self.assertNotIn('This comment should not be extracted', po_contents) @@ -175,7 +174,7 @@ class BasicExtractorTests(ExtractorTests): def test_special_char_extracted(self): management.call_command('makemessages', locale=[LOCALE], verbosity=0) self.assertTrue(os.path.exists(self.PO_FILE)) - with io.open(self.PO_FILE, 'r', encoding='utf-8') as fp: + with open(self.PO_FILE, 'r', encoding='utf-8') as fp: po_contents = fp.read() self.assertMsgId("Non-breaking space\u00a0:", po_contents) @@ -390,7 +389,7 @@ class BasicExtractorTests(ExtractorTests): shutil.copyfile(BR_PO_BASE + '.pristine', BR_PO_BASE + '.po') management.call_command('makemessages', locale=['pt_BR'], verbosity=0) self.assertTrue(os.path.exists(BR_PO_BASE + '.po')) - with io.open(BR_PO_BASE + '.po', 'r', encoding='utf-8') as fp: + with open(BR_PO_BASE + '.po', 'r', encoding='utf-8') as fp: po_contents = force_text(fp.read()) self.assertMsgStr("Größe", po_contents) @@ -515,7 +514,7 @@ class CopyPluralFormsExtractorTests(ExtractorTests): """Ticket #20311.""" management.call_command('makemessages', locale=['es'], extensions=['djtpl'], verbosity=0) self.assertTrue(os.path.exists(self.PO_FILE_ES)) - with io.open(self.PO_FILE_ES, 'r', encoding='utf-8') as fp: + with open(self.PO_FILE_ES, 'r', encoding='utf-8') as fp: po_contents = fp.read() found = re.findall(r'^(?P<value>"Plural-Forms.+?\\n")\s*$', po_contents, re.MULTILINE | re.DOTALL) self.assertEqual(1, len(found)) diff --git a/tests/migrations/test_commands.py b/tests/migrations/test_commands.py index e6de83212e..421b4890a4 100644 --- a/tests/migrations/test_commands.py +++ b/tests/migrations/test_commands.py @@ -655,7 +655,7 @@ class MakeMigrationsTests(MigrationTestBase): initial_file = os.path.join(migration_dir, "0001_initial.py") self.assertTrue(os.path.exists(initial_file)) - with io.open(initial_file, 'r', encoding='utf-8') as fp: + with open(initial_file, 'r', encoding='utf-8') as fp: content = fp.read() self.assertIn('migrations.CreateModel', content) self.assertIn('initial = True', content) @@ -798,7 +798,7 @@ class MakeMigrationsTests(MigrationTestBase): initial_file = os.path.join(migration_dir, "0001_initial.py") self.assertTrue(os.path.exists(initial_file)) - with io.open(initial_file, 'r', encoding='utf-8') as fp: + with open(initial_file, 'r', encoding='utf-8') as fp: content = fp.read() # Remove all whitespace to check for empty dependencies and operations @@ -1192,7 +1192,7 @@ class MakeMigrationsTests(MigrationTestBase): migration_file = os.path.join(migration_dir, "%s_%s.py" % (migration_count, migration_name)) # Check for existing migration file in migration folder self.assertTrue(os.path.exists(migration_file)) - with io.open(migration_file, "r", encoding="utf-8") as fp: + with open(migration_file, "r", encoding="utf-8") as fp: content = fp.read() content = content.replace(" ", "") return content @@ -1307,7 +1307,7 @@ class SquashMigrationsTests(MigrationTestBase): call_command("squashmigrations", "migrations", "0002", interactive=False, verbosity=0) squashed_migration_file = os.path.join(migration_dir, "0001_squashed_0002_second.py") - with io.open(squashed_migration_file, "r", encoding="utf-8") as fp: + with open(squashed_migration_file, "r", encoding="utf-8") as fp: content = fp.read() self.assertIn("initial = True", content) @@ -1340,7 +1340,7 @@ class SquashMigrationsTests(MigrationTestBase): interactive=False, verbosity=1, stdout=out) squashed_migration_file = os.path.join(migration_dir, "0002_second_squashed_0003_third.py") - with io.open(squashed_migration_file, "r", encoding="utf-8") as fp: + with open(squashed_migration_file, "r", encoding="utf-8") as fp: content = fp.read() self.assertIn(" ('migrations', '0001_initial')", content) self.assertNotIn("initial = True", content) diff --git a/tests/validators/tests.py b/tests/validators/tests.py index d5fb2215ca..2f26efcaa5 100644 --- a/tests/validators/tests.py +++ b/tests/validators/tests.py @@ -1,4 +1,3 @@ -import io import os import re import types @@ -269,10 +268,10 @@ def create_path(filename): # Add valid and invalid URL tests. # This only tests the validator without extended schemes. -with io.open(create_path('valid_urls.txt'), encoding='utf8') as f: +with open(create_path('valid_urls.txt'), encoding='utf8') as f: for url in f: TEST_DATA.append((URLValidator(), url.strip(), None)) -with io.open(create_path('invalid_urls.txt'), encoding='utf8') as f: +with open(create_path('invalid_urls.txt'), encoding='utf8') as f: for url in f: TEST_DATA.append((URLValidator(), url.strip(), ValidationError)) |
