Skip to content
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

bpo-34240: Convert test_mmap to use tempfile #8486

Open
wants to merge 5 commits into
base: master
from

Conversation

Projects
None yet
5 participants
@tjguk
Copy link
Member

commented Jul 26, 2018

test_mmap currently uses the test.support.TESTFN functionality which creates a temporary file local to the test directory named around the pid.

This can give rise to race conditions where tests are competing with each other to delete and recreate the file.

This change converts the tests to use tempfile.mkstemp which gives a different file every time from the system's temp area

https://bugs.python.org/issue34240

tjguk added some commits Jul 26, 2018

bpo-34239: Convert test_bz2 to use tempfile
test_bz2 currently uses the test.support.TESTFN functionality which creates a temporary file local to the test directory named around the pid.

This can give rise to race conditions where tests are competing with each other to delete and recreate the file.

This change converts the tests to use tempfile.mkstemp which gives a different file every time from the system's temp area
bpo-34240: Convert test_mmap to use tempfile
test_mmap currently uses the test.support.TESTFN functionality which creates a temporary file local to the test directory named around the pid.

This can give rise to race conditions where tests are competing with each other to delete and recreate the file.

This change converts the tests to use tempfile.mkstemp which gives a different file every time from the system's temp area
os.unlink(self.filename)
except FileNotFoundError:

This comment has been minimized.

Copy link
@berkerpeksag

berkerpeksag Jul 27, 2018

Member

You can use unlink from test.support. It already catches FileNotFoundError and works fine on Windows. (This comment also applies to 6a62e1d.)

https://github.com/python/cpython/blob/master/Lib/test/support/__init__.py#L410-L414

@taleinat
Copy link
Contributor

left a comment

ISTM the changes to test_bz2.py were included here by mistake.

@@ -42,7 +50,7 @@ def test_basic(self):

# Simple sanity checks

tp = str(type(m)) # SF bug 128713: segfaulted on Linux
tp = str(type(m)) # SF g 128713: segfaulted on Linux

This comment has been minimized.

Copy link
@taleinat

taleinat Jul 27, 2018

Contributor

?

@bedevere-bot

This comment has been minimized.

Copy link

commented Jul 27, 2018

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.