Permalink
Browse files

make sure sitecustomize.py doesn't grow in the FastTestPipEnvironment

  • Loading branch information...
1 parent 1d1363b commit faee69bdabf98a788faf6721091d7392f8c9f701 @qwcode committed Jun 14, 2012
Showing with 29 additions and 0 deletions.
  1. +13 −0 tests/test_pip.py
  2. +16 −0 tests/test_test.py
View
@@ -355,6 +355,9 @@ def __init__(self, environ=None, use_distribute=None, sitecustomize=None):
# Install this version instead
self.run('python', 'setup.py', 'install', cwd=src_folder, expect_stderr=True)
+
+ #create sitecustomize.py and add patches
+ self._create_empty_sitecustomize()
self._use_cached_pypi_server()
if sitecustomize:
self._add_to_sitecustomize(sitecustomize)
@@ -394,6 +397,12 @@ def _use_cached_pypi_server(self):
sys.path.remove(%r)""" % (str(here), str(here))
self._add_to_sitecustomize(patch)
+ def _create_empty_sitecustomize(self):
+ "Create empty sitecustomize.py."
+ sitecustomize_path = self.lib_path / 'sitecustomize.py'
+ sitecustomize = open(sitecustomize_path, 'w')
+ sitecustomize.close()
+
def _add_to_sitecustomize(self, snippet):
"Adds a python code snippet to sitecustomize.py."
sitecustomize_path = self.lib_path / 'sitecustomize.py'
@@ -492,9 +501,13 @@ def __init__(self, environ=None, sitecustomize=None):
# Install this version instead
self.run('python', 'setup.py', 'install', cwd=src_folder, expect_stderr=True)
shutil.copytree(self.root_path, self.backup_path, True)
+
+ #create sitecustomize.py and add patches
+ self._create_empty_sitecustomize()
self._use_cached_pypi_server()
if sitecustomize:
self._add_to_sitecustomize(sitecustomize)
+
assert self.root_path.exists
def __del__(self):
View
@@ -1,6 +1,7 @@
"""Test the test support."""
import sys
+import os
from os.path import abspath, join, curdir, isdir, isfile
from nose import SkipTest
from tests.local_repos import local_checkout
@@ -50,3 +51,18 @@ def test_add_patch_to_sitecustomize_fast():
assert "sitecustomize"== result.stdout.strip(), result.stdout
+def test_sitecustomize_not_growing_in_fast_environment():
+ """
+ Test that the sitecustomize is not growing with redundant patches in the cached fast environment
+ """
+
+ patch = "fu = 'bar'"
+
+ env1 = reset_env(sitecustomize=patch)
+ sc1 = env1.lib_path / 'sitecustomize.py'
+ size1 = os.stat(sc1).st_size
+ env2 = reset_env(sitecustomize=patch)
+ sc2 = env2.lib_path / 'sitecustomize.py'
+ size2 = os.stat(sc2).st_size
+ assert size1==size2, "size before, %d != size after, %d" %(size1, size2)
+

0 comments on commit faee69b

Please sign in to comment.