Skip to content

Commit f47de53

Browse files
author
Forest
committed
imaplib test: RuntimeWarning on IMAP4.file access
1 parent 9a07f3b commit f47de53

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Lib/test/test_imaplib.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import ssl
2222
except ImportError:
2323
ssl = None
24+
import warnings
2425

2526
support.requires_working_socket(module=True)
2627

@@ -602,6 +603,17 @@ def test_unselect(self):
602603
self.assertEqual(data[0], b'Returned to authenticated state. (Success)')
603604
self.assertEqual(client.state, 'AUTH')
604605

606+
# property tests
607+
608+
def test_file_property(self):
609+
client, _ = self._setup(SimpleIMAPHandler)
610+
# 'file' attribute access should trigger a warning
611+
with warnings.catch_warnings(record=True) as warned:
612+
warnings.simplefilter('always')
613+
client.file
614+
self.assertEqual(len(warned), 1)
615+
self.assertTrue(issubclass(warned[-1].category, RuntimeWarning))
616+
605617

606618
class NewIMAPTests(NewIMAPTestsMixin, unittest.TestCase):
607619
imap_class = imaplib.IMAP4

0 commit comments

Comments
 (0)