import os
import py_compile
import random
-import shutil
import stat
import sys
import unittest
-from test.test_support import (unlink, TESTFN, unload, run_unittest,
+from test.test_support import (unlink, TESTFN, unload, run_unittest, rmtree,
is_jython, check_warnings, EnvironmentVarGuard)
self.assertIs(orig_path, new_os.path)
self.assertIsNot(orig_getenv, new_os.getenv)
+ def test_bug7732(self):
+ source = TESTFN + '.py'
+ os.mkdir(source)
+ try:
+ self.assertRaises(IOError, imp.find_module, TESTFN, ["."])
+ finally:
+ rmtree(source)
+
def test_module_with_large_stack(self, module='longlist'):
# Regression test for http://bugs.python.org/issue561858.
filename = module + os.extsep + 'py'
unload(self.module_name)
unlink(self.file_name)
unlink(self.compiled_name)
- if os.path.exists(self.dir_name):
- shutil.rmtree(self.dir_name)
+ rmtree(self.dir_name)
def import_module(self):
ns = globals()
self.syspath = sys.path[:]
def tearDown(self):
- shutil.rmtree(self.path)
+ rmtree(self.path)
sys.path[:] = self.syspath
# Regression test for http://bugs.python.org/issue1293.
self.assertRaises(ValueError, check_relative)
def test_absolute_import_without_future(self):
- # If absolute import syntax is used, then do not try to perform
- # a relative import in the face of failure.
+ # If explicit relative import syntax is used, then do not try
+ # to perform an absolute import in the face of failure.
# Issue #7902.
- try:
+ with self.assertRaises(ImportError):
from .os import sep
- except ImportError:
- pass
- else:
self.fail("explicit relative import triggered an "
- "implicit relative import")
+ "implicit absolute import")
def test_main(verbose=None):