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 <d...@axtens.net> --- patchwork/management/commands/parsearchive.py | 4 ++-- patchwork/tests/test_series.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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) -- 2.14.1 _______________________________________________ Patchwork mailing list Patchwork@lists.ozlabs.org https://lists.ozlabs.org/listinfo/patchwork