diff mbox series

[3/4] Don't create mailboxes/maildirs if not present

Message ID 20180130153611.31474-3-dja@axtens.net
State Accepted
Headers show
Series [1/4] tags: be a bit more permissive in what we render to a message | expand

Commit Message

Daniel Axtens Jan. 30, 2018, 3:36 p.m. UTC
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 | 4 ++--
 patchwork/tests/test_series.py                | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/patchwork/management/commands/parsearchive.py b/patchwork/management/commands/parsearchive.py
index 3eee8382e389..f5ea4af4e113 100644
--- a/patchwork/management/commands/parsearchive.py
+++ b/patchwork/management/commands/parsearchive.py
@@ -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)
 
diff --git a/patchwork/tests/test_series.py b/patchwork/tests/test_series.py
index 6d656d6f3b2d..9b5c01291621 100644
--- a/patchwork/tests/test_series.py
+++ b/patchwork/tests/test_series.py
@@ -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)