summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_fileinput.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_fileinput.py')
-rw-r--r--Lib/test/test_fileinput.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_fileinput.py b/Lib/test/test_fileinput.py
index c97bb4c..c5d722e 100644
--- a/Lib/test/test_fileinput.py
+++ b/Lib/test/test_fileinput.py
@@ -351,6 +351,7 @@ class FileInputTests(BaseTests, unittest.TestCase):
with FileInput(files=[]) as fi:
self.assertEqual(fi._files, ('-',))
+ @support.ignore_warnings(category=DeprecationWarning)
def test__getitem__(self):
"""Tests invoking FileInput.__getitem__() with the current
line number"""
@@ -361,6 +362,14 @@ class FileInputTests(BaseTests, unittest.TestCase):
retval2 = fi[1]
self.assertEqual(retval2, "line2\n")
+ def test__getitem___deprecation(self):
+ t = self.writeTmp("line1\nline2\n")
+ with self.assertWarnsRegex(DeprecationWarning,
+ r'Use iterator protocol instead'):
+ with FileInput(files=[t]) as fi:
+ self.assertEqual(fi[0], "line1\n")
+
+ @support.ignore_warnings(category=DeprecationWarning)
def test__getitem__invalid_key(self):
"""Tests invoking FileInput.__getitem__() with an index unequal to
the line number"""
@@ -370,6 +379,7 @@ class FileInputTests(BaseTests, unittest.TestCase):
fi[1]
self.assertEqual(cm.exception.args, ("accessing lines out of order",))
+ @support.ignore_warnings(category=DeprecationWarning)
def test__getitem__eof(self):
"""Tests invoking FileInput.__getitem__() with the line number but at
end-of-input"""