]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- latest distribute
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 5 Jul 2010 23:54:46 +0000 (19:54 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 5 Jul 2010 23:54:46 +0000 (19:54 -0400)
- 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

README.unittests
distribute_setup.py
test/aaa_profiling/test_compiler.py
test/aaa_profiling/test_pool.py
test/aaa_profiling/test_zoomark.py
test/aaa_profiling/test_zoomark_orm.py

index 37a6e49105b624b0d902687cc332049466d741b7..ca76997435aea62a8de7ccb21fd63aa3616dc7bc 100644 (file)
@@ -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:
 
index 002133624dcc3950b99276e135b3402853596fd2..37117b34eb985005751226fe4c14285d78bf5f95 100644 (file)
@@ -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))
 
index dc02cece456b461911da86faa67e536c72e6ef4a..a7f64410b1e7eb439e2feaa03a9783fa4616f657 100644 (file)
@@ -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()
index 0ce48e2a79da01da54e7d61388ffa9d2f1c87d44..c4f5191fec331810017649f89f9dc57c2d0fa80c 100644 (file)
@@ -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
index 6b567c0c5761b7bff053b8128582d5339aaf2d9f..43b3e4b0910c3a321b7ffbfc182e54b58cadf41c 100644 (file)
@@ -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()
 
index 0820d7cc46de7f49e7eb346363b19628a371ca5b..6e8cbd8e6005c3916136b288c9cb3bac4efa2e31 100644 (file)
@@ -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()