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
e34aa351
Commit
e34aa351
authored
Oct 06, 2000
by
Tim Peters
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding Jeremy's new test_import (SF patch 101709).
parent
6de482aa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
0 deletions
+45
-0
Lib/test/output/test_import
Lib/test/output/test_import
+1
-0
Lib/test/test_import.py
Lib/test/test_import.py
+44
-0
No files found.
Lib/test/output/test_import
0 → 100644
View file @
e34aa351
test_import
Lib/test/test_import.py
0 → 100644
View file @
e34aa351
from
test_support
import
TESTFN
import
os
import
random
source
=
TESTFN
+
".py"
pyc
=
TESTFN
+
".pyc"
pyo
=
TESTFN
+
".pyo"
f
=
open
(
source
,
"w"
)
print
>>
f
,
"# This will test Python's ability to import a .py file"
a
=
random
.
randrange
(
1000
)
b
=
random
.
randrange
(
1000
)
print
>>
f
,
"a ="
,
a
print
>>
f
,
"b ="
,
b
f
.
close
()
try
:
try
:
mod
=
__import__
(
TESTFN
)
except
ImportError
,
err
:
raise
ValueError
,
"import from .py failed: %s"
%
err
if
mod
.
a
!=
a
or
mod
.
b
!=
b
:
print
a
,
"!="
,
mod
.
a
print
b
,
"!="
,
mod
.
b
raise
ValueError
,
"module loaded (%s) but contents invalid"
%
mod
finally
:
os
.
unlink
(
source
)
try
:
try
:
reload
(
mod
)
except
ImportError
,
err
:
raise
ValueError
,
"import from .pyc/.pyo failed: %s"
%
err
finally
:
try
:
os
.
unlink
(
pyc
)
except
os
.
error
:
pass
try
:
os
.
unlink
(
pyo
)
except
os
.
error
:
pass
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