Skip to content

Commit 5666a1d

Browse files
committed
refactor raise_oserror()
1 parent 759de2b commit 5666a1d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Lib/test/test_linecache.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,14 @@ def f():
3737
def f():
3838
return 3''' # No ending newline
3939

40-
4140
SOURCE_4 = '''
4241
raise OSError
4342
'''
4443

44+
def raise_oserror(*args, **kwargs):
45+
raise OSError
46+
47+
4548
class TempFile:
4649

4750
def setUp(self):
@@ -190,8 +193,7 @@ def test_checkcache_oserror(self):
190193
_ = linecache.getlines(FILENAME)
191194
self.assertTrue(_)
192195
self.assertEqual(1, len(linecache.cache.keys()))
193-
def raise_oserror(*args, **kwargs):
194-
raise OSError
196+
195197
with support.swap_attr(os, 'stat', raise_oserror):
196198
# pop all cache
197199
_ = linecache.checkcache()
@@ -202,8 +204,6 @@ def test_updatecache_oserror(self):
202204
source_name = os_helper.TESTFN
203205
self.addCleanup(os_helper.unlink, os_helper.TESTFN)
204206

205-
def raise_oserror(*args, **kwargs):
206-
raise OSError
207207
with open(source_name, 'w', encoding='utf-8') as source:
208208
source.write(SOURCE_4)
209209
_ = linecache.getlines(source_name)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy