Fixes indentations to pass E128 check.

Fixes indentations to pass E128 check.
Removes E128 from ignore setting in tox.ini.

Change-Id: I92ca574c076b4bd26e424a3b404188601264b5de
This commit is contained in:
Petr Blaho 2014-06-12 16:07:22 +02:00
parent 423c17e02b
commit e1dbd31c5b
10 changed files with 89 additions and 69 deletions

View File

@ -69,8 +69,10 @@ def handle_error(engine, listener):
# re-raise # re-raise
reraised_exception = e reraised_exception = e
_oslo_handle_error_events = getattr(self.engine, _oslo_handle_error_events = getattr(
'_oslo_handle_error_events', False) self.engine,
'_oslo_handle_error_events',
False)
newraise = None newraise = None
if _oslo_handle_error_events: if _oslo_handle_error_events:
@ -78,10 +80,10 @@ def handle_error(engine, listener):
sqla_exc.StatementError): sqla_exc.StatementError):
sqlalchemy_exception = reraised_exception sqlalchemy_exception = reraised_exception
original_exception = sqlalchemy_exception.orig original_exception = sqlalchemy_exception.orig
self._is_disconnect = is_disconnect = \ self._is_disconnect = is_disconnect = (
isinstance(sqlalchemy_exception, isinstance(sqlalchemy_exception,
sqla_exc.DBAPIError) and sqlalchemy_exception.\ sqla_exc.DBAPIError)
connection_invalidated and sqlalchemy_exception.connection_invalidated)
else: else:
sqlalchemy_exception = None sqlalchemy_exception = None
original_exception = reraised_exception original_exception = reraised_exception

View File

@ -237,7 +237,8 @@ def _raise_mysql_table_doesnt_exist_asis(
@filters("*", sqla_exc.OperationalError, r".*") @filters("*", sqla_exc.OperationalError, r".*")
def _raise_operational_errors_directly_filter(operational_error, def _raise_operational_errors_directly_filter(operational_error,
match, engine_name, is_disconnect): match, engine_name,
is_disconnect):
"""Filter for all remaining OperationalError classes and apply. """Filter for all remaining OperationalError classes and apply.
Filter for all remaining OperationalError classes and apply Filter for all remaining OperationalError classes and apply

View File

@ -65,7 +65,8 @@ class TestsExceptionFilter(test_base.DbTestCase):
def _dbapi_fixture(self, dialect_name): def _dbapi_fixture(self, dialect_name):
engine = self.engine engine = self.engine
with contextlib.nested( with contextlib.nested(
mock.patch.object(engine.dialect.dbapi, "Error", mock.patch.object(engine.dialect.dbapi,
"Error",
self.Error), self.Error),
mock.patch.object(engine.dialect, "name", dialect_name), mock.patch.object(engine.dialect, "name", dialect_name),
): ):
@ -88,10 +89,12 @@ class TestsExceptionFilter(test_base.DbTestCase):
mock.patch.object(engine.dialect, "do_execute", do_execute), mock.patch.object(engine.dialect, "do_execute", do_execute),
# replace the whole DBAPI rather than patching "Error" # replace the whole DBAPI rather than patching "Error"
# as some DBAPIs might not be patchable (?) # as some DBAPIs might not be patchable (?)
mock.patch.object(engine.dialect, "dbapi", mock.patch.object(engine.dialect,
"dbapi",
mock.Mock(Error=self.Error)), mock.Mock(Error=self.Error)),
mock.patch.object(engine.dialect, "name", dialect_name), mock.patch.object(engine.dialect, "name", dialect_name),
mock.patch.object(engine.dialect, "is_disconnect", mock.patch.object(engine.dialect,
"is_disconnect",
lambda *args: is_disconnect) lambda *args: is_disconnect)
): ):
yield yield
@ -269,7 +272,8 @@ class TestRaiseReferenceError(TestsExceptionFilter):
class TestDuplicate(TestsExceptionFilter): class TestDuplicate(TestsExceptionFilter):
def _run_dupe_constraint_test(self, dialect_name, message, def _run_dupe_constraint_test(self, dialect_name, message,
expected_columns=['a', 'b'], expected_value=None): expected_columns=['a', 'b'],
expected_value=None):
matched = self._run_test( matched = self._run_test(
dialect_name, "insert into table some_values", dialect_name, "insert into table some_values",
self.IntegrityError(message), self.IntegrityError(message),
@ -291,16 +295,19 @@ class TestDuplicate(TestsExceptionFilter):
self._run_dupe_constraint_test("sqlite", 'column a, b are not unique') self._run_dupe_constraint_test("sqlite", 'column a, b are not unique')
def test_sqlite_3_7_16_or_3_8_2_and_higher(self): def test_sqlite_3_7_16_or_3_8_2_and_higher(self):
self._run_dupe_constraint_test("sqlite", self._run_dupe_constraint_test(
"sqlite",
'UNIQUE constraint failed: tbl.a, tbl.b') 'UNIQUE constraint failed: tbl.a, tbl.b')
def test_mysql_mysqldb(self): def test_mysql_mysqldb(self):
self._run_dupe_constraint_test("mysql", self._run_dupe_constraint_test(
"mysql",
'(1062, "Duplicate entry ' '(1062, "Duplicate entry '
'\'2-3\' for key \'uniq_tbl0a0b\'")', expected_value='2-3') '\'2-3\' for key \'uniq_tbl0a0b\'")', expected_value='2-3')
def test_mysql_mysqlconnector(self): def test_mysql_mysqlconnector(self):
self._run_dupe_constraint_test("mysql", self._run_dupe_constraint_test(
"mysql",
'1062 (23000): Duplicate entry ' '1062 (23000): Duplicate entry '
'\'2-3\' for key \'uniq_tbl0a0b\'")', expected_value='2-3') '\'2-3\' for key \'uniq_tbl0a0b\'")', expected_value='2-3')
@ -314,7 +321,8 @@ class TestDuplicate(TestsExceptionFilter):
) )
def test_mysql_single(self): def test_mysql_single(self):
self._run_dupe_constraint_test("mysql", self._run_dupe_constraint_test(
"mysql",
"1062 (23000): Duplicate entry '2' for key 'b'", "1062 (23000): Duplicate entry '2' for key 'b'",
expected_columns=['b'], expected_columns=['b'],
expected_value='2' expected_value='2'
@ -366,7 +374,8 @@ class TestDuplicate(TestsExceptionFilter):
class TestDeadlock(TestsExceptionFilter): class TestDeadlock(TestsExceptionFilter):
def _run_deadlock_detect_test(self, dialect_name, message, def _run_deadlock_detect_test(
self, dialect_name, message,
orig_exception_cls=TestsExceptionFilter.OperationalError): orig_exception_cls=TestsExceptionFilter.OperationalError):
statement = ('SELECT quota_usages.created_at AS ' statement = ('SELECT quota_usages.created_at AS '
'quota_usages_created_at FROM quota_usages \n' 'quota_usages_created_at FROM quota_usages \n'
@ -383,7 +392,8 @@ class TestDeadlock(TestsExceptionFilter):
params=params params=params
) )
def _not_deadlock_test(self, dialect_name, message, def _not_deadlock_test(
self, dialect_name, message,
expected_cls, expected_message, expected_cls, expected_message,
orig_exception_cls=TestsExceptionFilter.OperationalError): orig_exception_cls=TestsExceptionFilter.OperationalError):
statement = ('SELECT quota_usages.created_at AS ' statement = ('SELECT quota_usages.created_at AS '
@ -474,7 +484,8 @@ class IntegrationTest(test_base.DbTestCase):
def setUp(self): def setUp(self):
super(IntegrationTest, self).setUp() super(IntegrationTest, self).setUp()
meta = sqla.MetaData() meta = sqla.MetaData()
self.test_table = sqla.Table(_TABLE_NAME, meta, self.test_table = sqla.Table(
_TABLE_NAME, meta,
sqla.Column('id', sqla.Integer, sqla.Column('id', sqla.Integer,
primary_key=True, nullable=False), primary_key=True, nullable=False),
sqla.Column('counter', sqla.Integer, sqla.Column('counter', sqla.Integer,
@ -587,8 +598,10 @@ class TestDBDisconnected(TestsExceptionFilter):
with self._dbapi_fixture(dialect_name): with self._dbapi_fixture(dialect_name):
with contextlib.nested( with contextlib.nested(
mock.patch.object(engine.dialect, mock.patch.object(engine.dialect,
"do_execute", fake_do_execute), "do_execute",
mock.patch.object(engine.dialect, "is_disconnect", fake_do_execute),
mock.patch.object(engine.dialect,
"is_disconnect",
mock.Mock(return_value=True)) mock.Mock(return_value=True))
): ):
yield yield

View File

@ -156,7 +156,8 @@ class ExceptionReraiseTest(test_base.BaseTestCase):
# done the invalidation. # done the invalidation.
expect_failure = not utils.sqla_097 and orig_error and not evt_value expect_failure = not utils.sqla_097 and orig_error and not evt_value
with mock.patch.object(engine.dialect, "is_disconnect", with mock.patch.object(engine.dialect,
"is_disconnect",
mock.Mock(return_value=orig_error)): mock.Mock(return_value=orig_error)):
with engine.connect() as c: with engine.connect() as c:
@ -179,7 +180,8 @@ class ExceptionReraiseTest(test_base.BaseTestCase):
except NotImplementedError as ne: except NotImplementedError as ne:
self.assertTrue(expect_failure) self.assertTrue(expect_failure)
self.assertEqual(str(ne), self.assertEqual(
str(ne),
"Can't reset 'disconnect' status of exception once it " "Can't reset 'disconnect' status of exception once it "
"is set with this version of SQLAlchemy") "is set with this version of SQLAlchemy")

View File

@ -54,7 +54,8 @@ class TestWalkVersions(test.BaseTestCase, migrate.WalkVersionsMixin):
{'version': version, 'engine': self.engine}) {'version': version, 'engine': self.engine})
with mock.patch.object(self.migration_api, with mock.patch.object(self.migration_api,
'upgrade', side_effect=exc.DbMigrationError): 'upgrade',
side_effect=exc.DbMigrationError):
log = self.useFixture(fixtures.FakeLogger()) log = self.useFixture(fixtures.FakeLogger())
self.assertRaises(exc.DbMigrationError, self._migrate_up, version) self.assertRaises(exc.DbMigrationError, self._migrate_up, version)
self.assertEqual(expected_output, log.output) self.assertEqual(expected_output, log.output)
@ -80,7 +81,8 @@ class TestWalkVersions(test.BaseTestCase, migrate.WalkVersionsMixin):
def test_migrate_down_not_implemented(self): def test_migrate_down_not_implemented(self):
with mock.patch.object(self.migration_api, with mock.patch.object(self.migration_api,
'downgrade', side_effect=NotImplementedError): 'downgrade',
side_effect=NotImplementedError):
self.assertFalse(self._migrate_down(self.engine, 42)) self.assertFalse(self._migrate_down(self.engine, 42))
def test_migrate_down_with_data(self): def test_migrate_down_with_data(self):

View File

@ -45,7 +45,7 @@ commands =
# see https://bugs.launchpad.net/hacking/+bug/1329363 # see https://bugs.launchpad.net/hacking/+bug/1329363
show-source = True show-source = True
ignore = E123,E125,E128,E265,H305,H307,H803,H904 ignore = E123,E125,E265,H305,H307,H803,H904
builtins = _ builtins = _
exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build