Skip to content

Commit d619580

Browse files
author
Forest
committed
imaplib test: simplify IMAP4.file warning test
1 parent 66d32a0 commit d619580

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

Lib/test/test_imaplib.py

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

2625
support.requires_working_socket(module=True)
2726

@@ -605,14 +604,11 @@ def test_unselect(self):
605604

606605
# property tests
607606

608-
def test_file_property(self):
607+
def test_file_property_should_not_be_accessed(self):
609608
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')
609+
# the 'file' property replaced a private attribute that is now unsafe
610+
with self.assertWarns(RuntimeWarning):
613611
client.file
614-
self.assertEqual(len(warned), 1)
615-
self.assertTrue(issubclass(warned[-1].category, RuntimeWarning))
616612

617613

618614
class NewIMAPTests(NewIMAPTestsMixin, unittest.TestCase):

0 commit comments

Comments
 (0)