]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- profile file is configurable
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 26 Sep 2012 23:15:09 +0000 (19:15 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 26 Sep 2012 23:15:09 +0000 (19:15 -0400)
setup.cfg
test/bootstrap/config.py
test/bootstrap/noseplugin.py
test/lib/profiles.txt
test/lib/profiling.py

index 1610fb00f06fe9eb948da3ee304832263473aef3..01e4149c9ce915ab6e5c02ef24729b0e1c547176 100644 (file)
--- a/setup.cfg
+++ b/setup.cfg
@@ -7,8 +7,9 @@ exclude = ^examples
 first-package-wins = true
 where = test
 
-[requirements]
+[sqla_testing]
 requirement_cls=test.lib.requires:DefaultRequirements
+profile_file=test/lib/profiles.txt
 
 [db]
 sqlite=sqlite:///:memory:
index dfaf972b97e3d18e68efd92cadaf0a97fd7250c8..b0e92d630d329c047b007425197be47b5db4730f 100644 (file)
@@ -157,8 +157,8 @@ def _reverse_topological(options, file_config):
 post_configure.append(_reverse_topological)
 
 def _requirements(options, file_config):
-    from test.lib import testing
-    requirement_cls = file_config.get('requirements', "requirement_cls")
+    from ..lib import testing
+    requirement_cls = file_config.get('sqla_testing', "requirement_cls")
 
     modname, clsname = requirement_cls.split(":")
 
@@ -175,3 +175,10 @@ def _requirements(options, file_config):
 
 post_configure.append(_requirements)
 
+
+def _setup_profiling(options, file_config):
+    from ..lib import profiling
+    profiling._profile_stats = profiling.ProfileStatsFile(
+                file_config.get('sqla_testing', 'profile_file'))
+
+post_configure.append(_setup_profiling)
\ No newline at end of file
index 4aec808f9b135f54c6cbe55c02c113c95779910f..5608a06a4f6d7a6f97786ea82337bf59861c22c0 100644 (file)
@@ -3,9 +3,9 @@ import ConfigParser
 
 from nose.plugins import Plugin
 from nose import SkipTest
-from test.bootstrap import config
+from . import config
 
-from test.bootstrap.config import _log, _list_dbs, _zero_timeout, \
+from .config import _log, _list_dbs, _zero_timeout, \
     _engine_strategy, _server_side_cursors, pre_configure,\
     post_configure
 
index bcd30785463a4d78dc7cc59e95be7999b9af77aa..5decc3aaa6724475b4b5a68f78efd19c19991642 100644 (file)
@@ -1,15 +1,15 @@
 # /Users/classic/dev/sqlalchemy/./test/lib/profiles.txt
 # This file is written out on a per-environment basis.
-# For each test in aaa_profiling, the corresponding function and 
+# For each test in aaa_profiling, the corresponding function and
 # environment is located within this file.  If it doesn't exist,
 # the test is skipped.
-# If a callcount does exist, it is compared to what we received. 
+# If a callcount does exist, it is compared to what we received.
 # assertions are raised if the counts do not match.
-# 
-# To add a new callcount test, apply the function_call_count 
-# decorator and re-run the tests using the --write-profiles option - 
+#
+# To add a new callcount test, apply the function_call_count
+# decorator and re-run the tests using the --write-profiles option -
 # this file will be rewritten including the new count.
-# 
+#
 
 # TEST: test.aaa_profiling.test_compiler.CompileTest.test_insert
 
index dbf96958674f70df7b9d6d37ebfc8fa80f6cb0bb..ab0bc3f2b91bf3c6e9702316780f5e2dadb80fbc 100644 (file)
@@ -92,12 +92,10 @@ class ProfileStatsFile(object):
     so no json lib :(  need to roll something silly
 
     """
-    def __init__(self):
-        from test.bootstrap.config import options
-        self.write = options is not None and options.write_profiles
-        dirname, fname = os.path.split(__file__)
-        self.short_fname = "profiles.txt"
-        self.fname = os.path.join(dirname, self.short_fname)
+    def __init__(self, filename):
+        self.write = config.options is not None and config.options.write_profiles
+        self.fname = os.path.abspath(filename)
+        self.short_fname = os.path.split(self.fname)[-1]
         self.data = collections.defaultdict(lambda: collections.defaultdict(dict))
         self._read()
         if self.write:
@@ -206,8 +204,6 @@ class ProfileStatsFile(object):
                 )
         profile_f.close()
 
-_profile_stats = ProfileStatsFile()
-
 from sqlalchemy.util.compat import update_wrapper
 
 def function_call_count(variance=0.05):