Skip to content

Commit 4a40fdf

Browse files
committed
Update tests for standard library aliases again
Also remove unicode_literals from test_standard_library.py
1 parent feb9fdd commit 4a40fdf

File tree

2 files changed

+43
-37
lines changed

2 files changed

+43
-37
lines changed

future/tests/test_import_star.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,6 @@ def test_iterators(self):
4848
def test_super(self):
4949
pass
5050

51-
@skip26
52-
def test_python3_stdlib_imports(self):
53-
"""
54-
The import hooks should be tightened up so that this test never fails
55-
"""
56-
# These should fail on Py2
57-
try:
58-
import queue
59-
import socketserver
60-
except ImportError:
61-
if utils.PY3:
62-
self.fail('Py3 modules failed to load')
63-
else:
64-
if utils.PY2:
65-
self.fail('Py3 standard library modules should not import on Py2 without explicitly enabling them')
66-
self.assertTrue(True)
67-
6851
def test_str(self):
6952
self.assertIsNot(str, bytes) # Py2: assertIsNot only in 2.7
7053
self.assertEqual(str('blah'), u'blah') # Py3.3 and Py2 only

future/tests/test_standard_library.py

Lines changed: 43 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Tests for the future.standard_library module
33
"""
44

5-
from __future__ import absolute_import, unicode_literals, print_function
5+
from __future__ import absolute_import, print_function
66
from future import standard_library
77
from future import utils
88
from future.tests.base import unittest, CodeHandler, expectedFailurePY2
@@ -64,23 +64,23 @@ def test_is_py2_stdlib_module(self):
6464
not any ([standard_library.is_py2_stdlib_module(module)
6565
for module in py2modules]))
6666

67-
@unittest.skipIf(utils.PY3, 'generic import tests are for Py2 only')
68-
def test_all(self):
69-
"""
70-
Tests whether all of the old imports in RENAMES are accessible
71-
under their new names.
72-
"""
73-
for (oldname, newname) in standard_library.RENAMES.items():
74-
if newname == 'winreg' and sys.platform not in ['win32', 'win64']:
75-
continue
76-
if newname in standard_library.REPLACED_MODULES:
77-
# Skip this check for e.g. the stdlib's ``test`` module,
78-
# which we have replaced completely.
79-
continue
80-
oldmod = __import__(oldname)
81-
newmod = __import__(newname)
82-
if '.' not in oldname:
83-
self.assertEqual(oldmod, newmod)
67+
# @unittest.skip("No longer relevant")
68+
# def test_all_modules_identical(self):
69+
# """
70+
# Tests whether all of the old imports in RENAMES are accessible
71+
# under their new names.
72+
# """
73+
# for (oldname, newname) in standard_library.RENAMES.items():
74+
# if newname == 'winreg' and sys.platform not in ['win32', 'win64']:
75+
# continue
76+
# if newname in standard_library.REPLACED_MODULES:
77+
# # Skip this check for e.g. the stdlib's ``test`` module,
78+
# # which we have replaced completely.
79+
# continue
80+
# oldmod = __import__(oldname)
81+
# newmod = __import__(newname)
82+
# if '.' not in oldname:
83+
# self.assertEqual(oldmod, newmod)
8484

8585
@unittest.expectedFailure
8686
def test_suspend_hooks(self):
@@ -285,7 +285,7 @@ def test_profile(self):
285285

286286
def test_stringio(self):
287287
from io import StringIO
288-
s = StringIO('test')
288+
s = StringIO(u'test')
289289
for method in ['tell', 'read', 'seek', 'close', 'flush']:
290290
self.assertTrue(hasattr(s, method))
291291

@@ -427,9 +427,32 @@ def test_install_aliases(self):
427427
"""
428428
from future.standard_library import remove_hooks, install_aliases
429429
remove_hooks()
430-
self.assertTrue('urllib.request' not in sys.modules)
431430
install_aliases()
431+
432+
from collections import Counter, OrderedDict # backported to Py2.6
433+
from collections import UserDict, UserList, UserString
434+
435+
# Requires Python dbm support:
436+
# import dbm
437+
# import dbm.dumb
438+
# import dbm.gnu
439+
# import dbm.ndbm
440+
441+
from itertools import filterfalse, zip_longest
442+
443+
from subprocess import check_output # backported to Py2.6
444+
from subprocess import getoutput, getstatusoutput
445+
446+
from sys import intern
447+
448+
import test.support
449+
450+
import urllib.error
451+
import urllib.parse
432452
import urllib.request
453+
import urllib.response
454+
import urllib.robotparser
455+
433456
self.assertTrue('urlopen' in dir(urllib.request))
434457

435458

0 commit comments

Comments
 (0)