summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing/profiling.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2013-08-28 00:04:38 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2013-08-28 00:04:38 -0400
commit87b9f48c57bbbc75eb907509002e6a9687b85cdf (patch)
treeaf06143496426dd106d539a21a41b28497e4dd3f /lib/sqlalchemy/testing/profiling.py
parent5672f78806c4f9bcdfe383dad8a7c0575f2bb042 (diff)
downloadsqlalchemy-87b9f48c57bbbc75eb907509002e6a9687b85cdf.tar.gz
- rework the profile thing to just rewrite all failing numbers when --write-profiles is set
- some sqlite callcounts
Diffstat (limited to 'lib/sqlalchemy/testing/profiling.py')
-rw-r--r--lib/sqlalchemy/testing/profiling.py24
1 files changed, 18 insertions, 6 deletions
diff --git a/lib/sqlalchemy/testing/profiling.py b/lib/sqlalchemy/testing/profiling.py
index bda44d80c..2e0a5babc 100644
--- a/lib/sqlalchemy/testing/profiling.py
+++ b/lib/sqlalchemy/testing/profiling.py
@@ -162,6 +162,15 @@ class ProfileStatsFile(object):
per_platform['current_count'] += 1
return result
+ def replace(self, callcount):
+ test_key = _current_test
+ per_fn = self.data[test_key]
+ per_platform = per_fn[self.platform_key]
+ counts = per_platform['counts']
+ counts[-1] = callcount
+ if self.write:
+ self._write()
+
def _header(self):
return \
"# %s\n"\
@@ -263,16 +272,19 @@ def function_call_count(variance=0.05):
if expected_count:
deviance = int(callcount * variance)
- if abs(callcount - expected_count) > deviance:
+ failed = abs(callcount - expected_count) > deviance
+
+ if failed:
+ if _profile_stats.write:
+ _profile_stats.replace(callcount)
+ else:
raise AssertionError(
"Adjusted function call count %s not within %s%% "
- "of expected %s. (Delete line %d of file %s to "
- "regenerate this callcount, when tests are run "
- "with --write-profiles.)"
+ "of expected %s. Rerun with --write-profiles to "
+ "regenerate this callcount."
% (
callcount, (variance * 100),
- expected_count, line_no,
- _profile_stats.fname))
+ expected_count))
return fn_result
return update_wrapper(wrap, fn)
return decorate