Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cython
Commits
e2922b0c
Commit
e2922b0c
authored
9 years ago
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modernise pyximport tests
parent
36fda830
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
13 deletions
+22
-13
pyximport/test/test_pyximport.py
pyximport/test/test_pyximport.py
+15
-8
pyximport/test/test_reload.py
pyximport/test/test_reload.py
+7
-5
No files found.
pyximport/test/test_pyximport.py
View file @
e2922b0c
import
pyximport
;
pyximport
.
install
(
reload_support
=
True
)
from
__future__
import
absolute_import
,
print_function
from
pyximport
import
pyximport
;
pyximport
.
install
(
reload_support
=
True
)
import
os
,
sys
import
time
,
shutil
import
tempfile
def
make_tempdir
():
tempdir
=
os
.
path
.
join
(
tempfile
.
gettempdir
(),
"pyrex_temp"
)
if
os
.
path
.
exists
(
tempdir
):
...
...
@@ -11,14 +15,17 @@ def make_tempdir():
os
.
mkdir
(
tempdir
)
return
tempdir
def
remove_tempdir
(
tempdir
):
shutil
.
rmtree
(
tempdir
,
0
,
on_remove_file_error
)
def
on_remove_file_error
(
func
,
path
,
excinfo
):
print
"Sorry! Could not remove a temp file:"
,
path
print
"Extra information."
print
func
,
excinfo
print
"You may want to delete this yourself when you get a chance."
print
(
"Sorry! Could not remove a temp file:"
,
path
)
print
(
"Extra information."
)
print
(
func
,
excinfo
)
print
(
"You may want to delete this yourself when you get a chance."
)
def
test
():
pyximport
.
_test_files
=
[]
...
...
@@ -52,14 +59,14 @@ def make_ext(name, filename):
time
.
sleep
(
1
)
# sleep a second to get safer mtimes
open
(
os
.
path
.
join
(
tempdir
,
"abc.txt"
),
"w"
).
write
(
" "
)
print
"Here goes the reolad"
print
(
"Here goes the reolad"
)
reload
(
dummy
)
assert
len
(
pyximport
.
_test_files
)
==
1
,
pyximport
.
_test_files
reload
(
dummy
)
assert
len
(
pyximport
.
_test_files
)
==
0
,
pyximport
.
_test_files
assert
len
(
pyximport
.
_test_files
)
==
0
,
pyximport
.
_test_files
remove_tempdir
(
tempdir
)
if
__name__
==
"__main__"
:
test
()
This diff is collapsed.
Click to expand it.
pyximport/test/test_reload.py
View file @
e2922b0c
# reload seems to work for Python 2.3 but not 2.2.
from
__future__
import
absolute_import
,
print_function
import
time
,
os
,
sys
import
test_pyximport
from
.
import
test_pyximport
# debugging the 2.2 problem
if
1
:
from
distutils
import
sysconfig
try
:
...
...
@@ -10,7 +11,8 @@ if 1:
except
AttributeError
:
pass
import
pyxbuild
print
pyxbuild
.
distutils
.
sysconfig
==
sysconfig
print
(
pyxbuild
.
distutils
.
sysconfig
==
sysconfig
)
def
test
():
tempdir
=
test_pyximport
.
make_tempdir
()
...
...
@@ -28,6 +30,6 @@ def test():
assert
hello
.
x
==
2
,
"Reload should work on Python 2.3 but not 2.2"
test_pyximport
.
remove_tempdir
(
tempdir
)
if
__name__
==
"__main__"
:
test
()
This diff is collapsed.
Click to expand it.
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