Skip to content

Commit bdd46af

Browse files
committed
Fix test for six imports mapping
1 parent 43bd952 commit bdd46af

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

tests/test_fix_imports_six.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import absolute_import
22

33
import sys
4+
import unittest
45

56
try:
67
from six.moves import tkinter
@@ -35,13 +36,20 @@ def test_moved_module():
3536
def test_moved_module_fromlist():
3637
check_on_input(*MOVED_MODULE_FROMLIST)
3738

39+
@unittest.skipIf(sys.version_info[0] >= 3, "Test only runs on Python 2")
3840
def test_validate_mapping():
3941
for py2_name, six_name in fix_imports_six.FixImportsSix.mapping.items():
4042
try:
4143
__import__(py2_name)
4244
__import__(six_name)
43-
except ImportError as exc:
44-
if 'tkinter' in six_name and tkinter is not None:
45-
raise
46-
elif 'winreg' in six_name and sys.platform.startswith('win'):
45+
except ImportError:
46+
if 'tkinter' in six_name:
47+
# Ignore error if tkinter not installed
48+
if tkinter is not None:
49+
raise
50+
elif 'winreg' in six_name:
51+
# Ignore error if we're not on Windows
52+
if sys.platform.startswith('win'):
53+
raise
54+
else:
4755
raise

0 commit comments

Comments
 (0)