Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add a wrapper to reload modules (py3k compatibility)

  • Loading branch information...
commit 38d7f5a69f3d5d07dc32a9e939b3b04d0262e9ed 1 parent 20e6bd5
@hltbra hltbra authored
Showing with 12 additions and 4 deletions.
  1. +3 −4 tests/test_locations.py
  2. +9 −0 tests/test_pip.py
View
7 tests/test_locations.py
@@ -3,7 +3,7 @@
import os.path
from mock import patch
from nose.tools import assert_equal
-from tests.test_pip import without_real_prefix
+from tests.test_pip import without_real_prefix, reload_module
@patch('sys.prefix', '/path/to/fake/sys.prefix')
@@ -11,7 +11,7 @@
def test_build_prefix_and_src_prefix_should_use_sys_prefix_dir_if_under_virtualenv():
# reload module because it was imported before the test method
import pip.locations
- reload(pip.locations)
+ reload_module(pip.locations)
from pip.locations import build_prefix, src_prefix
@@ -26,7 +26,7 @@ def test_build_prefix_and_src_prefix_should_use_sys_prefix_dir_if_under_virtuale
def test_build_prefix_and_src_prefix_should_use_default_storage_dir_if_not_under_virtualenv():
# reload module because it was imported before the test method
import pip.locations
- reload(pip.locations)
+ reload_module(pip.locations)
from pip.locations import build_prefix, src_prefix, default_storage_dir
@@ -35,4 +35,3 @@ def test_build_prefix_and_src_prefix_should_use_default_storage_dir_if_not_under
assert_equal(expected_build_prefix, build_prefix)
assert_equal(expected_src_prefix, src_prefix)
-
View
9 tests/test_pip.py
@@ -603,6 +603,15 @@ def newfn(*args, **kw):
return newfn
+def reload_module(module):
+ # python 3 compatible
+ try:
+ reload(module)
+ except NameError:
+ import imp
+ imp.reload(module)
+
+
def _create_test_package(env):
mkdir('version_pkg')
version_pkg_path = env.scratch_path/'version_pkg'
Please sign in to comment.
Something went wrong with that request. Please try again.