[damned-lies] Fixed omitted unpatch of mock object in tests



commit dd60f50d583e3e373eb3d857abe468ba06422e1a
Author: Claude Paroz <claude 2xlibre net>
Date:   Sat Sep 18 13:44:14 2021 +0200

    Fixed omitted unpatch of mock object in tests

 stats/tests/tests.py | 6 ++++--
 stats/tests/utils.py | 1 +
 2 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/stats/tests/tests.py b/stats/tests/tests.py
index 497b1f51..2bff8655 100644
--- a/stats/tests/tests.py
+++ b/stats/tests/tests.py
@@ -238,7 +238,8 @@ class ModuleTestCase(TestCase):
     def test_delete_branch(self):
         """ Deleting the master branch of a git module deletes the checkout dir """
         checkout_path = self.branch.co_path
-        branch = Branch.objects.create(name="gnome-hello-1-4", module=self.mod)
+        branch = Branch(module=self.mod, name="gnome-hello-1-4")
+        branch.save(update_statistics=False)
         branch.delete()
         self.assertTrue(checkout_path.exists())
         self.branch.delete()
@@ -464,7 +465,8 @@ class ModuleTestCase(TestCase):
         run_shell_command(
             ['git', 'checkout', '-b', 'gnome-3-18', 'origin/master'], cwd=commit_dir, raise_on_error=True
         )
-        branch = Branch.objects.create(module=self.mod, name='gnome-3-18')
+        branch = Branch(module=self.mod, name="gnome-3-18")
+        branch.save(update_statistics=False)
         fr_lang = Language.objects.get(locale='fr')
         # Copy stats from master
         stat = Statistics.objects.get(language=fr_lang, branch=self.branch, domain=domain)
diff --git a/stats/tests/utils.py b/stats/tests/utils.py
index f028f5c5..ccf48300 100644
--- a/stats/tests/utils.py
+++ b/stats/tests/utils.py
@@ -41,6 +41,7 @@ class PatchShellCommand:
     def __exit__(self, *args):
         self.patcher1.stop()
         self.patcher2.stop()
+        self.patcher3.stop()
 
 
 def test_scratchdir(test_func):


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]