Use call_count instead of assert_called()
because later was introduced in python 3.6.
This commit is contained in:
2 files changed
+6
-6
No files matched your search
@@ -41,7 +41,7 @@ class Cache(dict):
|
|||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
with open(self.filename, 'wb') as f:
|
with open(self.filename, 'wb') as f:
|
||||||
pickle.dump(self, f, protocol=pickle.HIGHEST_PROTOCOL)
|
pickle.dump(self, f, protocol=2)
|
||||||
|
|
||||||
def md5(self, app_name, migration):
|
def md5(self, app_name, migration):
|
||||||
path = compose_migration_path(self.django_folder, app_name, migration)
|
path = compose_migration_path(self.django_folder, app_name, migration)
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ class CacheTest(unittest.TestCase):
|
|||||||
|
|
||||||
with mock.patch.object(MigrationLinter, 'get_sql', wraps=linter.get_sql)as sql_mock:
|
with mock.patch.object(MigrationLinter, 'get_sql', wraps=linter.get_sql)as sql_mock:
|
||||||
linter.lint_all_migrations()
|
linter.lint_all_migrations()
|
||||||
sql_mock.assert_called()
|
self.assertEqual(sql_mock.call_count, 2)
|
||||||
|
|
||||||
cache = Cache(
|
cache = Cache(
|
||||||
fixtures.ADD_NOT_NULL_COLUMN_PROJECT,
|
fixtures.ADD_NOT_NULL_COLUMN_PROJECT,
|
||||||
@@ -67,7 +67,7 @@ class CacheTest(unittest.TestCase):
|
|||||||
|
|
||||||
with mock.patch.object(MigrationLinter, 'get_sql', wraps=linter.get_sql) as sql_mock:
|
with mock.patch.object(MigrationLinter, 'get_sql', wraps=linter.get_sql) as sql_mock:
|
||||||
linter.lint_all_migrations()
|
linter.lint_all_migrations()
|
||||||
sql_mock.assert_not_called()
|
self.assertEqual(sql_mock.call_count, 0)
|
||||||
|
|
||||||
self.assertTrue(linter.has_errors)
|
self.assertTrue(linter.has_errors)
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ class CacheTest(unittest.TestCase):
|
|||||||
|
|
||||||
with mock.patch.object(MigrationLinter, 'get_sql', wraps=linter.get_sql) as sql_mock:
|
with mock.patch.object(MigrationLinter, 'get_sql', wraps=linter.get_sql) as sql_mock:
|
||||||
linter.lint_all_migrations()
|
linter.lint_all_migrations()
|
||||||
sql_mock.assert_called()
|
self.assertEqual(sql_mock.call_count, 2)
|
||||||
|
|
||||||
cache = Cache(
|
cache = Cache(
|
||||||
fixtures.IGNORE_MIGRATION_PROJECT,
|
fixtures.IGNORE_MIGRATION_PROJECT,
|
||||||
@@ -95,7 +95,7 @@ class CacheTest(unittest.TestCase):
|
|||||||
|
|
||||||
with mock.patch.object(MigrationLinter, 'get_sql', wraps=linter.get_sql) as sql_mock:
|
with mock.patch.object(MigrationLinter, 'get_sql', wraps=linter.get_sql) as sql_mock:
|
||||||
linter.lint_all_migrations()
|
linter.lint_all_migrations()
|
||||||
sql_mock.assert_not_called()
|
self.assertEqual(sql_mock.call_count, 0)
|
||||||
|
|
||||||
def test_cache_ignored_command_line(self):
|
def test_cache_ignored_command_line(self):
|
||||||
cache_file = os.path.join(DEFAULT_CACHE_PATH, 'test_project_ignore_migration.pickle')
|
cache_file = os.path.join(DEFAULT_CACHE_PATH, 'test_project_ignore_migration.pickle')
|
||||||
@@ -106,7 +106,7 @@ class CacheTest(unittest.TestCase):
|
|||||||
|
|
||||||
with mock.patch.object(MigrationLinter, 'get_sql', wraps=linter.get_sql) as sql_mock:
|
with mock.patch.object(MigrationLinter, 'get_sql', wraps=linter.get_sql) as sql_mock:
|
||||||
linter.lint_all_migrations()
|
linter.lint_all_migrations()
|
||||||
sql_mock.assert_called()
|
self.assertEqual(sql_mock.call_count, 1)
|
||||||
|
|
||||||
cache = Cache(
|
cache = Cache(
|
||||||
fixtures.IGNORE_MIGRATION_PROJECT,
|
fixtures.IGNORE_MIGRATION_PROJECT,
|
||||||
|
|||||||
Reference in new issue
Block a user