8000 bpo-25872: Add unit tests for linecache and threading by uniocto · Pull Request #25913 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-25872: Add unit tests for linecache and threading #25913

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
May 18, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor linecache
  • Loading branch information
uniocto committed May 5, 2021
commit fc1f92d7c4be1a1f02fed8f40ce540775b3ddcac
7 changes: 4 additions & 3 deletions Lib/test/test_linecache.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,16 @@ def raise_oserror(*args, **kwargs):

def test_updatecache_oserror(self):
linecache.clearcache()
def raise_oserror(*args, **kwargs):
raise OSError
source_name = os_helper.TESTFN
self.addCleanup(os_helper.unlink, os_helper.TESTFN)

def raise_oserror(*args, **kwargs):
raise OSError
with open(source_name, 'w', encoding='utf-8') as source:
source.write(SOURCE_4)
_ = linecache.getlines(source_name)
self.assertEqual(1, len(linecache.cache.keys()))

with support.swap_attr(os, 'stat', raise_oserror):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above - delete/modify the file instead of mocking os.stat.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As shown above, I write delete/modify test.

# Trace OSError with no pop cache
_ = linecache.updatecache('dummy')
Expand Down
0