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
5978fde7
Commit
5978fde7
authored
Jun 17, 2012
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding test from issue6727 demonstrating that symlink import issue does not occur here in 3.3
parent
3253ced8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
0 deletions
+53
-0
Lib/test/test_import.py
Lib/test/test_import.py
+53
-0
No files found.
Lib/test/test_import.py
View file @
5978fde7
...
...
@@ -13,7 +13,9 @@ import sys
import
unittest
import
textwrap
import
errno
import
shutil
import
test.support
from
test.support
import
(
EnvironmentVarGuard
,
TESTFN
,
check_warnings
,
forget
,
is_jython
,
make_legacy_pyc
,
rmtree
,
run_unittest
,
swap_attr
,
swap_item
,
temp_umask
,
...
...
@@ -690,6 +692,56 @@ class PycacheTests(unittest.TestCase):
self
.
assertEqual
(
m
.
x
,
5
)
class
TestSymbolicallyLinkedPackage
(
unittest
.
TestCase
):
package_name
=
'sample'
def
setUp
(
self
):
if
os
.
path
.
exists
(
self
.
tagged
):
shutil
.
rmtree
(
self
.
tagged
)
if
os
.
path
.
exists
(
self
.
package_name
):
os
.
remove
(
self
.
package_name
)
self
.
orig_sys_path
=
sys
.
path
[:]
# create a sample package; imagine you have a package with a tag and
# you want to symbolically link it from its untagged name.
os
.
mkdir
(
self
.
tagged
)
init_file
=
os
.
path
.
join
(
self
.
tagged
,
'__init__.py'
)
open
(
init_file
,
'w'
).
close
()
assert
os
.
path
.
exists
(
init_file
)
# now create a symlink to the tagged package
# sample -> sample-tagged
os
.
symlink
(
self
.
tagged
,
self
.
package_name
)
# assert os.path.isdir(self.package_name) # currently fails
assert
os
.
path
.
isfile
(
os
.
path
.
join
(
self
.
package_name
,
'__init__.py'
))
@
property
def
tagged
(
self
):
return
self
.
package_name
+
'-tagged'
# regression test for issue6727
@
unittest
.
skipUnless
(
not
hasattr
(
sys
,
'getwindowsversion'
)
or
sys
.
getwindowsversion
()
>=
(
6
,
0
),
"Windows Vista or later required"
)
@
test
.
support
.
skip_unless_symlink
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
__import__
(
self
.
package_name
)
def
tearDown
(
self
):
# now cleanup
if
os
.
path
.
exists
(
self
.
package_name
):
os
.
remove
(
self
.
package_name
)
if
os
.
path
.
exists
(
self
.
tagged
):
shutil
.
rmtree
(
self
.
tagged
)
sys
.
path
[:]
=
self
.
orig_sys_path
def
test_main
(
verbose
=
None
):
flag
=
importlib_util
.
using___import__
try
:
...
...
@@ -697,6 +749,7 @@ def test_main(verbose=None):
run_unittest
(
ImportTests
,
PycacheTests
,
PycRewritingTests
,
PathsTests
,
RelativeImportTests
,
OverridingImportBuiltinTests
,
TestSymbolicallyLinkedPackage
,
importlib_import_test_suite
())
finally
:
importlib_util
.
using___import__
=
flag
...
...
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