From: Mike Bayer Date: Mon, 5 Jul 2010 23:54:46 +0000 (-0400) Subject: - latest distribute X-Git-Tag: rel_0_6_2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a9f2ed7b4650e3e546c53666bb3f4a0c48a82c54;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - latest distribute - added caveats to unittest README encountered with Py2.7 + current nose 0.11.3 - call counts for py2.7. all tests pass for sqlite + mysql-python + psycopg2 --- diff --git a/README.unittests b/README.unittests index 37a6e49105..ca76997435 100644 --- a/README.unittests +++ b/README.unittests @@ -25,6 +25,9 @@ A plain vanilla run of all tests using sqlite can be run via setup.py: $ python setup.py test +(NOTE: this command is broken for Python 2.7 with nose 0.11.3, see +Nose issue 340. You will need to use 'nosetests' directly, see below.) + Setuptools will take care of the rest ! To run nose directly and have its full set of options available, read on... @@ -48,6 +51,9 @@ To run all tests: $ nosetests +(NOTE: if running with Python 2.7 and nose 0.11.3, add "-w test/" to the command. +Again this is a Nose issue, see Nose issue 342.) + If you're running the tests on Microsoft Windows, then there is an additional argument that must be passed to nosetests: diff --git a/distribute_setup.py b/distribute_setup.py index 002133624d..37117b34eb 100644 --- a/distribute_setup.py +++ b/distribute_setup.py @@ -46,7 +46,7 @@ except ImportError: args = [quote(arg) for arg in args] return os.spawnl(os.P_WAIT, sys.executable, *args) == 0 -DEFAULT_VERSION = "0.6.10" +DEFAULT_VERSION = "0.6.13" DEFAULT_URL = "http://pypi.python.org/packages/source/d/distribute/" SETUPTOOLS_FAKED_VERSION = "0.6c11" @@ -203,6 +203,29 @@ def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, dst.close() return os.path.realpath(saveto) +def _no_sandbox(function): + def __no_sandbox(*args, **kw): + try: + from setuptools.sandbox import DirectorySandbox + if not hasattr(DirectorySandbox, '_old'): + def violation(*args): + pass + DirectorySandbox._old = DirectorySandbox._violation + DirectorySandbox._violation = violation + patched = True + else: + patched = False + except ImportError: + patched = False + + try: + return function(*args, **kw) + finally: + if patched: + DirectorySandbox._violation = DirectorySandbox._old + del DirectorySandbox._old + + return __no_sandbox def _patch_file(path, content): """Will backup the file then patch it""" @@ -220,32 +243,11 @@ def _patch_file(path, content): f.close() return True +_patch_file = _no_sandbox(_patch_file) def _same_content(path, content): return open(path).read() == content -def _no_sandbox(function): - def __no_sandbox(*args, **kw): - try: - from setuptools.sandbox import DirectorySandbox - def violation(*args): - pass - DirectorySandbox._old = DirectorySandbox._violation - DirectorySandbox._violation = violation - patched = True - except ImportError: - patched = False - - try: - return function(*args, **kw) - finally: - if patched: - DirectorySandbox._violation = DirectorySandbox._old - del DirectorySandbox._old - - return __no_sandbox - -@_no_sandbox def _rename_path(path): new_name = path + '.OLD.%s' % time.time() log.warn('Renaming %s into %s', path, new_name) @@ -285,13 +287,13 @@ def _remove_flat_installation(placeholder): 'Setuptools distribution', element) return True +_remove_flat_installation = _no_sandbox(_remove_flat_installation) def _after_install(dist): log.warn('After install bootstrap.') placeholder = dist.get_command_obj('install').install_purelib _create_fake_setuptools_pkg_info(placeholder) -@_no_sandbox def _create_fake_setuptools_pkg_info(placeholder): if not placeholder or not os.path.exists(placeholder): log.warn('Could not find the install location') @@ -319,6 +321,8 @@ def _create_fake_setuptools_pkg_info(placeholder): finally: f.close() +_create_fake_setuptools_pkg_info = _no_sandbox(_create_fake_setuptools_pkg_info) + def _patch_egg_dir(path): # let's check if it's already patched pkg_info = os.path.join(path, 'EGG-INFO', 'PKG-INFO') @@ -337,6 +341,7 @@ def _patch_egg_dir(path): f.close() return True +_patch_egg_dir = _no_sandbox(_patch_egg_dir) def _before_install(): log.warn('Before install bootstrap.') @@ -356,8 +361,8 @@ def _under_prefix(location): if len(args) > index: top_dir = args[index+1] return location.startswith(top_dir) - elif option == '--user' and USER_SITE is not None: - return location.startswith(USER_SITE) + if arg == '--user' and USER_SITE is not None: + return location.startswith(USER_SITE) return True @@ -416,6 +421,9 @@ def _fake_setuptools(): def _relaunch(): log.warn('Relaunching...') # we have to relaunch the process + # pip marker to avoid a relaunch bug + if sys.argv[:3] == ['-c', 'install', '--single-version-externally-managed']: + sys.argv[0] = 'setup.py' args = [sys.executable] + sys.argv sys.exit(subprocess.call(args)) diff --git a/test/aaa_profiling/test_compiler.py b/test/aaa_profiling/test_compiler.py index dc02cece45..a7f64410b1 100644 --- a/test/aaa_profiling/test_compiler.py +++ b/test/aaa_profiling/test_compiler.py @@ -25,7 +25,8 @@ class CompileTest(TestBase, AssertsExecutionResults): for t in types.type_map.values(): t._type_affinity - @profiling.function_call_count(69, {'2.4': 44, '3.0':77, '3.1':77}) + @profiling.function_call_count(69, {'2.4': 44, + '3.0':77, '3.1':77}) def test_insert(self): t1.insert().compile() @@ -37,7 +38,8 @@ class CompileTest(TestBase, AssertsExecutionResults): def test_update_whereclause(self): t1.update().where(t1.c.c2==12).compile() - @profiling.function_call_count(195, versions={'2.4':118, '3.0':208, '3.1':208}) + @profiling.function_call_count(195, versions={'2.4':118, + '3.0':208, '3.1':208}) def test_select(self): s = select([t1], t1.c.c2==t2.c.c1) s.compile() diff --git a/test/aaa_profiling/test_pool.py b/test/aaa_profiling/test_pool.py index 0ce48e2a79..c4f5191fec 100644 --- a/test/aaa_profiling/test_pool.py +++ b/test/aaa_profiling/test_pool.py @@ -18,7 +18,9 @@ class QueuePoolTest(TestBase, AssertsExecutionResults): use_threadlocal=True) - @profiling.function_call_count(64, {'2.4': 42, '3.0':65, '3.1':65}) + @profiling.function_call_count(64, {'2.4': 42, '2.7':59, + '2.7+cextension':59, + '3.0':65, '3.1':65}) def test_first_connect(self): conn = pool.connect() @@ -26,7 +28,8 @@ class QueuePoolTest(TestBase, AssertsExecutionResults): conn = pool.connect() conn.close() - @profiling.function_call_count(32, {'2.4': 21}) + @profiling.function_call_count(32, {'2.4': 21, '2.7':29, + '2.7+cextension':29}) def go(): conn2 = pool.connect() return conn2 diff --git a/test/aaa_profiling/test_zoomark.py b/test/aaa_profiling/test_zoomark.py index 6b567c0c57..43b3e4b091 100644 --- a/test/aaa_profiling/test_zoomark.py +++ b/test/aaa_profiling/test_zoomark.py @@ -339,11 +339,16 @@ class ZooMarkTest(TestBase): def test_profile_3_properties(self): self.test_baseline_3_properties() - @profiling.function_call_count(13341, {'2.4': 7963, '2.6+cextension':12447}) + @profiling.function_call_count(13341, {'2.4': 7963, + '2.6+cextension':12447, + '2.7+cextension':12447}) def test_profile_4_expressions(self): self.test_baseline_4_expressions() - @profiling.function_call_count(1311, {'2.4': 904, '2.6+cextension':1226}) + @profiling.function_call_count(1311, {'2.4': 904, + '2.6+cextension':1226, + '2.7+cextension':1226, + }) def test_profile_5_aggregates(self): self.test_baseline_5_aggregates() diff --git a/test/aaa_profiling/test_zoomark_orm.py b/test/aaa_profiling/test_zoomark_orm.py index 0820d7cc46..6e8cbd8e60 100644 --- a/test/aaa_profiling/test_zoomark_orm.py +++ b/test/aaa_profiling/test_zoomark_orm.py @@ -300,16 +300,19 @@ class ZooMarkTest(TestBase): self.test_baseline_2_insert() # this number... - @profiling.function_call_count(6783, {'2.6':7194, '2.6+cextension':7184}) + @profiling.function_call_count(6783, {'2.6':7194, '2.7':7298, + '2.7+cextension':7288, + '2.6+cextension':7184}) def test_profile_3_properties(self): self.test_baseline_3_properties() # and this number go down slightly when using the C extensions - @profiling.function_call_count(22510, {'2.6':24055}) + @profiling.function_call_count(22510, {'2.6':24055, '2.7':24214}) def test_profile_4_expressions(self): self.test_baseline_4_expressions() - @profiling.function_call_count(1313, {'2.6+cextension':1236}) + @profiling.function_call_count(1313, {'2.6+cextension':1236, + '2.7+cextension':1207}) def test_profile_5_aggregates(self): self.test_baseline_5_aggregates()