summaryrefslogtreecommitdiff
path: root/test/engine/test_processors.py
diff options
context:
space:
mode:
authorPhilip Jenvey <pjenvey@underboss.org>2012-03-07 21:48:36 -0800
committerPhilip Jenvey <pjenvey@underboss.org>2012-03-07 21:48:36 -0800
commit94e05e3d878769a565dd836c51b6d4055a9b84c8 (patch)
treec60a32c0fcf43a0fa1eb62eb32325178f071b9c2 /test/engine/test_processors.py
parentbe71c73f614f9c316c0c02a98505a8c03d5ef788 (diff)
downloadsqlalchemy-94e05e3d878769a565dd836c51b6d4055a9b84c8.tar.gz
cleanup test_processors, modeling the PEP 399 style
Diffstat (limited to 'test/engine/test_processors.py')
-rw-r--r--test/engine/test_processors.py97
1 files changed, 25 insertions, 72 deletions
diff --git a/test/engine/test_processors.py b/test/engine/test_processors.py
index 48c0fb8f1..d6b994e78 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