diff --git a/django_migration_linter/cache.py b/django_migration_linter/cache.py index e0f00ea..0ddd08c 100644 --- a/django_migration_linter/cache.py +++ b/django_migration_linter/cache.py @@ -41,7 +41,7 @@ class Cache(dict): def save(self): 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): path = compose_migration_path(self.django_folder, app_name, migration) diff --git a/tests/functional/test_cache.py b/tests/functional/test_cache.py index f6352e1..ae289b2 100644 --- a/tests/functional/test_cache.py +++ b/tests/functional/test_cache.py @@ -47,7 +47,7 @@ class CacheTest(unittest.TestCase): with mock.patch.object(MigrationLinter, 'get_sql', wraps=linter.get_sql)as sql_mock: linter.lint_all_migrations() - sql_mock.assert_called() + self.assertEqual(sql_mock.call_count, 2) cache = Cache( 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: linter.lint_all_migrations() - sql_mock.assert_not_called() + self.assertEqual(sql_mock.call_count, 0) 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: linter.lint_all_migrations() - sql_mock.assert_called() + self.assertEqual(sql_mock.call_count, 2) cache = Cache( 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: linter.lint_all_migrations() - sql_mock.assert_not_called() + self.assertEqual(sql_mock.call_count, 0) def test_cache_ignored_command_line(self): 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: linter.lint_all_migrations() - sql_mock.assert_called() + self.assertEqual(sql_mock.call_count, 1) cache = Cache( fixtures.IGNORE_MIGRATION_PROJECT,