From: Daniel Axtens Date: Mon, 29 Jan 2018 15:24:46 +0000 (+1100) Subject: Don't create mailboxes/maildirs if not present X-Git-Tag: v2.1.0-rc1~65 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=77ae4221d59a335ed17ec3e5dde9382a3ba7b7fb;p=thirdparty%2Fpatchwork.git Don't create mailboxes/maildirs if not present 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 --- diff --git a/patchwork/management/commands/parsearchive.py b/patchwork/management/commands/parsearchive.py index 3eee8382..f5ea4af4 100644 --- a/patchwork/management/commands/parsearchive.py +++ b/patchwork/management/commands/parsearchive.py @@ -71,9 +71,9 @@ class Command(BaseCommand): # assume if 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 6d656d6f..9b5c0129 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)