-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
bpo-28113: Convert Win32{Symlink,Junction}Tests to use support.TESTFN #12907
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
Draft
berkerpeksag
wants to merge
1
commit into
python:main
Choose a base branch
from
berkerpeksag:bpo-28113-createsymboliclinkw
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
bpo-28113: Convert Win32{Symlink,Junction}Tests to use support.TESTFN
- Loading branch information
commit 2cc093917a4e217dff20e39398991d2acee68748
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2148,26 +2148,25 @@ def test_bytes(self): | |
| @unittest.skipUnless(sys.platform == "win32", "Win32 specific tests") | ||
| @support.skip_unless_symlink | ||
| class Win32SymlinkTests(unittest.TestCase): | ||
| filelink = 'filelinktest' | ||
| filelink_target = os.path.abspath(__file__) | ||
| dirlink = 'dirlinktest' | ||
| dirlink_target = os.path.dirname(filelink_target) | ||
| missing_link = 'missing link' | ||
| dirlink_target = os.path.join(support.TESTFN, 'win32_symlink_tests') | ||
| filelink_target = os.path.join(dirlink_target, support.TESTFN) | ||
| dirlink = os.path.join(support.TESTFN, 'dirlinktest') | ||
| filelink = os.path.join(support.TESTFN, 'filelinktest') | ||
| missing_link = os.path.join(support.TESTFN, 'missinglinktest') | ||
|
|
||
| def setUp(self): | ||
| assert os.path.exists(self.dirlink_target) | ||
| assert os.path.exists(self.filelink_target) | ||
| assert not os.path.exists(self.dirlink) | ||
| assert not os.path.exists(self.filelink) | ||
| assert not os.path.exists(self.missing_link) | ||
|
|
||
| def tearDown(self): | ||
| if os.path.exists(self.filelink): | ||
| os.remove(self.filelink) | ||
| if os.path.exists(self.dirlink): | ||
| os.rmdir(self.dirlink) | ||
| if os.path.lexists(self.missing_link): | ||
| os.remove(self.missing_link) | ||
| self.assertFalse(os.path.lexists(self.dirlink)) | ||
| self.assertFalse(os.path.lexists(self.filelink)) | ||
| self.assertFalse(os.path.lexists(self.missing_link)) | ||
| self.assertFalse(os.path.lexists(self.dirlink_target)) | ||
| self.assertFalse(os.path.lexists(self.filelink_target)) | ||
| self.addCleanup(support.rmtree, self.dirlink_target) | ||
| self.addCleanup(support.rmdir, self.dirlink) | ||
| self.addCleanup(support.rmdir, self.missing_link) | ||
| self.addCleanup(support.unlink, self.missing_link) | ||
| self.addCleanup(support.unlink, self.filelink) | ||
| os.mkdir(self.dirlink_target) | ||
| create_file(self.filelink_target) | ||
|
|
||
| def test_directory_link(self): | ||
| os.symlink(self.dirlink_target, self.dirlink) | ||
|
|
@@ -2200,16 +2199,12 @@ def test_remove_directory_link_to_missing_target(self): | |
| # was created with target_is_dir==True. | ||
| os.remove(self.missing_link) | ||
|
|
||
| @unittest.skip("currently fails; consider for improvement") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this no longer skipped: has this behavior been implemented? Likewise for the next test below. |
||
| def test_isdir_on_directory_link_to_missing_target(self): | ||
| self._create_missing_dir_link() | ||
| # consider having isdir return true for directory links | ||
| self.assertTrue(os.path.isdir(self.missing_link)) | ||
|
|
||
| @unittest.skip("currently fails; consider for improvement") | ||
| def test_rmdir_on_directory_link_to_missing_target(self): | ||
| self._create_missing_dir_link() | ||
| # consider allowing rmdir to remove directory links | ||
| os.rmdir(self.missing_link) | ||
|
|
||
| def check_stat(self, link, target): | ||
|
|
@@ -2221,21 +2216,13 @@ def check_stat(self, link, target): | |
| self.assertNotEqual(os.lstat(bytes_link), os.stat(bytes_link)) | ||
|
|
||
| def test_12084(self): | ||
| level1 = os.path.abspath(support.TESTFN) | ||
| file1 = self.filelink_target | ||
| level1 = self.dirlink_target | ||
| level2 = os.path.join(level1, "level2") | ||
| level3 = os.path.join(level2, "level3") | ||
| self.addCleanup(support.rmtree, level1) | ||
|
|
||
| os.mkdir(level1) | ||
| os.mkdir(level2) | ||
| os.mkdir(level3) | ||
| os.makedirs(level3) | ||
|
|
||
| file1 = os.path.abspath(os.path.join(level1, "file1")) | ||
| create_file(file1) | ||
|
|
||
| orig_dir = os.getcwd() | ||
| try: | ||
| os.chdir(level2) | ||
| with support.change_cwd(level2): | ||
| link = os.path.join(level2, "link") | ||
| os.symlink(os.path.relpath(file1), "link") | ||
| self.assertIn("link", os.listdir(os.getcwd())) | ||
|
|
@@ -2252,8 +2239,6 @@ def test_12084(self): | |
| os.chdir(level3) | ||
| self.assertEqual(os.stat(file1), | ||
| os.stat(os.path.relpath(link))) | ||
| finally: | ||
| os.chdir(orig_dir) | ||
|
|
||
| @unittest.skipUnless(os.path.lexists(r'C:\Users\All Users') | ||
| and os.path.exists(r'C:\ProgramData'), | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
support.TESTFNis just a path, but not an existing directory.Perhaps add something the following to
setUp()?With this all of the other existence checks and cleanups may be removed.