]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
Don't create mailboxes/maildirs if not present
authorDaniel Axtens <dja@axtens.net>
Mon, 29 Jan 2018 15:24:46 +0000 (02:24 +1100)
committerDaniel Axtens <dja@axtens.net>
Tue, 30 Jan 2018 15:35:32 +0000 (02:35 +1100)
I realised when I misspelled the name of an input to a test case
that mailbox will happily create an mbox or maildir if it doesn't
exist.

Don't do that, set create=False.

Signed-off-by: Daniel Axtens <dja@axtens.net>
patchwork/management/commands/parsearchive.py
patchwork/tests/test_series.py

index 3eee8382e389bf503264345c7325207e29d09e0b..f5ea4af4e113f725dc3ac33f24a5b1467a561697 100644 (file)
@@ -71,9 +71,9 @@ class Command(BaseCommand):
 
         # assume if <infile> is a directory, then we're passing a maildir
         if os.path.isfile(path):
-            mbox = mailbox.mbox(path)
+            mbox = mailbox.mbox(path, create=False)
         else:
-            mbox = mailbox.Maildir(path)
+            mbox = mailbox.Maildir(path, create=False)
 
         count = len(mbox)
 
index 6d656d6f3b2dc900e61010cd585d8e32c059874a..9b5c012916215190b6f3214a4441827453847785 100644 (file)
@@ -45,7 +45,7 @@ class _BaseTestCase(TestCase):
         results = [[], [], []]
         project = project or utils.create_project()
 
-        mbox = mailbox.mbox(os.path.join(TEST_SERIES_DIR, name))
+        mbox = mailbox.mbox(os.path.join(TEST_SERIES_DIR, name), create=False)
         for msg in mbox:
             obj = parser.parse_mail(msg, project.listid)
             if type(obj) == models.CoverLetter:
@@ -632,7 +632,7 @@ class SeriesNameTestCase(TestCase):
 
         :param name: Name of mbox file
         """
-        return mailbox.mbox(os.path.join(TEST_SERIES_DIR, name))
+        return mailbox.mbox(os.path.join(TEST_SERIES_DIR, name), create=False)
 
     def _parse_mail(self, mail):
         return parser.parse_mail(mail, self.project.listid)