From: Philip Jenvey Date: Thu, 8 Mar 2012 05:48:36 +0000 (-0800) Subject: cleanup test_processors, modeling the PEP 399 style X-Git-Tag: rel_0_7_6~20^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=94e05e3d878769a565dd836c51b6d4055a9b84c8;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git cleanup test_processors, modeling the PEP 399 style --- diff --git a/test/engine/test_processors.py b/test/engine/test_processors.py index 48c0fb8f19..d6b994e786 100644 --- a/test/engine/test_processors.py +++ b/test/engine/test_processors.py @@ -1,107 +1,60 @@ -from test.lib.testing import eq_, assert_raises, assert_raises_message -from test.lib import testing, fixtures +from test.lib import fixtures +from test.lib.testing import assert_raises_message +from sqlalchemy import processors try: - from sqlalchemy.cprocessors import str_to_datetime as c_str_to_datetime, \ - str_to_date as c_str_to_date, \ - str_to_time as c_str_to_time - from sqlalchemy.processors import py_fallback - for key, value in py_fallback().items(): - globals()["py_%s" % key] = value -except: - from sqlalchemy.processors import str_to_datetime as py_str_to_datetime, \ - str_to_date as py_str_to_date, \ - str_to_time as py_str_to_time + from sqlalchemy import cprocessors +except ImportError: + cprocessors = None -class DateProcessorTest(fixtures.TestBase): - @testing.requires.cextensions - def test_c_date_no_string(self): +class _DateProcessorTest(fixtures.TestBase): + def test_date_no_string(self): assert_raises_message( ValueError, "Couldn't parse date string '2012' - value is not a string", - c_str_to_date, 2012 + self.module.str_to_date, 2012 ) - def test_py_date_no_string(self): - assert_raises_message( - ValueError, - "Couldn't parse date string '2012' - value is not a string", - py_str_to_date, 2012 - ) - - @testing.requires.cextensions - def test_c_datetime_no_string(self): + def test_datetime_no_string(self): assert_raises_message( ValueError, "Couldn't parse datetime string '2012' - value is not a string", - c_str_to_datetime, 2012 - ) - - def test_py_datetime_no_string(self): - assert_raises_message( - ValueError, - "Couldn't parse datetime string '2012' - value is not a string", - py_str_to_datetime, 2012 - ) - - @testing.requires.cextensions - def test_c_time_no_string(self): - assert_raises_message( - ValueError, - "Couldn't parse time string '2012' - value is not a string", - c_str_to_time, 2012 + self.module.str_to_datetime, 2012 ) - def test_py_time_no_string(self): + def test_time_no_string(self): assert_raises_message( ValueError, "Couldn't parse time string '2012' - value is not a string", - py_str_to_time, 2012 + self.module.str_to_time, 2012 ) - @testing.requires.cextensions - def test_c_date_invalid_string(self): + def test_date_invalid_string(self): assert_raises_message( ValueError, "Couldn't parse date string: '5:a'", - c_str_to_date, "5:a" + self.module.str_to_date, "5:a" ) - def test_py_date_invalid_string(self): - assert_raises_message( - ValueError, - "Couldn't parse date string: '5:a'", - py_str_to_date, "5:a" - ) - - @testing.requires.cextensions - def test_c_datetime_invalid_string(self): + def test_datetime_invalid_string(self): assert_raises_message( ValueError, "Couldn't parse datetime string: '5:a'", - c_str_to_datetime, "5:a" + self.module.str_to_datetime, "5:a" ) - def test_py_datetime_invalid_string(self): - assert_raises_message( - ValueError, - "Couldn't parse datetime string: '5:a'", - py_str_to_datetime, "5:a" - ) - - @testing.requires.cextensions - def test_c_time_invalid_string(self): + def test_time_invalid_string(self): assert_raises_message( ValueError, "Couldn't parse time string: '5:a'", - c_str_to_time, "5:a" + self.module.str_to_time, "5:a" ) - def test_py_time_invalid_string(self): - assert_raises_message( - ValueError, - "Couldn't parse time string: '5:a'", - py_str_to_time, "5:a" - ) + +class PyDateProcessorTest(_DateProcessorTest): + module = processors +class CDateProcessorTest(_DateProcessorTest): + __requires__ = ('cextensions',) + module = cprocessors