summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorZackery Spytz <zspytz@gmail.com>2023-12-25 15:07:51 (GMT)
committerGitHub <noreply@github.com>2023-12-25 15:07:51 (GMT)
commit3f5eb3e6c75b874db1a83c9d53e824e56fcad02e (patch)
tree03b86133f14368d15e48bb25568e14dbe50291f3 /Lib/test
parentf7c5a7a0f9f8186a7fdc8b721468d022fe310b04 (diff)
downloadcpython-3f5eb3e6c75b874db1a83c9d53e824e56fcad02e.zip
cpython-3f5eb3e6c75b874db1a83c9d53e824e56fcad02e.tar.gz
cpython-3f5eb3e6c75b874db1a83c9d53e824e56fcad02e.tar.bz2
bpo-21360: mailbox.Maildir now ignores files with a leading dot (GH-11833)
The maildir format specification states that files with a leading dot should be ignored. Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_mailbox.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_mailbox.py b/Lib/test/test_mailbox.py
index 23fcbfa..caa7eb3 100644
--- a/Lib/test/test_mailbox.py
+++ b/Lib/test/test_mailbox.py
@@ -681,6 +681,20 @@ class TestMaildir(TestMailbox, unittest.TestCase):
self._box = mailbox.Maildir(self._path)
self._check_basics()
+ def test_filename_leading_dot(self):
+ self.tearDown()
+ for subdir in '', 'tmp', 'new', 'cur':
+ os.mkdir(os.path.normpath(os.path.join(self._path, subdir)))
+ for subdir in 'tmp', 'new', 'cur':
+ fname = os.path.join(self._path, subdir, '.foo' + subdir)
+ with open(fname, 'wb') as f:
+ f.write(b"@")
+ self._box = mailbox.Maildir(self._path)
+ self.assertNotIn('.footmp', self._box)
+ self.assertNotIn('.foonew', self._box)
+ self.assertNotIn('.foocur', self._box)
+ self.assertEqual(list(self._box.iterkeys()), [])
+
def _check_basics(self, factory=None):
# (Used by test_open_new() and test_open_existing().)
self.assertEqual(self._box._path, os.path.abspath(self._path))