Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
setuptools
Commits
9c132229
Commit
9c132229
authored
May 18, 2008
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GHOP #257: test distutils' build_ext command, written by Josip Dzolonga.
parent
372161eb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
72 additions
and
0 deletions
+72
-0
tests/test_build_ext.py
tests/test_build_ext.py
+72
-0
No files found.
tests/test_build_ext.py
0 → 100644
View file @
9c132229
import
sys
import
os
import
tempfile
import
shutil
from
StringIO
import
StringIO
from
distutils.core
import
Extension
,
Distribution
from
distutils.command.build_ext
import
build_ext
from
distutils
import
sysconfig
import
unittest
from
test
import
test_support
class
BuildExtTestCase
(
unittest
.
TestCase
):
def
setUp
(
self
):
# Create a simple test environment
# Note that we're making changes to sys.path
self
.
tmp_dir
=
tempfile
.
mkdtemp
(
prefix
=
"pythontest_"
)
self
.
sys_path
=
sys
.
path
[:]
sys
.
path
.
append
(
self
.
tmp_dir
)
xx_c
=
os
.
path
.
join
(
sysconfig
.
project_base
,
'Modules'
,
'xxmodule.c'
)
shutil
.
copy
(
xx_c
,
self
.
tmp_dir
)
def
test_build_ext
(
self
):
xx_c
=
os
.
path
.
join
(
self
.
tmp_dir
,
'xxmodule.c'
)
xx_ext
=
Extension
(
'xx'
,
[
xx_c
])
dist
=
Distribution
({
'name'
:
'xx'
,
'ext_modules'
:
[
xx_ext
]})
dist
.
package_dir
=
self
.
tmp_dir
cmd
=
build_ext
(
dist
)
cmd
.
build_lib
=
self
.
tmp_dir
cmd
.
build_temp
=
self
.
tmp_dir
old_stdout
=
sys
.
stdout
if
not
test_support
.
verbose
:
# silence compiler output
sys
.
stdout
=
StringIO
()
try
:
cmd
.
ensure_finalized
()
cmd
.
run
()
finally
:
sys
.
stdout
=
old_stdout
import
xx
for
attr
in
(
'error'
,
'foo'
,
'new'
,
'roj'
):
self
.
assert_
(
hasattr
(
xx
,
attr
))
self
.
assertEquals
(
xx
.
foo
(
2
,
5
),
7
)
self
.
assertEquals
(
xx
.
foo
(
13
,
15
),
28
)
self
.
assertEquals
(
xx
.
new
().
demo
(),
None
)
doc
=
'This is a template module just for instruction.'
self
.
assertEquals
(
xx
.
__doc__
,
doc
)
self
.
assert_
(
isinstance
(
xx
.
Null
(),
xx
.
Null
))
self
.
assert_
(
isinstance
(
xx
.
Str
(),
xx
.
Str
))
def
tearDown
(
self
):
# Get everything back to normal
test_support
.
unload
(
'xx'
)
sys
.
path
=
self
.
sys_path
# XXX on Windows the test leaves a directory with xx.pyd in TEMP
shutil
.
rmtree
(
self
.
tmp_dir
,
False
if
os
.
name
!=
"nt"
else
True
)
def
test_suite
():
if
not
sysconfig
.
python_build
:
if
test_support
.
verbose
:
print
'test_build_ext: The test must be run in a python build dir'
return
unittest
.
TestSuite
()
else
:
return
unittest
.
makeSuite
(
BuildExtTestCase
)
if
__name__
==
'__main__'
:
test_support
.
run_unittest
(
test_suite
())
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