From: Paul Johnston Date: Sun, 19 Aug 2007 15:30:02 +0000 (+0000) Subject: mssql unit test fixes X-Git-Tag: rel_0_4beta4~37 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1b1da969ebe582c4831c298dfa27e87719b1f329;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git mssql unit test fixes --- diff --git a/test/orm/assorted_eager.py b/test/orm/assorted_eager.py index 59fa2891ee..c98ffeb962 100644 --- a/test/orm/assorted_eager.py +++ b/test/orm/assorted_eager.py @@ -717,10 +717,10 @@ class EagerTest8(ORMTest): ) def setUp(self): - testbase.db.execute("INSERT INTO prj (title) values('project 1');") - testbase.db.execute("INSERT INTO task_status (id) values(1);") - testbase.db.execute("INSERT INTO task_type(id) values(1);") - testbase.db.execute("INSERT INTO task (title, task_type_id, status_id, prj_id) values('task 1',1,1,1);") + testbase.db.execute(project_t.insert(), {'id':1}) + testbase.db.execute(task_status_t.insert(), {'id':1}) + testbase.db.execute(task_type_t.insert(), {'id':1}) + testbase.db.execute(task_t.insert(), {'title':'task 1', 'task_type_id':1, 'status_id':1, 'prj_id':1}) def test_nested_joins(self): # this is testing some subtle column resolution stuff, diff --git a/test/sql/testtypes.py b/test/sql/testtypes.py index 4ffb4c5916..e355436ec1 100644 --- a/test/sql/testtypes.py +++ b/test/sql/testtypes.py @@ -356,8 +356,8 @@ class DateTest(AssertMixin): ] if db.engine.name == 'mssql': - # MSSQL Datetime values have only a 3.33 milliseconds precision - insert_data[2] = [9, 'foo', datetime.datetime(2005, 11, 10, 11, 52, 35, 547000), datetime.date(1970,4,1), datetime.time(23,59,59,997000)] + # MSSQL can't reliably fetch the millisecond part + insert_data[2] = [9, 'foo', datetime.datetime(2005, 11, 10, 11, 52, 35), datetime.date(1970,4,1), datetime.time(23,59,59)] fnames = ['user_id', 'user_name', 'user_datetime', 'user_date', 'user_time'] diff --git a/test/testlib/testing.py b/test/testlib/testing.py index 58fd7c0d10..0038fddfe9 100644 --- a/test/testlib/testing.py +++ b/test/testlib/testing.py @@ -128,6 +128,8 @@ class ExecutionContextWrapper(object): ctx = self.ctx statement = unicode(ctx.compiled) statement = re.sub(r'\n', '', ctx.statement) + if config.db.name == 'mssql' and statement.endswith('; select scope_identity()'): + statement = statement[:-25] if testdata.buffer is not None: testdata.buffer.write(statement + "\n") @@ -168,8 +170,6 @@ class ExecutionContextWrapper(object): parameters = [p.get_original_dict() for p in ctx.compiled_parameters] query = self.convert_statement(query) - if config.db.name == 'mssql' and statement.endswith('; select scope_identity()'): - statement = statement[:-25] testdata.unittest.assert_(statement == query and (params is None or params == parameters), "Testing for query '%s' params %s, received '%s' with params %s" % (query, repr(params), statement, repr(parameters))) testdata.sql_count += 1 self.ctx.post_execution()