]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- rework the profile thing to just rewrite all failing numbers when --write-profiles...
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 28 Aug 2013 04:04:38 +0000 (00:04 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 28 Aug 2013 04:04:38 +0000 (00:04 -0400)
- some sqlite callcounts

lib/sqlalchemy/testing/profiling.py
test/profiles.txt

index bda44d80ccec755953891c4507a780fb2ce610d5..2e0a5babcdabf8aa944ddf5d4e0e9ddda4b266b8 100644 (file)
@@ -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
index a89be0e1505404464fb52852c59e271aa6cf32f6..fc13bedc10417e0af060173fb146964049d0d450 100644 (file)
@@ -324,7 +324,7 @@ test.aaa_profiling.test_resultset.ResultSetTest.test_string 2.7_mysql_mysqldb_no
 test.aaa_profiling.test_resultset.ResultSetTest.test_string 2.7_oracle_cx_oracle_nocextensions 35582
 test.aaa_profiling.test_resultset.ResultSetTest.test_string 2.7_postgresql_psycopg2_cextensions 20471
 test.aaa_profiling.test_resultset.ResultSetTest.test_string 2.7_postgresql_psycopg2_nocextensions 35491
-test.aaa_profiling.test_resultset.ResultSetTest.test_string 2.7_sqlite_pysqlite_cextensions 427
+test.aaa_profiling.test_resultset.ResultSetTest.test_string 2.7_sqlite_pysqlite_cextensions 455
 test.aaa_profiling.test_resultset.ResultSetTest.test_string 2.7_sqlite_pysqlite_nocextensions 15447
 test.aaa_profiling.test_resultset.ResultSetTest.test_string 3.2_postgresql_psycopg2_nocextensions 14459
 test.aaa_profiling.test_resultset.ResultSetTest.test_string 3.2_sqlite_pysqlite_nocextensions 14430
@@ -342,7 +342,7 @@ test.aaa_profiling.test_resultset.ResultSetTest.test_unicode 2.7_mysql_mysqldb_n
 test.aaa_profiling.test_resultset.ResultSetTest.test_unicode 2.7_oracle_cx_oracle_nocextensions 35572
 test.aaa_profiling.test_resultset.ResultSetTest.test_unicode 2.7_postgresql_psycopg2_cextensions 20471
 test.aaa_profiling.test_resultset.ResultSetTest.test_unicode 2.7_postgresql_psycopg2_nocextensions 35491
-test.aaa_profiling.test_resultset.ResultSetTest.test_unicode 2.7_sqlite_pysqlite_cextensions 427
+test.aaa_profiling.test_resultset.ResultSetTest.test_unicode 2.7_sqlite_pysqlite_cextensions 455
 test.aaa_profiling.test_resultset.ResultSetTest.test_unicode 2.7_sqlite_pysqlite_nocextensions 15447
 test.aaa_profiling.test_resultset.ResultSetTest.test_unicode 3.2_postgresql_psycopg2_nocextensions 14459
 test.aaa_profiling.test_resultset.ResultSetTest.test_unicode 3.2_sqlite_pysqlite_nocextensions 14430