mirror of
https://github.com/sqlalchemy/sqlalchemy.git
synced 2026-05-18 14:42:01 -04:00
d050193daa
The major action here is to lift and move future.Connection and future.Engine fully into sqlalchemy.engine.base. This removes lots of engine concepts, including: * autocommit * Connection running without a transaction, autobegin is now present in all cases * most "autorollback" is obsolete * Core-level subtransactions (i.e. MarkerTransaction) * "branched" connections, copies of connections * execution_options() returns self, not a new connection * old argument formats, distill_params(), simplifies calling scheme between engine methods * before/after_execute() events (oriented towards compiled constructs) don't emit for exec_driver_sql(). before/after_cursor_execute() is still included for this * old helper methods superseded by context managers, connection.transaction(), engine.transaction() engine.run_callable() * ancient engine-level reflection methods has_table(), table_names() * sqlalchemy.testing.engines.proxying_engine References: #7257 Change-Id: Ib20ed816642d873b84221378a9ec34480e01e82c
106 lines
2.7 KiB
Python
106 lines
2.7 KiB
Python
from sqlalchemy.testing import assert_raises_message
|
|
from sqlalchemy.testing import eq_
|
|
from sqlalchemy.testing import fixtures
|
|
|
|
|
|
class _BooleanProcessorTest(fixtures.TestBase):
|
|
def test_int_to_bool_none(self):
|
|
eq_(self.module.int_to_boolean(None), None)
|
|
|
|
def test_int_to_bool_zero(self):
|
|
eq_(self.module.int_to_boolean(0), False)
|
|
|
|
def test_int_to_bool_one(self):
|
|
eq_(self.module.int_to_boolean(1), True)
|
|
|
|
def test_int_to_bool_positive_int(self):
|
|
eq_(self.module.int_to_boolean(12), True)
|
|
|
|
def test_int_to_bool_negative_int(self):
|
|
eq_(self.module.int_to_boolean(-4), True)
|
|
|
|
|
|
class CBooleanProcessorTest(_BooleanProcessorTest):
|
|
__requires__ = ("cextensions",)
|
|
|
|
@classmethod
|
|
def setup_test_class(cls):
|
|
from sqlalchemy import cprocessors
|
|
|
|
cls.module = cprocessors
|
|
|
|
|
|
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",
|
|
self.module.str_to_date,
|
|
2012,
|
|
)
|
|
|
|
def test_datetime_no_string(self):
|
|
assert_raises_message(
|
|
ValueError,
|
|
"Couldn't parse datetime string '2012' - value is not a string",
|
|
self.module.str_to_datetime,
|
|
2012,
|
|
)
|
|
|
|
def test_time_no_string(self):
|
|
assert_raises_message(
|
|
ValueError,
|
|
"Couldn't parse time string '2012' - value is not a string",
|
|
self.module.str_to_time,
|
|
2012,
|
|
)
|
|
|
|
def test_date_invalid_string(self):
|
|
assert_raises_message(
|
|
ValueError,
|
|
"Couldn't parse date string: '5:a'",
|
|
self.module.str_to_date,
|
|
"5:a",
|
|
)
|
|
|
|
def test_datetime_invalid_string(self):
|
|
assert_raises_message(
|
|
ValueError,
|
|
"Couldn't parse datetime string: '5:a'",
|
|
self.module.str_to_datetime,
|
|
"5:a",
|
|
)
|
|
|
|
def test_time_invalid_string(self):
|
|
assert_raises_message(
|
|
ValueError,
|
|
"Couldn't parse time string: '5:a'",
|
|
self.module.str_to_time,
|
|
"5:a",
|
|
)
|
|
|
|
|
|
class PyDateProcessorTest(_DateProcessorTest):
|
|
@classmethod
|
|
def setup_test_class(cls):
|
|
from sqlalchemy import processors
|
|
|
|
cls.module = type(
|
|
"util",
|
|
(object,),
|
|
dict(
|
|
(k, staticmethod(v))
|
|
for k, v in list(processors.py_fallback().items())
|
|
),
|
|
)
|
|
|
|
|
|
class CDateProcessorTest(_DateProcessorTest):
|
|
__requires__ = ("cextensions",)
|
|
|
|
@classmethod
|
|
def setup_test_class(cls):
|
|
from sqlalchemy import cprocessors
|
|
|
|
cls.module = cprocessors
|