tests: Replace "self.assert_" by "self.assertTrue"

The assert_() method is deprecated and can be safely replaced by assertTrue().
This patch makes sure that running the tests does not fill the screen with
warnings.

Change-Id: I8966b7f7a44f1573a4d2c398717bfc68ae40b197
This commit is contained in:
Cyril Roelandt 2014-03-19 17:29:49 +01:00
parent fad07f1c8e
commit 07909159ae
13 changed files with 108 additions and 108 deletions

View File

@ -74,7 +74,7 @@ class TestAddDropColumn(fixture.DB):
create_column_func(col) create_column_func(col)
assert_numcols(2) assert_numcols(2)
# data column exists # data column exists
self.assert_(self.table.c.data.type.length, 40) self.assertTrue(self.table.c.data.type.length, 40)
col2 = self.table.c.data col2 = self.table.c.data
drop_column_func(col2) drop_column_func(col2)
@ -109,11 +109,11 @@ class TestAddDropColumn(fixture.DB):
ie. no table parameter passed to function ie. no table parameter passed to function
""" """
def add_func(col): def add_func(col):
self.assert_(col.table is None, col.table) self.assertTrue(col.table is None, col.table)
self.table.append_column(col) self.table.append_column(col)
return col.create() return col.create()
def drop_func(col): def drop_func(col):
#self.assert_(col.table is None,col.table) #self.assertTrue(col.table is None,col.table)
#self.table.append_column(col) #self.table.append_column(col)
return col.drop() return col.drop()
return self.run_(add_func, drop_func) return self.run_(add_func, drop_func)
@ -642,14 +642,14 @@ class TestColumnChange(fixture.DB):
self.refresh_table() self.refresh_table()
alter_column(self.table.c.data2, name='atad') alter_column(self.table.c.data2, name='atad')
self.refresh_table(self.table.name) self.refresh_table(self.table.name)
self.assert_('data' not in self.table.c.keys()) self.assertTrue('data' not in self.table.c.keys())
self.assert_('atad' in self.table.c.keys()) self.assertTrue('atad' in self.table.c.keys())
self.assertEqual(num_rows(self.table.c.atad, content), 1) self.assertEqual(num_rows(self.table.c.atad, content), 1)
# ...as a method, given a new name # ...as a method, given a new name
self.table.c.atad.alter(name='data') self.table.c.atad.alter(name='data')
self.refresh_table(self.table.name) self.refresh_table(self.table.name)
self.assert_('atad' not in self.table.c.keys()) self.assertTrue('atad' not in self.table.c.keys())
self.table.c.data # Should not raise exception self.table.c.data # Should not raise exception
self.assertEqual(num_rows(self.table.c.data, content), 1) self.assertEqual(num_rows(self.table.c.data, content), 1)
@ -658,7 +658,7 @@ class TestColumnChange(fixture.DB):
name = 'atad', type=String(40), name = 'atad', type=String(40),
server_default=self.table.c.data.server_default) server_default=self.table.c.data.server_default)
self.refresh_table(self.table.name) self.refresh_table(self.table.name)
self.assert_('data' not in self.table.c.keys()) self.assertTrue('data' not in self.table.c.keys())
self.table.c.atad # Should not raise exception self.table.c.atad # Should not raise exception
self.assertEqual(num_rows(self.table.c.atad, content), 1) self.assertEqual(num_rows(self.table.c.atad, content), 1)
@ -668,7 +668,7 @@ class TestColumnChange(fixture.DB):
server_default=self.table.c.atad.server_default server_default=self.table.c.atad.server_default
) )
self.refresh_table(self.table.name) self.refresh_table(self.table.name)
self.assert_('atad' not in self.table.c.keys()) self.assertTrue('atad' not in self.table.c.keys())
self.table.c.data # Should not raise exception self.table.c.data # Should not raise exception
self.assertEqual(num_rows(self.table.c.data,content), 1) self.assertEqual(num_rows(self.table.c.data,content), 1)
@ -679,18 +679,18 @@ class TestColumnChange(fixture.DB):
# Just the new type # Just the new type
self.table.c.data.alter(type=String(43)) self.table.c.data.alter(type=String(43))
self.refresh_table(self.table.name) self.refresh_table(self.table.name)
self.assert_(isinstance(self.table.c.data.type, String)) self.assertTrue(isinstance(self.table.c.data.type, String))
self.assertEqual(self.table.c.data.type.length, 43) self.assertEqual(self.table.c.data.type.length, 43)
# Different type # Different type
self.assert_(isinstance(self.table.c.id.type, Integer)) self.assertTrue(isinstance(self.table.c.id.type, Integer))
self.assertEqual(self.table.c.id.nullable, False) self.assertEqual(self.table.c.id.nullable, False)
if not self.engine.name == 'firebird': if not self.engine.name == 'firebird':
self.table.c.id.alter(type=String(20)) self.table.c.id.alter(type=String(20))
self.assertEqual(self.table.c.id.nullable, False) self.assertEqual(self.table.c.id.nullable, False)
self.refresh_table(self.table.name) self.refresh_table(self.table.name)
self.assert_(isinstance(self.table.c.id.type, String)) self.assertTrue(isinstance(self.table.c.id.type, String))
@fixture.usedb() @fixture.usedb()
def test_default(self): def test_default(self):
@ -706,7 +706,7 @@ class TestColumnChange(fixture.DB):
self.refresh_table(self.table.name) self.refresh_table(self.table.name)
#self.assertEqual(self.table.c.data.server_default.arg,default) #self.assertEqual(self.table.c.data.server_default.arg,default)
# TextClause returned by autoload # TextClause returned by autoload
self.assert_(default in str(self.table.c.data.server_default.arg)) self.assertTrue(default in str(self.table.c.data.server_default.arg))
self.engine.execute(self.table.insert(), id=12) self.engine.execute(self.table.insert(), id=12)
row = self._select_row() row = self._select_row()
self.assertEqual(row['data'], default) self.assertEqual(row['data'], default)
@ -715,7 +715,7 @@ class TestColumnChange(fixture.DB):
default = 'your_default' default = 'your_default'
self.table.c.data.alter(type=String(40), server_default=DefaultClause(default)) self.table.c.data.alter(type=String(40), server_default=DefaultClause(default))
self.refresh_table(self.table.name) self.refresh_table(self.table.name)
self.assert_(default in str(self.table.c.data.server_default.arg)) self.assertTrue(default in str(self.table.c.data.server_default.arg))
# Drop/remove default # Drop/remove default
self.table.c.data.alter(server_default=None) self.table.c.data.alter(server_default=None)
@ -723,10 +723,10 @@ class TestColumnChange(fixture.DB):
self.refresh_table(self.table.name) self.refresh_table(self.table.name)
# server_default isn't necessarily None for Oracle # server_default isn't necessarily None for Oracle
#self.assert_(self.table.c.data.server_default is None,self.table.c.data.server_default) #self.assertTrue(self.table.c.data.server_default is None,self.table.c.data.server_default)
self.engine.execute(self.table.insert(), id=11) self.engine.execute(self.table.insert(), id=11)
row = self.table.select(self.table.c.id == 11).execution_options(autocommit=True).execute().fetchone() row = self.table.select(self.table.c.id == 11).execution_options(autocommit=True).execute().fetchone()
self.assert_(row['data'] is None, row['data']) self.assertTrue(row['data'] is None, row['data'])
@fixture.usedb(not_supported='firebird') @fixture.usedb(not_supported='firebird')
def test_null(self): def test_null(self):
@ -769,7 +769,7 @@ class TestColumnChange(fixture.DB):
"""Test if alter constructs return delta""" """Test if alter constructs return delta"""
delta = self.table.c.data.alter(type=String(100)) delta = self.table.c.data.alter(type=String(100))
self.assert_('type' in delta) self.assertTrue('type' in delta)
@fixture.usedb() @fixture.usedb()
def test_alter_all(self): def test_alter_all(self):
@ -886,12 +886,12 @@ class TestColumnDelta(fixture.DB):
col = self.mkcol(server_default='foobar') col = self.mkcol(server_default='foobar')
self.verify(['type'], col, self.mkcol('id', Text, DefaultClause('foobar')), alter_metadata=True) self.verify(['type'], col, self.mkcol('id', Text, DefaultClause('foobar')), alter_metadata=True)
self.assert_(isinstance(col.type, Text)) self.assertTrue(isinstance(col.type, Text))
col = self.mkcol() col = self.mkcol()
self.verify(['name', 'server_default', 'type'], col, self.mkcol('beep', Text, DefaultClause('foobar')), self.verify(['name', 'server_default', 'type'], col, self.mkcol('beep', Text, DefaultClause('foobar')),
alter_metadata=True) alter_metadata=True)
self.assert_(isinstance(col.type, Text)) self.assertTrue(isinstance(col.type, Text))
self.assertEqual(col.name, 'beep') self.assertEqual(col.name, 'beep')
self.assertEqual(col.server_default.arg, 'foobar') self.assertEqual(col.server_default.arg, 'foobar')
@ -908,7 +908,7 @@ class TestColumnDelta(fixture.DB):
self.meta.clear() self.meta.clear()
delta = self.verify(['type'], 'ids', table=self.table.name, type=String(80), metadata=self.meta, delta = self.verify(['type'], 'ids', table=self.table.name, type=String(80), metadata=self.meta,
alter_metadata=True) alter_metadata=True)
self.assert_(self.table.name in self.meta) self.assertTrue(self.table.name in self.meta)
self.assertEqual(delta.result_column.type.length, 80) self.assertEqual(delta.result_column.type.length, 80)
self.assertEqual(self.meta.tables.get(self.table.name).c.ids.type.length, 80) self.assertEqual(self.meta.tables.get(self.table.name).c.ids.type.length, 80)
@ -942,7 +942,7 @@ class TestColumnDelta(fixture.DB):
col_orig = self.mkcol(primary_key=True) col_orig = self.mkcol(primary_key=True)
self.verify(['name', 'type'], col_orig, name='id12', type=Text, alter_metadata=True) self.verify(['name', 'type'], col_orig, name='id12', type=Text, alter_metadata=True)
self.assert_(isinstance(col_orig.type, Text)) self.assertTrue(isinstance(col_orig.type, Text))
self.assertEqual(col_orig.name, 'id12') self.assertEqual(col_orig.name, 'id12')
# test server default # test server default
@ -956,7 +956,7 @@ class TestColumnDelta(fixture.DB):
# no change # no change
col_orig = self.mkcol(server_default=DefaultClause('foobar')) col_orig = self.mkcol(server_default=DefaultClause('foobar'))
delta = self.verify(['type'], col_orig, DefaultClause('foobar'), type=PickleType) delta = self.verify(['type'], col_orig, DefaultClause('foobar'), type=PickleType)
self.assert_(isinstance(delta.result_column.type, PickleType)) self.assertTrue(isinstance(delta.result_column.type, PickleType))
# TODO: test server on update # TODO: test server on update
# TODO: test bind metadata # TODO: test bind metadata

View File

@ -41,7 +41,7 @@ class CommonTestConstraint(fixture.DB):
# make sure we start at zero # make sure we start at zero
self.assertEqual(len(self.table.primary_key), 0) self.assertEqual(len(self.table.primary_key), 0)
self.assert_(isinstance(self.table.primary_key, self.assertTrue(isinstance(self.table.primary_key,
schema.PrimaryKeyConstraint), self.table.primary_key.__class__) schema.PrimaryKeyConstraint), self.table.primary_key.__class__)
@ -68,7 +68,7 @@ class TestConstraint(CommonTestConstraint):
pk.drop() pk.drop()
self.refresh_table() self.refresh_table()
self.assertEqual(len(self.table.primary_key), 0) self.assertEqual(len(self.table.primary_key), 0)
self.assert_(isinstance(self.table.primary_key, schema.PrimaryKeyConstraint)) self.assertTrue(isinstance(self.table.primary_key, schema.PrimaryKeyConstraint))
return pk return pk
@fixture.usedb(not_supported='sqlite') @fixture.usedb(not_supported='sqlite')
@ -88,9 +88,9 @@ class TestConstraint(CommonTestConstraint):
name="fk_id_fkey", name="fk_id_fkey",
ondelete="CASCADE") ondelete="CASCADE")
if SQLA_07: if SQLA_07:
self.assert_(list(self.table.c.fkey.foreign_keys) is not []) self.assertTrue(list(self.table.c.fkey.foreign_keys) is not [])
else: else:
self.assert_(self.table.c.fkey.foreign_keys._list is not []) self.assertTrue(self.table.c.fkey.foreign_keys._list is not [])
for key in fk.columns: for key in fk.columns:
self.assertEqual(key, self.table.c.fkey.name) self.assertEqual(key, self.table.c.fkey.name)
self.assertEqual([e.column for e in fk.elements], [self.table.c.id]) self.assertEqual([e.column for e in fk.elements], [self.table.c.id])
@ -112,9 +112,9 @@ class TestConstraint(CommonTestConstraint):
self.refresh_table() self.refresh_table()
if SQLA_07: if SQLA_07:
self.assert_(list(self.table.c.fkey.foreign_keys) is not []) self.assertTrue(list(self.table.c.fkey.foreign_keys) is not [])
else: else:
self.assert_(self.table.c.fkey.foreign_keys._list is not []) self.assertTrue(self.table.c.fkey.foreign_keys._list is not [])
fk.drop() fk.drop()
self.refresh_table() self.refresh_table()

View File

@ -15,7 +15,7 @@ class TestAPI(Pathed):
self.assertTrue(isinstance(api.help('help'), basestring)) self.assertTrue(isinstance(api.help('help'), basestring))
self.assertRaises(UsageError, api.help) self.assertRaises(UsageError, api.help)
self.assertRaises(UsageError, api.help, 'foobar') self.assertRaises(UsageError, api.help, 'foobar')
self.assert_(isinstance(api.help('create'), str)) self.assertTrue(isinstance(api.help('create'), str))
# test that all commands return some text # test that all commands return some text
for cmd in api.__all__: for cmd in api.__all__:

View File

@ -12,7 +12,7 @@ class TestConfigParser(fixture.Base):
def test_to_dict(self): def test_to_dict(self):
"""Correctly interpret config results as dictionaries""" """Correctly interpret config results as dictionaries"""
parser = cfgparse.Parser(dict(default_value=42)) parser = cfgparse.Parser(dict(default_value=42))
self.assert_(len(parser.sections()) == 0) self.assertTrue(len(parser.sections()) == 0)
parser.add_section('section') parser.add_section('section')
parser.set('section','option','value') parser.set('section','option','value')
self.assertEqual(parser.get('section', 'option'), 'value') self.assertEqual(parser.get('section', 'option'), 'value')

View File

@ -24,15 +24,15 @@ class TestKeydInstance(fixture.Base):
# Different key: different instance # Different key: different instance
b10 = Uniq1('b') b10 = Uniq1('b')
self.assert_(a10 is not b10) self.assertTrue(a10 is not b10)
# Different class: different instance # Different class: different instance
a20 = Uniq2('a') a20 = Uniq2('a')
self.assert_(a10 is not a20) self.assertTrue(a10 is not a20)
# Same key/class: same instance # Same key/class: same instance
a11 = Uniq1('a') a11 = Uniq1('a')
self.assert_(a10 is a11) self.assertTrue(a10 is a11)
# __init__ is called # __init__ is called
self.assertEqual(a10.value,'a') self.assertEqual(a10.value,'a')
@ -40,6 +40,6 @@ class TestKeydInstance(fixture.Base):
# clear() causes us to forget all existing instances # clear() causes us to forget all existing instances
Uniq1.clear() Uniq1.clear()
a12 = Uniq1('a') a12 = Uniq1('a')
self.assert_(a10 is not a12) self.assertTrue(a10 is not a12)
self.assertRaises(NotImplementedError, KeyedInstance._key) self.assertRaises(NotImplementedError, KeyedInstance._key)

View File

@ -9,9 +9,9 @@ class TestPathed(fixture.Base):
sdirpath='/fgsfds/moot/' sdirpath='/fgsfds/moot/'
result='/fgsfds' result='/fgsfds'
self.assert_(result==Pathed._parent_path(filepath)) self.assertTrue(result==Pathed._parent_path(filepath))
self.assert_(result==Pathed._parent_path(dirpath)) self.assertTrue(result==Pathed._parent_path(dirpath))
self.assert_(result==Pathed._parent_path(sdirpath)) self.assertTrue(result==Pathed._parent_path(sdirpath))
def test_new(self): def test_new(self):
"""Pathed(path) shouldn't create duplicate objects of the same path""" """Pathed(path) shouldn't create duplicate objects of the same path"""
@ -20,13 +20,13 @@ class TestPathed(fixture.Base):
attr=None attr=None
o1=Test(path) o1=Test(path)
o2=Test(path) o2=Test(path)
self.assert_(isinstance(o1,Test)) self.assertTrue(isinstance(o1,Test))
self.assert_(o1.path==path) self.assertTrue(o1.path==path)
self.assert_(o1 is o2) self.assertTrue(o1 is o2)
o1.attr='herring' o1.attr='herring'
self.assert_(o2.attr=='herring') self.assertTrue(o2.attr=='herring')
o2.attr='shrubbery' o2.attr='shrubbery'
self.assert_(o1.attr=='shrubbery') self.assertTrue(o1.attr=='shrubbery')
def test_parent(self): def test_parent(self):
"""Parents should be fetched correctly""" """Parents should be fetched correctly"""
@ -45,7 +45,7 @@ class TestPathed(fixture.Base):
path='/fgsfds/moot.py' path='/fgsfds/moot.py'
parent_path='/fgsfds' parent_path='/fgsfds'
object=Child(path) object=Child(path)
self.assert_(isinstance(object,Child)) self.assertTrue(isinstance(object,Child))
self.assert_(isinstance(object.parent,Parent)) self.assertTrue(isinstance(object.parent,Parent))
self.assert_(object.path==path) self.assertTrue(object.path==path)
self.assert_(object.parent.path==parent_path) self.assertTrue(object.parent.path==parent_path)

View File

@ -22,12 +22,12 @@ class TestRepository(fixture.Pathed):
repo = Repository.create(path, name) repo = Repository.create(path, name)
config_path = repo.config.path config_path = repo.config.path
manage_path = os.path.join(repo.path, 'manage.py') manage_path = os.path.join(repo.path, 'manage.py')
self.assert_(repo) self.assertTrue(repo)
# Files should actually be created # Files should actually be created
self.assert_(os.path.exists(path)) self.assertTrue(os.path.exists(path))
self.assert_(os.path.exists(config_path)) self.assertTrue(os.path.exists(config_path))
self.assert_(os.path.exists(manage_path)) self.assertTrue(os.path.exists(manage_path))
# Can't create it again: it already exists # Can't create it again: it already exists
self.assertRaises(exceptions.PathFoundError, Repository.create, path, name) self.assertRaises(exceptions.PathFoundError, Repository.create, path, name)
@ -39,9 +39,9 @@ class TestRepository(fixture.Pathed):
path = self.test_create() path = self.test_create()
repos = Repository(path) repos = Repository(path)
self.assert_(repos) self.assertTrue(repos)
self.assert_(repos.config) self.assertTrue(repos.config)
self.assert_(repos.config.get('db_settings', 'version_table')) self.assertTrue(repos.config.get('db_settings', 'version_table'))
# version_table's default isn't none # version_table's default isn't none
self.assertNotEquals(repos.config.get('db_settings', 'version_table'), 'None') self.assertNotEquals(repos.config.get('db_settings', 'version_table'), 'None')
@ -49,7 +49,7 @@ class TestRepository(fixture.Pathed):
def test_load_notfound(self): def test_load_notfound(self):
"""Nonexistant repositories shouldn't be loaded""" """Nonexistant repositories shouldn't be loaded"""
path = self.tmp_repos() path = self.tmp_repos()
self.assert_(not os.path.exists(path)) self.assertTrue(not os.path.exists(path))
self.assertRaises(exceptions.InvalidRepositoryError, Repository, path) self.assertRaises(exceptions.InvalidRepositoryError, Repository, path)
def test_load_invalid(self): def test_load_invalid(self):
@ -78,23 +78,23 @@ class TestVersionedRepository(fixture.Pathed):
self.assertEqual(repos.latest, 0) self.assertEqual(repos.latest, 0)
# repos.latest isn't an integer, but a VerNum # repos.latest isn't an integer, but a VerNum
# (so we can't just assume the following tests are correct) # (so we can't just assume the following tests are correct)
self.assert_(repos.latest >= 0) self.assertTrue(repos.latest >= 0)
self.assert_(repos.latest < 1) self.assertTrue(repos.latest < 1)
# Create a script and test again # Create a script and test again
repos.create_script('') repos.create_script('')
self.assertEqual(repos.latest, 1) self.assertEqual(repos.latest, 1)
self.assert_(repos.latest >= 0) self.assertTrue(repos.latest >= 0)
self.assert_(repos.latest >= 1) self.assertTrue(repos.latest >= 1)
self.assert_(repos.latest < 2) self.assertTrue(repos.latest < 2)
# Create a new script and test again # Create a new script and test again
repos.create_script('') repos.create_script('')
self.assertEqual(repos.latest, 2) self.assertEqual(repos.latest, 2)
self.assert_(repos.latest >= 0) self.assertTrue(repos.latest >= 0)
self.assert_(repos.latest >= 1) self.assertTrue(repos.latest >= 1)
self.assert_(repos.latest >= 2) self.assertTrue(repos.latest >= 2)
self.assert_(repos.latest < 3) self.assertTrue(repos.latest < 3)
def test_timestmap_numbering_version(self): def test_timestmap_numbering_version(self):
@ -105,8 +105,8 @@ class TestVersionedRepository(fixture.Pathed):
self.assertEqual(repos.latest, 0) self.assertEqual(repos.latest, 0)
# repos.latest isn't an integer, but a VerNum # repos.latest isn't an integer, but a VerNum
# (so we can't just assume the following tests are correct) # (so we can't just assume the following tests are correct)
self.assert_(repos.latest >= 0) self.assertTrue(repos.latest >= 0)
self.assert_(repos.latest < 1) self.assertTrue(repos.latest < 1)
# Create a script and test again # Create a script and test again
now = int(datetime.utcnow().strftime('%Y%m%d%H%M%S')) now = int(datetime.utcnow().strftime('%Y%m%d%H%M%S'))
@ -134,8 +134,8 @@ class TestVersionedRepository(fixture.Pathed):
"""Repository.version() (no params) returns the latest version""" """Repository.version() (no params) returns the latest version"""
repos = Repository(self.path_repos) repos = Repository(self.path_repos)
repos.create_script('') repos.create_script('')
self.assert_(repos.version(repos.latest) is repos.version()) self.assertTrue(repos.version(repos.latest) is repos.version())
self.assert_(repos.version() is not None) self.assertTrue(repos.version() is not None)
def test_changeset(self): def test_changeset(self):
"""Repositories can create changesets properly""" """Repositories can create changesets properly"""
@ -152,9 +152,9 @@ class TestVersionedRepository(fixture.Pathed):
uniq = list() uniq = list()
# Changesets are iterable # Changesets are iterable
for version, change in changeset: for version, change in changeset:
self.assert_(isinstance(change, BaseScript)) self.assertTrue(isinstance(change, BaseScript))
# Changes aren't identical # Changes aren't identical
self.assert_(id(change) not in uniq) self.assertTrue(id(change) not in uniq)
uniq.append(id(change)) uniq.append(id(change))
return changeset return changeset
@ -209,8 +209,8 @@ class TestVersionedRepository(fixture.Pathed):
repos.create_script('') repos.create_script('')
# since we normally create 3 digit ones, let's see if we blow up # since we normally create 3 digit ones, let's see if we blow up
self.assert_(os.path.exists('%s/versions/1000.py' % self.path_repos)) self.assertTrue(os.path.exists('%s/versions/1000.py' % self.path_repos))
self.assert_(os.path.exists('%s/versions/1001.py' % self.path_repos)) self.assertTrue(os.path.exists('%s/versions/1001.py' % self.path_repos))
# TODO: test manage file # TODO: test manage file

View File

@ -117,7 +117,7 @@ class TestControlledSchema(fixture.Pathed, fixture.DB):
# Can't have custom errors with assertRaises... # Can't have custom errors with assertRaises...
try: try:
ControlledSchema.create(self.engine, self.repos, version) ControlledSchema.create(self.engine, self.repos, version)
self.assert_(False, repr(version)) self.assertTrue(False, repr(version))
except exceptions.InvalidVersionError: except exceptions.InvalidVersionError:
pass pass

View File

@ -34,7 +34,7 @@ class TestPyScript(fixture.Pathed, fixture.DB):
path = self.tmp_py() path = self.tmp_py()
# Creating a file that doesn't exist should succeed # Creating a file that doesn't exist should succeed
self.cls.create(path) self.cls.create(path)
self.assert_(os.path.exists(path)) self.assertTrue(os.path.exists(path))
# Created file should be a valid script (If not, raises an error) # Created file should be a valid script (If not, raises an error)
self.cls.verify(path) self.cls.verify(path)
# Can't create it again: it already exists # Can't create it again: it already exists

View File

@ -96,7 +96,7 @@ class TestShellCommands(Shell):
result = self.env.run('migrate create %s repository_name' % repos) result = self.env.run('migrate create %s repository_name' % repos)
# Files should actually be created # Files should actually be created
self.assert_(os.path.exists(repos)) self.assertTrue(os.path.exists(repos))
# The default table should not be None # The default table should not be None
repos_ = Repository(repos) repos_ = Repository(repos)
@ -113,13 +113,13 @@ class TestShellCommands(Shell):
result = self.env.run('migrate create %s repository_name' % repos) result = self.env.run('migrate create %s repository_name' % repos)
result = self.env.run('migrate script --repository=%s Desc' % repos) result = self.env.run('migrate script --repository=%s Desc' % repos)
self.assert_(os.path.exists('%s/versions/001_Desc.py' % repos)) self.assertTrue(os.path.exists('%s/versions/001_Desc.py' % repos))
result = self.env.run('migrate script More %s' % repos) result = self.env.run('migrate script More %s' % repos)
self.assert_(os.path.exists('%s/versions/002_More.py' % repos)) self.assertTrue(os.path.exists('%s/versions/002_More.py' % repos))
result = self.env.run('migrate script "Some Random name" %s' % repos) result = self.env.run('migrate script "Some Random name" %s' % repos)
self.assert_(os.path.exists('%s/versions/003_Some_Random_name.py' % repos)) self.assertTrue(os.path.exists('%s/versions/003_Some_Random_name.py' % repos))
def test_script_sql(self): def test_script_sql(self):
"""We can create a migration sql script via the command line""" """We can create a migration sql script via the command line"""
@ -127,24 +127,24 @@ class TestShellCommands(Shell):
result = self.env.run('migrate create %s repository_name' % repos) result = self.env.run('migrate create %s repository_name' % repos)
result = self.env.run('migrate script_sql mydb foo %s' % repos) result = self.env.run('migrate script_sql mydb foo %s' % repos)
self.assert_(os.path.exists('%s/versions/001_foo_mydb_upgrade.sql' % repos)) self.assertTrue(os.path.exists('%s/versions/001_foo_mydb_upgrade.sql' % repos))
self.assert_(os.path.exists('%s/versions/001_foo_mydb_downgrade.sql' % repos)) self.assertTrue(os.path.exists('%s/versions/001_foo_mydb_downgrade.sql' % repos))
# Test creating a second # Test creating a second
result = self.env.run('migrate script_sql postgres foo --repository=%s' % repos) result = self.env.run('migrate script_sql postgres foo --repository=%s' % repos)
self.assert_(os.path.exists('%s/versions/002_foo_postgres_upgrade.sql' % repos)) self.assertTrue(os.path.exists('%s/versions/002_foo_postgres_upgrade.sql' % repos))
self.assert_(os.path.exists('%s/versions/002_foo_postgres_downgrade.sql' % repos)) self.assertTrue(os.path.exists('%s/versions/002_foo_postgres_downgrade.sql' % repos))
# TODO: test --previews # TODO: test --previews
def test_manage(self): def test_manage(self):
"""Create a project management script""" """Create a project management script"""
script = self.tmp_py() script = self.tmp_py()
self.assert_(not os.path.exists(script)) self.assertTrue(not os.path.exists(script))
# No attempt is made to verify correctness of the repository path here # No attempt is made to verify correctness of the repository path here
result = self.env.run('migrate manage %s --repository=/bla/' % script) result = self.env.run('migrate manage %s --repository=/bla/' % script)
self.assert_(os.path.exists(script)) self.assertTrue(os.path.exists(script))
class TestShellRepository(Shell): class TestShellRepository(Shell):
@ -177,7 +177,7 @@ class TestShellRepository(Shell):
filename = '%s/versions/001_Desc.py' % self.path_repos filename = '%s/versions/001_Desc.py' % self.path_repos
source = open(filename).read() source = open(filename).read()
self.assert_(source.find('def upgrade') >= 0) self.assertTrue(source.find('def upgrade') >= 0)
# Version is now 1 # Version is now 1
result = self.env.run('migrate version %s' % self.path_repos) result = self.env.run('migrate version %s' % self.path_repos)
@ -190,10 +190,10 @@ class TestShellRepository(Shell):
# We can also send the source to a file... test that too # We can also send the source to a file... test that too
result = self.env.run('migrate source 1 %s --repository=%s' % result = self.env.run('migrate source 1 %s --repository=%s' %
(filename, self.path_repos)) (filename, self.path_repos))
self.assert_(os.path.exists(filename)) self.assertTrue(os.path.exists(filename))
fd = open(filename) fd = open(filename)
result = fd.read() result = fd.read()
self.assert_(result.strip() == source.strip()) self.assertTrue(result.strip() == source.strip())
class TestShellDatabase(Shell, DB): class TestShellDatabase(Shell, DB):
@ -473,19 +473,19 @@ class TestShellDatabase(Shell, DB):
# Setup helper script. # Setup helper script.
result = self.env.run('migrate manage %s --repository=%s --url=%s --model=%s'\ result = self.env.run('migrate manage %s --repository=%s --url=%s --model=%s'\
% (script_path, repos_path, self.url, model_module)) % (script_path, repos_path, self.url, model_module))
self.assert_(os.path.exists(script_path)) self.assertTrue(os.path.exists(script_path))
# Model is defined but database is empty. # Model is defined but database is empty.
result = self.env.run('migrate compare_model_to_db %s %s --model=%s' \ result = self.env.run('migrate compare_model_to_db %s %s --model=%s' \
% (self.url, repos_path, model_module)) % (self.url, repos_path, model_module))
self.assert_("tables missing from database: tmp_account_rundiffs" in result.stdout) self.assertTrue("tables missing from database: tmp_account_rundiffs" in result.stdout)
# Test Deprecation # Test Deprecation
result = self.env.run('migrate compare_model_to_db %s %s --model=%s' \ result = self.env.run('migrate compare_model_to_db %s %s --model=%s' \
% (self.url, repos_path, model_module.replace(":", ".")), expect_error=True) % (self.url, repos_path, model_module.replace(":", ".")), expect_error=True)
self.assertEqual(result.returncode, 0) self.assertEqual(result.returncode, 0)
self.assertTrue("DeprecationWarning" in result.stderr) self.assertTrue("DeprecationWarning" in result.stderr)
self.assert_("tables missing from database: tmp_account_rundiffs" in result.stdout) self.assertTrue("tables missing from database: tmp_account_rundiffs" in result.stdout)
# Update db to latest model. # Update db to latest model.
result = self.env.run('migrate update_db_from_model %s %s %s'\ result = self.env.run('migrate update_db_from_model %s %s %s'\
@ -495,7 +495,7 @@ class TestShellDatabase(Shell, DB):
result = self.env.run('migrate compare_model_to_db %s %s %s'\ result = self.env.run('migrate compare_model_to_db %s %s %s'\
% (self.url, repos_path, model_module)) % (self.url, repos_path, model_module))
self.assert_("No schema diffs" in result.stdout) self.assertTrue("No schema diffs" in result.stdout)
result = self.env.run('migrate drop_version_control %s %s' % (self.url, repos_path), expect_error=True) result = self.env.run('migrate drop_version_control %s %s' % (self.url, repos_path), expect_error=True)
result = self.env.run('migrate version_control %s %s' % (self.url, repos_path)) result = self.env.run('migrate version_control %s %s' % (self.url, repos_path))
@ -550,6 +550,6 @@ class TestShellDatabase(Shell, DB):
#result = self.env.run('migrate compare_model_to_db %s %s %s'\ #result = self.env.run('migrate compare_model_to_db %s %s %s'\
#% (self.url, repos_path, model_module)) #% (self.url, repos_path, model_module))
#self.assert_("No schema diffs" in result.stdout) #self.assertTrue("No schema diffs" in result.stdout)
self.meta.drop_all() # in case junk tables are lying around in the test database self.meta.drop_all() # in case junk tables are lying around in the test database

View File

@ -15,17 +15,17 @@ class TestTemplate(fixture.Pathed):
def test_templates(self): def test_templates(self):
"""We can find the path to all repository templates""" """We can find the path to all repository templates"""
path = str(Template()) path = str(Template())
self.assert_(os.path.exists(path)) self.assertTrue(os.path.exists(path))
def test_repository(self): def test_repository(self):
"""We can find the path to the default repository""" """We can find the path to the default repository"""
path = Template().get_repository() path = Template().get_repository()
self.assert_(os.path.exists(path)) self.assertTrue(os.path.exists(path))
def test_script(self): def test_script(self):
"""We can find the path to the default migration script""" """We can find the path to the default migration script"""
path = Template().get_script() path = Template().get_script()
self.assert_(os.path.exists(path)) self.assertTrue(os.path.exists(path))
def test_custom_templates_and_themes(self): def test_custom_templates_and_themes(self):
"""Users can define their own templates with themes""" """Users can define their own templates with themes"""

View File

@ -20,7 +20,7 @@ class TestUtil(fixture.Pathed):
url = 'sqlite://' url = 'sqlite://'
engine = construct_engine(url) engine = construct_engine(url)
self.assert_(engine.name == 'sqlite') self.assertTrue(engine.name == 'sqlite')
# keyword arg # keyword arg
engine = construct_engine(url, engine_arg_encoding='utf-8') engine = construct_engine(url, engine_arg_encoding='utf-8')
@ -108,7 +108,7 @@ class TestUtil(fixture.Pathed):
# deprecated spelling # deprecated spelling
FakeFloat = load_model('test_load_model.FakeFloat') FakeFloat = load_model('test_load_model.FakeFloat')
self.assert_(isinstance(FakeFloat(), int)) self.assertTrue(isinstance(FakeFloat(), int))
self.assertEqual(len(w),1) self.assertEqual(len(w),1)
self.assertTrue(issubclass(w[-1].category, self.assertTrue(issubclass(w[-1].category,
@ -122,10 +122,10 @@ class TestUtil(fixture.Pathed):
cw.__exit__() cw.__exit__()
FakeFloat = load_model('test_load_model:FakeFloat') FakeFloat = load_model('test_load_model:FakeFloat')
self.assert_(isinstance(FakeFloat(), int)) self.assertTrue(isinstance(FakeFloat(), int))
FakeFloat = load_model(FakeFloat) FakeFloat = load_model(FakeFloat)
self.assert_(isinstance(FakeFloat(), int)) self.assertTrue(isinstance(FakeFloat(), int))
def test_guess_obj_type(self): def test_guess_obj_type(self):
"""guess object type from string""" """guess object type from string"""

View File

@ -23,7 +23,7 @@ class TestVerNum(fixture.Base):
"""Two version with the same number should be equal""" """Two version with the same number should be equal"""
a = VerNum(1) a = VerNum(1)
b = VerNum(1) b = VerNum(1)
self.assert_(a is b) self.assertTrue(a is b)
self.assertEqual(VerNum(VerNum(2)), VerNum(2)) self.assertEqual(VerNum(VerNum(2)), VerNum(2))
@ -31,11 +31,11 @@ class TestVerNum(fixture.Base):
self.assertEqual(VerNum(1) + VerNum(1), VerNum(2)) self.assertEqual(VerNum(1) + VerNum(1), VerNum(2))
self.assertEqual(VerNum(1) + 1, 2) self.assertEqual(VerNum(1) + 1, 2)
self.assertEqual(VerNum(1) + 1, '2') self.assertEqual(VerNum(1) + 1, '2')
self.assert_(isinstance(VerNum(1) + 1, VerNum)) self.assertTrue(isinstance(VerNum(1) + 1, VerNum))
def test_sub(self): def test_sub(self):
self.assertEqual(VerNum(1) - 1, 0) self.assertEqual(VerNum(1) - 1, 0)
self.assert_(isinstance(VerNum(1) - 1, VerNum)) self.assertTrue(isinstance(VerNum(1) - 1, VerNum))
self.assertRaises(ValueError, lambda: VerNum(0) - 1) self.assertRaises(ValueError, lambda: VerNum(0) - 1)
def test_eq(self): def test_eq(self):
@ -46,27 +46,27 @@ class TestVerNum(fixture.Base):
self.assertNotEqual(VerNum(1), 2) self.assertNotEqual(VerNum(1), 2)
def test_ne(self): def test_ne(self):
self.assert_(VerNum(1) != 2) self.assertTrue(VerNum(1) != 2)
self.assertFalse(VerNum(1) != 1) self.assertFalse(VerNum(1) != 1)
def test_lt(self): def test_lt(self):
self.assertFalse(VerNum(1) < 1) self.assertFalse(VerNum(1) < 1)
self.assert_(VerNum(1) < 2) self.assertTrue(VerNum(1) < 2)
self.assertFalse(VerNum(2) < 1) self.assertFalse(VerNum(2) < 1)
def test_le(self): def test_le(self):
self.assert_(VerNum(1) <= 1) self.assertTrue(VerNum(1) <= 1)
self.assert_(VerNum(1) <= 2) self.assertTrue(VerNum(1) <= 2)
self.assertFalse(VerNum(2) <= 1) self.assertFalse(VerNum(2) <= 1)
def test_gt(self): def test_gt(self):
self.assertFalse(VerNum(1) > 1) self.assertFalse(VerNum(1) > 1)
self.assertFalse(VerNum(1) > 2) self.assertFalse(VerNum(1) > 2)
self.assert_(VerNum(2) > 1) self.assertTrue(VerNum(2) > 1)
def test_ge(self): def test_ge(self):
self.assert_(VerNum(1) >= 1) self.assertTrue(VerNum(1) >= 1)
self.assert_(VerNum(2) >= 1) self.assertTrue(VerNum(2) >= 1)
self.assertFalse(VerNum(1) >= 2) self.assertFalse(VerNum(1) >= 2)
@ -114,7 +114,7 @@ class TestVersion(fixture.Pathed):
coll.create_new_python_version("'") coll.create_new_python_version("'")
ver = coll.version() ver = coll.version()
self.assert_(ver.script().source()) self.assertTrue(ver.script().source())
def test_create_new_sql_version(self): def test_create_new_sql_version(self):
coll = Collection(self.temp_usable_dir) coll = Collection(self.temp_usable_dir)