summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2012-09-26 19:15:09 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2012-09-26 19:15:09 -0400
commit21cac5b598a83ef0e24423dc523629b475aa3af0 (patch)
treebe4ea137029eabc43caf198852097f03c24f6f53
parent1a7778632d8039bd687e23522ce6c027e859d487 (diff)
downloadsqlalchemy-21cac5b598a83ef0e24423dc523629b475aa3af0.tar.gz
- profile file is configurable
-rw-r--r--setup.cfg3
-rw-r--r--test/bootstrap/config.py11
-rw-r--r--test/bootstrap/noseplugin.py4
-rw-r--r--test/lib/profiles.txt12
-rw-r--r--test/lib/profiling.py12
5 files changed, 23 insertions, 19 deletions
diff --git a/setup.cfg b/setup.cfg
index 1610fb00f..01e4149c9 100644
--- 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:
diff --git a/test/bootstrap/config.py b/test/bootstrap/config.py
index dfaf972b9..b0e92d630 100644
--- a/test/bootstrap/config.py
+++ b/test/bootstrap/config.py
@@ -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
diff --git a/test/bootstrap/noseplugin.py b/test/bootstrap/noseplugin.py
index 4aec808f9..5608a06a4 100644
--- a/test/bootstrap/noseplugin.py
+++ b/test/bootstrap/noseplugin.py
@@ -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
diff --git a/test/lib/profiles.txt b/test/lib/profiles.txt
index bcd307854..5decc3aaa 100644
--- a/test/lib/profiles.txt
+++ b/test/lib/profiles.txt
@@ -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
diff --git a/test/lib/profiling.py b/test/lib/profiling.py
index dbf969586..ab0bc3f2b 100644
--- a/test/lib/profiling.py
+++ b/test/lib/profiling.py
@@ -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):