]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
skip profiling tests on Jython and platforms that lack hotshot/cProfile
authorPhilip Jenvey <pjenvey@underboss.org>
Fri, 17 Jul 2009 05:35:02 +0000 (05:35 +0000)
committerPhilip Jenvey <pjenvey@underboss.org>
Fri, 17 Jul 2009 05:35:02 +0000 (05:35 +0000)
lib/sqlalchemy/test/profiling.py
test/aaa_profiling/test_memusage.py

index c2c00c42bd9030454b0e7566058b7ffef4226835..8cab6ceba1525686d333be32865b895372230622 100644 (file)
@@ -6,8 +6,9 @@ in a more fine-grained way than nose's profiling plugin.
 """
 
 import os, sys
+from sqlalchemy.test import config
 from sqlalchemy.test.util import function_named, gc_collect
-import config
+from nose import SkipTest
 
 __all__ = 'profiled', 'function_call_count', 'conditional_call_count'
 
@@ -162,15 +163,22 @@ def conditional_call_count(discriminator, categories):
 def _profile(filename, fn, *args, **kw):
     global profiler
     if not profiler:
-        profiler = 'hotshot'
         if sys.version_info > (2, 5):
             try:
                 import cProfile
                 profiler = 'cProfile'
             except ImportError:
                 pass
+        if not profiler:
+            try:
+                import hotshot
+                profiler = 'hotshot'
+            except ImportError:
+                profiler = 'skip'
 
-    if profiler == 'cProfile':
+    if profiler == 'skip':
+        raise SkipTest('Profiling not supported on this platform')
+    elif profiler == 'cProfile':
         return _profile_cProfile(filename, fn, *args, **kw)
     else:
         return _profile_hotshot(filename, fn, *args, **kw)
index 795bd4b575322dfaf6b5c8e642f07d62ff83c236..fbf0560ca1b079f7c08e74a675086e72dd4fed79 100644 (file)
@@ -2,6 +2,7 @@ from sqlalchemy.test.testing import eq_
 from sqlalchemy.orm import mapper, relation, create_session, clear_mappers, sessionmaker
 from sqlalchemy.orm.mapper import _mapper_registry
 from sqlalchemy.orm.session import _sessions
+from sqlalchemy.util import jython
 import operator
 from sqlalchemy.test import testing
 from sqlalchemy import MetaData, Integer, String, ForeignKey, PickleType
@@ -12,6 +13,10 @@ from sqlalchemy.test.util import gc_collect
 import gc
 from test.orm import _base
 
+if jython:
+    from nose import SkipTest
+    raise SkipTest("Profiling not supported on this platform")
+
 
 class A(_base.ComparableEntity):
     pass
@@ -61,7 +66,7 @@ class EnsureZeroed(_base.ORMTest):
 class MemUsageTest(EnsureZeroed):
     
     # ensure a pure growing test trips the assertion
-    @testing.fails_if(lambda:True)
+    @testing.fails_if(lambda: True)
     def test_fixture(self):
         class Foo(object):
             pass