Browse Source

Override _setUp instead setUp when we use fixtures.Fixture

According to https://pypi.python.org/pypi/fixtures, prior to
version 1.3.0 fixtures recommended overriding setUp. This is
still supported, but since it is harder to write leak-free
fixtures in this fashion, it is not recommended. We should
override _setUp now.

Change-Id: Id269b706c44cdb9c12e075ccb69dcb6055b18a3c
Closes-Bug: 1476573
changes/12/204012/1
Hua Wang 7 years ago
parent
commit
a5d358fc63
  1. 4
      magnum/tests/conf_fixture.py
  2. 3
      magnum/tests/policy_fixture.py
  3. 4
      magnum/tests/unit/db/base.py

4
magnum/tests/conf_fixture.py

@ -30,9 +30,7 @@ class ConfFixture(fixtures.Fixture):
def __init__(self, conf):
self.conf = conf
def setUp(self):
super(ConfFixture, self).setUp()
def _setUp(self):
self.conf.set_default('host', 'fake-mini')
self.conf.set_default('connection', "sqlite://", group='database')
self.conf.set_default('sqlite_synchronous', False, group='database')

3
magnum/tests/policy_fixture.py

@ -29,8 +29,7 @@ class PolicyFixture(fixtures.Fixture):
def __init__(self, compat=None):
self.compat = compat
def setUp(self):
super(PolicyFixture, self).setUp()
def _setUp(self):
self.policy_dir = self.useFixture(fixtures.TempDir())
self.policy_file_name = os.path.join(self.policy_dir.path,
'policy.json')

4
magnum/tests/unit/db/base.py

@ -71,9 +71,7 @@ class Database(fixtures.Fixture):
models.Base.metadata.create_all(self.engine)
db_migrate.stamp('head')
def setUp(self):
super(Database, self).setUp()
def _setUp(self):
if self.sql_connection == "sqlite://":
conn = self.engine.connect()
conn.connection.executescript(self._DB)

Loading…
Cancel
Save