Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
ea4629af
Commit
ea4629af
authored
Mar 08, 2012
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve the test case to avoid spurious errors about already existing symlinks.
parent
0e17dfbd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
4 deletions
+14
-4
Lib/test/test_import.py
Lib/test/test_import.py
+14
-4
No files found.
Lib/test/test_import.py
View file @
ea4629af
...
...
@@ -494,7 +494,10 @@ class TestSymbolicallyLinkedPackage(unittest.TestCase):
package_name
=
'sample'
def
setUp
(
self
):
if
os
.
path
.
exists
(
'sample-tagged'
):
shutil
.
rmtree
(
'sample-tagged'
)
if
os
.
path
.
exists
(
self
.
tagged
):
shutil
.
rmtree
(
self
.
tagged
)
if
os
.
path
.
exists
(
self
.
package_name
):
self
.
remove_symlink
(
self
.
package_name
)
self
.
orig_sys_path
=
sys
.
path
[:]
symlink
=
getattr
(
os
,
'symlink'
,
None
)
or
self
.
_symlink_win32
...
...
@@ -583,23 +586,30 @@ class TestSymbolicallyLinkedPackage(unittest.TestCase):
# regression test for issue6727
@
unittest
.
skipUnless
(
not
hasattr
(
sys
,
'getwindowsversion'
)
or
sys
.
getwindowsversion
()
>=
(
6
,
0
),
or
sys
.
getwindowsversion
()
>=
(
6
,
0
),
"Windows Vista or later required"
)
def
test_symlinked_dir_importable
(
self
):
# make sure sample can only be imported from the current directory.
sys
.
path
[:]
=
[
'.'
]
# and try to import the package
pkg
=
__import__
(
self
.
package_name
)
__import__
(
self
.
package_name
)
def
tearDown
(
self
):
# now cleanup
if
os
.
path
.
exists
(
self
.
package_name
):
os
.
rmdir
(
self
.
package_name
)
self
.
remove_symlink
(
self
.
package_name
)
if
os
.
path
.
exists
(
self
.
tagged
):
shutil
.
rmtree
(
self
.
tagged
)
sys
.
path
[:]
=
self
.
orig_sys_path
@
staticmethod
def
remove_symlink
(
name
):
# On Windows, to remove a directory symlink, one must use rmdir
try
:
os
.
rmdir
(
name
)
except
OSError
:
os
.
remove
(
name
)
def
test_main
(
verbose
=
None
):
run_unittest
(
ImportTests
,
PycRewritingTests
,
PathsTests
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment