X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=tests%2Ftest_mysql2postgres.py;h=6782c5408eeef1b33335339da8e32a7ac9126ed8;hb=d73e4faa556e337eba2ffece77ae3d114bfc3da0;hp=37edb57aab0bab4ccc7a6c398343a5e45314513c;hpb=00f0aef5739a19921ed06f0397b44ba336184424;p=sqlconvert.git diff --git a/tests/test_mysql2postgres.py b/tests/test_mysql2postgres.py index 37edb57..6782c54 100644 --- a/tests/test_mysql2postgres.py +++ b/tests/test_mysql2postgres.py @@ -1,10 +1,14 @@ from sqlparse import parse from sqlobject.tests.dbtest import getConnection -import py.test +import pytest from sqlconvert.print_tokens import tlist2str from sqlconvert.process_mysql import unescape_strings +from sqlconvert.process_tokens import escape_strings +connection = getConnection() +pytestmark = pytest.mark.skipif(connection.dbName != "postgres", + reason="This test requires PostgreSQL") create_postgres_test_table = """ CREATE TABLE test ( @@ -15,15 +19,14 @@ CREATE TABLE test ( def test_mysql2postgres_string(): - connection = getConnection() - if connection.dbName != "postgres": - py.test.skip("This test requires PostgreSQL") connection.query(create_postgres_test_table) - parsed = parse("insert into test (id, test_str) " - "values (1, '\"te\\'st\\\"')")[0] + parsed = parse("insert into test (id, test_str) values " + "(1, '\"te\\'st\\\"\\n')")[0] unescape_strings(parsed) + escape_strings(parsed, 'postgres') query = tlist2str(parsed) - assert query == u"INSERT INTO test (id, test_str) VALUES (1, '\"te''st\"')" + assert query == u"INSERT INTO test (id, test_str) VALUES " \ + u"(1, E'\"te''st\"\\n')" connection.query(query) test_str = connection.queryOne("SELECT test_str FROM test WHERE id=1")[0] - assert test_str == u"\"te'st\"" + assert test_str == u"\"te'st\"\n"