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
df79f96e
Commit
df79f96e
authored
Nov 20, 2010
by
Ezio Melotti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#9424: Replace deprecated assert* methods in the Python test suite.
parent
bbcb6110
Changes
32
Hide whitespace changes
Inline
Side-by-side
Showing
32 changed files
with
233 additions
and
235 deletions
+233
-235
tests/test_archive_util.py
tests/test_archive_util.py
+7
-7
tests/test_bdist.py
tests/test_bdist.py
+2
-2
tests/test_bdist_dumb.py
tests/test_bdist_dumb.py
+1
-1
tests/test_build.py
tests/test_build.py
+7
-7
tests/test_build_clib.py
tests/test_build_clib.py
+5
-5
tests/test_build_ext.py
tests/test_build_ext.py
+24
-24
tests/test_check.py
tests/test_check.py
+7
-7
tests/test_cmd.py
tests/test_cmd.py
+5
-5
tests/test_config.py
tests/test_config.py
+3
-3
tests/test_config_cmd.py
tests/test_config_cmd.py
+6
-6
tests/test_core.py
tests/test_core.py
+2
-2
tests/test_cygwinccompiler.py
tests/test_cygwinccompiler.py
+16
-16
tests/test_dep_util.py
tests/test_dep_util.py
+2
-2
tests/test_dir_util.py
tests/test_dir_util.py
+11
-11
tests/test_dist.py
tests/test_dist.py
+10
-10
tests/test_extension.py
tests/test_extension.py
+8
-8
tests/test_file_util.py
tests/test_file_util.py
+3
-3
tests/test_filelist.py
tests/test_filelist.py
+9
-9
tests/test_install.py
tests/test_install.py
+10
-10
tests/test_install_data.py
tests/test_install_data.py
+4
-4
tests/test_install_headers.py
tests/test_install_headers.py
+2
-2
tests/test_install_lib.py
tests/test_install_lib.py
+4
-4
tests/test_log.py
tests/test_log.py
+2
-2
tests/test_msvc9compiler.py
tests/test_msvc9compiler.py
+2
-2
tests/test_register.py
tests/test_register.py
+7
-7
tests/test_sdist.py
tests/test_sdist.py
+16
-18
tests/test_spawn.py
tests/test_spawn.py
+1
-1
tests/test_sysconfig.py
tests/test_sysconfig.py
+9
-9
tests/test_text_file.py
tests/test_text_file.py
+1
-1
tests/test_upload.py
tests/test_upload.py
+6
-6
tests/test_util.py
tests/test_util.py
+31
-31
tests/test_version.py
tests/test_version.py
+10
-10
No files found.
tests/test_archive_util.py
View file @
df79f96e
...
@@ -113,7 +113,7 @@ class ArchiveUtilTestCase(support.TempdirManager,
...
@@ -113,7 +113,7 @@ class ArchiveUtilTestCase(support.TempdirManager,
self
.
assertTrue
(
os
.
path
.
exists
(
tarball2
))
self
.
assertTrue
(
os
.
path
.
exists
(
tarball2
))
# let's compare both tarballs
# let's compare both tarballs
self
.
assertEqual
s
(
self
.
_tarinfo
(
tarball
),
self
.
_tarinfo
(
tarball2
))
self
.
assertEqual
(
self
.
_tarinfo
(
tarball
),
self
.
_tarinfo
(
tarball2
))
# trying an uncompressed one
# trying an uncompressed one
base_name
=
os
.
path
.
join
(
tmpdir2
,
'archive'
)
base_name
=
os
.
path
.
join
(
tmpdir2
,
'archive'
)
...
@@ -153,7 +153,7 @@ class ArchiveUtilTestCase(support.TempdirManager,
...
@@ -153,7 +153,7 @@ class ArchiveUtilTestCase(support.TempdirManager,
os
.
chdir
(
old_dir
)
os
.
chdir
(
old_dir
)
tarball
=
base_name
+
'.tar.Z'
tarball
=
base_name
+
'.tar.Z'
self
.
assertTrue
(
os
.
path
.
exists
(
tarball
))
self
.
assertTrue
(
os
.
path
.
exists
(
tarball
))
self
.
assertEqual
s
(
len
(
w
.
warnings
),
1
)
self
.
assertEqual
(
len
(
w
.
warnings
),
1
)
# same test with dry_run
# same test with dry_run
os
.
remove
(
tarball
)
os
.
remove
(
tarball
)
...
@@ -167,7 +167,7 @@ class ArchiveUtilTestCase(support.TempdirManager,
...
@@ -167,7 +167,7 @@ class ArchiveUtilTestCase(support.TempdirManager,
finally
:
finally
:
os
.
chdir
(
old_dir
)
os
.
chdir
(
old_dir
)
self
.
assertTrue
(
not
os
.
path
.
exists
(
tarball
))
self
.
assertTrue
(
not
os
.
path
.
exists
(
tarball
))
self
.
assertEqual
s
(
len
(
w
.
warnings
),
1
)
self
.
assertEqual
(
len
(
w
.
warnings
),
1
)
@
unittest
.
skipUnless
(
ZIP_SUPPORT
,
'Need zip support to run'
)
@
unittest
.
skipUnless
(
ZIP_SUPPORT
,
'Need zip support to run'
)
def
test_make_zipfile
(
self
):
def
test_make_zipfile
(
self
):
...
@@ -184,9 +184,9 @@ class ArchiveUtilTestCase(support.TempdirManager,
...
@@ -184,9 +184,9 @@ class ArchiveUtilTestCase(support.TempdirManager,
tarball
=
base_name
+
'.zip'
tarball
=
base_name
+
'.zip'
def
test_check_archive_formats
(
self
):
def
test_check_archive_formats
(
self
):
self
.
assertEqual
s
(
check_archive_formats
([
'gztar'
,
'xxx'
,
'zip'
]),
self
.
assertEqual
(
check_archive_formats
([
'gztar'
,
'xxx'
,
'zip'
]),
'xxx'
)
'xxx'
)
self
.
assertEqual
s
(
check_archive_formats
([
'gztar'
,
'zip'
]),
None
)
self
.
assertEqual
(
check_archive_formats
([
'gztar'
,
'zip'
]),
None
)
def
test_make_archive
(
self
):
def
test_make_archive
(
self
):
tmpdir
=
self
.
mkdtemp
()
tmpdir
=
self
.
mkdtemp
()
...
@@ -203,7 +203,7 @@ class ArchiveUtilTestCase(support.TempdirManager,
...
@@ -203,7 +203,7 @@ class ArchiveUtilTestCase(support.TempdirManager,
make_archive
(
'xxx'
,
'xxx'
,
root_dir
=
self
.
mkdtemp
())
make_archive
(
'xxx'
,
'xxx'
,
root_dir
=
self
.
mkdtemp
())
except
:
except
:
pass
pass
self
.
assertEqual
s
(
os
.
getcwd
(),
current_dir
)
self
.
assertEqual
(
os
.
getcwd
(),
current_dir
)
finally
:
finally
:
del
ARCHIVE_FORMATS
[
'xxx'
]
del
ARCHIVE_FORMATS
[
'xxx'
]
...
...
tests/test_bdist.py
View file @
df79f96e
...
@@ -24,7 +24,7 @@ class BuildTestCase(support.TempdirManager,
...
@@ -24,7 +24,7 @@ class BuildTestCase(support.TempdirManager,
cmd
=
bdist
(
dist
)
cmd
=
bdist
(
dist
)
cmd
.
formats
=
[
'msi'
]
cmd
.
formats
=
[
'msi'
]
cmd
.
ensure_finalized
()
cmd
.
ensure_finalized
()
self
.
assertEqual
s
(
cmd
.
formats
,
[
'msi'
])
self
.
assertEqual
(
cmd
.
formats
,
[
'msi'
])
# what format bdist offers ?
# what format bdist offers ?
# XXX an explicit list in bdist is
# XXX an explicit list in bdist is
...
@@ -35,7 +35,7 @@ class BuildTestCase(support.TempdirManager,
...
@@ -35,7 +35,7 @@ class BuildTestCase(support.TempdirManager,
formats
.
sort
()
formats
.
sort
()
founded
=
list
(
cmd
.
format_command
.
keys
())
founded
=
list
(
cmd
.
format_command
.
keys
())
founded
.
sort
()
founded
.
sort
()
self
.
assertEqual
s
(
founded
,
formats
)
self
.
assertEqual
(
founded
,
formats
)
def
test_suite
():
def
test_suite
():
return
unittest
.
makeSuite
(
BuildTestCase
)
return
unittest
.
makeSuite
(
BuildTestCase
)
...
...
tests/test_bdist_dumb.py
View file @
df79f96e
...
@@ -69,7 +69,7 @@ class BuildDumbTestCase(support.TempdirManager,
...
@@ -69,7 +69,7 @@ class BuildDumbTestCase(support.TempdirManager,
base
=
base
.
replace
(
':'
,
'-'
)
base
=
base
.
replace
(
':'
,
'-'
)
wanted
=
[
'%s.zip'
%
base
]
wanted
=
[
'%s.zip'
%
base
]
self
.
assertEqual
s
(
dist_created
,
wanted
)
self
.
assertEqual
(
dist_created
,
wanted
)
# now let's check what we have in the zip file
# now let's check what we have in the zip file
# XXX to be done
# XXX to be done
...
...
tests/test_build.py
View file @
df79f96e
...
@@ -18,11 +18,11 @@ class BuildTestCase(support.TempdirManager,
...
@@ -18,11 +18,11 @@ class BuildTestCase(support.TempdirManager,
cmd
.
finalize_options
()
cmd
.
finalize_options
()
# if not specified, plat_name gets the current platform
# if not specified, plat_name gets the current platform
self
.
assertEqual
s
(
cmd
.
plat_name
,
get_platform
())
self
.
assertEqual
(
cmd
.
plat_name
,
get_platform
())
# build_purelib is build + lib
# build_purelib is build + lib
wanted
=
os
.
path
.
join
(
cmd
.
build_base
,
'lib'
)
wanted
=
os
.
path
.
join
(
cmd
.
build_base
,
'lib'
)
self
.
assertEqual
s
(
cmd
.
build_purelib
,
wanted
)
self
.
assertEqual
(
cmd
.
build_purelib
,
wanted
)
# build_platlib is 'build/lib.platform-x.x[-pydebug]'
# build_platlib is 'build/lib.platform-x.x[-pydebug]'
# examples:
# examples:
...
@@ -32,21 +32,21 @@ class BuildTestCase(support.TempdirManager,
...
@@ -32,21 +32,21 @@ class BuildTestCase(support.TempdirManager,
self
.
assertTrue
(
cmd
.
build_platlib
.
endswith
(
'-pydebug'
))
self
.
assertTrue
(
cmd
.
build_platlib
.
endswith
(
'-pydebug'
))
plat_spec
+=
'-pydebug'
plat_spec
+=
'-pydebug'
wanted
=
os
.
path
.
join
(
cmd
.
build_base
,
'lib'
+
plat_spec
)
wanted
=
os
.
path
.
join
(
cmd
.
build_base
,
'lib'
+
plat_spec
)
self
.
assertEqual
s
(
cmd
.
build_platlib
,
wanted
)
self
.
assertEqual
(
cmd
.
build_platlib
,
wanted
)
# by default, build_lib = build_purelib
# by default, build_lib = build_purelib
self
.
assertEqual
s
(
cmd
.
build_lib
,
cmd
.
build_purelib
)
self
.
assertEqual
(
cmd
.
build_lib
,
cmd
.
build_purelib
)
# build_temp is build/temp.<plat>
# build_temp is build/temp.<plat>
wanted
=
os
.
path
.
join
(
cmd
.
build_base
,
'temp'
+
plat_spec
)
wanted
=
os
.
path
.
join
(
cmd
.
build_base
,
'temp'
+
plat_spec
)
self
.
assertEqual
s
(
cmd
.
build_temp
,
wanted
)
self
.
assertEqual
(
cmd
.
build_temp
,
wanted
)
# build_scripts is build/scripts-x.x
# build_scripts is build/scripts-x.x
wanted
=
os
.
path
.
join
(
cmd
.
build_base
,
'scripts-'
+
sys
.
version
[
0
:
3
])
wanted
=
os
.
path
.
join
(
cmd
.
build_base
,
'scripts-'
+
sys
.
version
[
0
:
3
])
self
.
assertEqual
s
(
cmd
.
build_scripts
,
wanted
)
self
.
assertEqual
(
cmd
.
build_scripts
,
wanted
)
# executable is os.path.normpath(sys.executable)
# executable is os.path.normpath(sys.executable)
self
.
assertEqual
s
(
cmd
.
executable
,
os
.
path
.
normpath
(
sys
.
executable
))
self
.
assertEqual
(
cmd
.
executable
,
os
.
path
.
normpath
(
sys
.
executable
))
def
test_suite
():
def
test_suite
():
return
unittest
.
makeSuite
(
BuildTestCase
)
return
unittest
.
makeSuite
(
BuildTestCase
)
...
...
tests/test_build_clib.py
View file @
df79f96e
...
@@ -57,14 +57,14 @@ class BuildCLibTestCase(support.TempdirManager,
...
@@ -57,14 +57,14 @@ class BuildCLibTestCase(support.TempdirManager,
self
.
assertRaises
(
DistutilsSetupError
,
cmd
.
get_source_files
)
self
.
assertRaises
(
DistutilsSetupError
,
cmd
.
get_source_files
)
cmd
.
libraries
=
[(
'name'
,
{
'sources'
:
[
'a'
,
'b'
]})]
cmd
.
libraries
=
[(
'name'
,
{
'sources'
:
[
'a'
,
'b'
]})]
self
.
assertEqual
s
(
cmd
.
get_source_files
(),
[
'a'
,
'b'
])
self
.
assertEqual
(
cmd
.
get_source_files
(),
[
'a'
,
'b'
])
cmd
.
libraries
=
[(
'name'
,
{
'sources'
:
(
'a'
,
'b'
)})]
cmd
.
libraries
=
[(
'name'
,
{
'sources'
:
(
'a'
,
'b'
)})]
self
.
assertEqual
s
(
cmd
.
get_source_files
(),
[
'a'
,
'b'
])
self
.
assertEqual
(
cmd
.
get_source_files
(),
[
'a'
,
'b'
])
cmd
.
libraries
=
[(
'name'
,
{
'sources'
:
(
'a'
,
'b'
)}),
cmd
.
libraries
=
[(
'name'
,
{
'sources'
:
(
'a'
,
'b'
)}),
(
'name2'
,
{
'sources'
:
[
'c'
,
'd'
]})]
(
'name2'
,
{
'sources'
:
[
'c'
,
'd'
]})]
self
.
assertEqual
s
(
cmd
.
get_source_files
(),
[
'a'
,
'b'
,
'c'
,
'd'
])
self
.
assertEqual
(
cmd
.
get_source_files
(),
[
'a'
,
'b'
,
'c'
,
'd'
])
def
test_build_libraries
(
self
):
def
test_build_libraries
(
self
):
...
@@ -93,11 +93,11 @@ class BuildCLibTestCase(support.TempdirManager,
...
@@ -93,11 +93,11 @@ class BuildCLibTestCase(support.TempdirManager,
cmd
.
include_dirs
=
'one-dir'
cmd
.
include_dirs
=
'one-dir'
cmd
.
finalize_options
()
cmd
.
finalize_options
()
self
.
assertEqual
s
(
cmd
.
include_dirs
,
[
'one-dir'
])
self
.
assertEqual
(
cmd
.
include_dirs
,
[
'one-dir'
])
cmd
.
include_dirs
=
None
cmd
.
include_dirs
=
None
cmd
.
finalize_options
()
cmd
.
finalize_options
()
self
.
assertEqual
s
(
cmd
.
include_dirs
,
[])
self
.
assertEqual
(
cmd
.
include_dirs
,
[])
cmd
.
distribution
.
libraries
=
'WONTWORK'
cmd
.
distribution
.
libraries
=
'WONTWORK'
self
.
assertRaises
(
DistutilsSetupError
,
cmd
.
finalize_options
)
self
.
assertRaises
(
DistutilsSetupError
,
cmd
.
finalize_options
)
...
...
tests/test_build_ext.py
View file @
df79f96e
...
@@ -96,11 +96,11 @@ class BuildExtTestCase(TempdirManager,
...
@@ -96,11 +96,11 @@ class BuildExtTestCase(TempdirManager,
for
attr
in
(
'error'
,
'foo'
,
'new'
,
'roj'
):
for
attr
in
(
'error'
,
'foo'
,
'new'
,
'roj'
):
self
.
assertTrue
(
hasattr
(
xx
,
attr
))
self
.
assertTrue
(
hasattr
(
xx
,
attr
))
self
.
assertEqual
s
(
xx
.
foo
(
2
,
5
),
7
)
self
.
assertEqual
(
xx
.
foo
(
2
,
5
),
7
)
self
.
assertEqual
s
(
xx
.
foo
(
13
,
15
),
28
)
self
.
assertEqual
(
xx
.
foo
(
13
,
15
),
28
)
self
.
assertEqual
s
(
xx
.
new
().
demo
(),
None
)
self
.
assertEqual
(
xx
.
new
().
demo
(),
None
)
doc
=
'This is a template module just for instruction.'
doc
=
'This is a template module just for instruction.'
self
.
assertEqual
s
(
xx
.
__doc__
,
doc
)
self
.
assertEqual
(
xx
.
__doc__
,
doc
)
self
.
assertTrue
(
isinstance
(
xx
.
Null
(),
xx
.
Null
))
self
.
assertTrue
(
isinstance
(
xx
.
Null
(),
xx
.
Null
))
self
.
assertTrue
(
isinstance
(
xx
.
Str
(),
xx
.
Str
))
self
.
assertTrue
(
isinstance
(
xx
.
Str
(),
xx
.
Str
))
...
@@ -206,7 +206,7 @@ class BuildExtTestCase(TempdirManager,
...
@@ -206,7 +206,7 @@ class BuildExtTestCase(TempdirManager,
cmd
=
build_ext
(
dist
)
cmd
=
build_ext
(
dist
)
cmd
.
libraries
=
'my_lib'
cmd
.
libraries
=
'my_lib'
cmd
.
finalize_options
()
cmd
.
finalize_options
()
self
.
assertEqual
s
(
cmd
.
libraries
,
[
'my_lib'
])
self
.
assertEqual
(
cmd
.
libraries
,
[
'my_lib'
])
# make sure cmd.library_dirs is turned into a list
# make sure cmd.library_dirs is turned into a list
# if it's a string
# if it's a string
...
@@ -220,7 +220,7 @@ class BuildExtTestCase(TempdirManager,
...
@@ -220,7 +220,7 @@ class BuildExtTestCase(TempdirManager,
cmd
=
build_ext
(
dist
)
cmd
=
build_ext
(
dist
)
cmd
.
rpath
=
os
.
pathsep
.
join
([
'one'
,
'two'
])
cmd
.
rpath
=
os
.
pathsep
.
join
([
'one'
,
'two'
])
cmd
.
finalize_options
()
cmd
.
finalize_options
()
self
.
assertEqual
s
(
cmd
.
rpath
,
[
'one'
,
'two'
])
self
.
assertEqual
(
cmd
.
rpath
,
[
'one'
,
'two'
])
# XXX more tests to perform for win32
# XXX more tests to perform for win32
...
@@ -229,25 +229,25 @@ class BuildExtTestCase(TempdirManager,
...
@@ -229,25 +229,25 @@ class BuildExtTestCase(TempdirManager,
cmd
=
build_ext
(
dist
)
cmd
=
build_ext
(
dist
)
cmd
.
define
=
'one,two'
cmd
.
define
=
'one,two'
cmd
.
finalize_options
()
cmd
.
finalize_options
()
self
.
assertEqual
s
(
cmd
.
define
,
[(
'one'
,
'1'
),
(
'two'
,
'1'
)])
self
.
assertEqual
(
cmd
.
define
,
[(
'one'
,
'1'
),
(
'two'
,
'1'
)])
# make sure undef is turned into a list of
# make sure undef is turned into a list of
# strings if they are ','-separated strings
# strings if they are ','-separated strings
cmd
=
build_ext
(
dist
)
cmd
=
build_ext
(
dist
)
cmd
.
undef
=
'one,two'
cmd
.
undef
=
'one,two'
cmd
.
finalize_options
()
cmd
.
finalize_options
()
self
.
assertEqual
s
(
cmd
.
undef
,
[
'one'
,
'two'
])
self
.
assertEqual
(
cmd
.
undef
,
[
'one'
,
'two'
])
# make sure swig_opts is turned into a list
# make sure swig_opts is turned into a list
cmd
=
build_ext
(
dist
)
cmd
=
build_ext
(
dist
)
cmd
.
swig_opts
=
None
cmd
.
swig_opts
=
None
cmd
.
finalize_options
()
cmd
.
finalize_options
()
self
.
assertEqual
s
(
cmd
.
swig_opts
,
[])
self
.
assertEqual
(
cmd
.
swig_opts
,
[])
cmd
=
build_ext
(
dist
)
cmd
=
build_ext
(
dist
)
cmd
.
swig_opts
=
'1 2'
cmd
.
swig_opts
=
'1 2'
cmd
.
finalize_options
()
cmd
.
finalize_options
()
self
.
assertEqual
s
(
cmd
.
swig_opts
,
[
'1'
,
'2'
])
self
.
assertEqual
(
cmd
.
swig_opts
,
[
'1'
,
'2'
])
def
test_check_extensions_list
(
self
):
def
test_check_extensions_list
(
self
):
dist
=
Distribution
()
dist
=
Distribution
()
...
@@ -284,7 +284,7 @@ class BuildExtTestCase(TempdirManager,
...
@@ -284,7 +284,7 @@ class BuildExtTestCase(TempdirManager,
# check_extensions_list adds in ext the values passed
# check_extensions_list adds in ext the values passed
# when they are in ('include_dirs', 'library_dirs', 'libraries'
# when they are in ('include_dirs', 'library_dirs', 'libraries'
# 'extra_objects', 'extra_compile_args', 'extra_link_args')
# 'extra_objects', 'extra_compile_args', 'extra_link_args')
self
.
assertEqual
s
(
ext
.
libraries
,
'foo'
)
self
.
assertEqual
(
ext
.
libraries
,
'foo'
)
self
.
assertTrue
(
not
hasattr
(
ext
,
'some'
))
self
.
assertTrue
(
not
hasattr
(
ext
,
'some'
))
# 'macros' element of build info dict must be 1- or 2-tuple
# 'macros' element of build info dict must be 1- or 2-tuple
...
@@ -294,15 +294,15 @@ class BuildExtTestCase(TempdirManager,
...
@@ -294,15 +294,15 @@ class BuildExtTestCase(TempdirManager,
exts
[
0
][
1
][
'macros'
]
=
[(
'1'
,
'2'
),
(
'3'
,)]
exts
[
0
][
1
][
'macros'
]
=
[(
'1'
,
'2'
),
(
'3'
,)]
cmd
.
check_extensions_list
(
exts
)
cmd
.
check_extensions_list
(
exts
)
self
.
assertEqual
s
(
exts
[
0
].
undef_macros
,
[
'3'
])
self
.
assertEqual
(
exts
[
0
].
undef_macros
,
[
'3'
])
self
.
assertEqual
s
(
exts
[
0
].
define_macros
,
[(
'1'
,
'2'
)])
self
.
assertEqual
(
exts
[
0
].
define_macros
,
[(
'1'
,
'2'
)])
def
test_get_source_files
(
self
):
def
test_get_source_files
(
self
):
modules
=
[
Extension
(
'foo'
,
[
'xxx'
],
optional
=
False
)]
modules
=
[
Extension
(
'foo'
,
[
'xxx'
],
optional
=
False
)]
dist
=
Distribution
({
'name'
:
'xx'
,
'ext_modules'
:
modules
})
dist
=
Distribution
({
'name'
:
'xx'
,
'ext_modules'
:
modules
})
cmd
=
build_ext
(
dist
)
cmd
=
build_ext
(
dist
)
cmd
.
ensure_finalized
()
cmd
.
ensure_finalized
()
self
.
assertEqual
s
(
cmd
.
get_source_files
(),
[
'xxx'
])
self
.
assertEqual
(
cmd
.
get_source_files
(),
[
'xxx'
])
def
test_compiler_option
(
self
):
def
test_compiler_option
(
self
):
# cmd.compiler is an option and
# cmd.compiler is an option and
...
@@ -313,7 +313,7 @@ class BuildExtTestCase(TempdirManager,
...
@@ -313,7 +313,7 @@ class BuildExtTestCase(TempdirManager,
cmd
.
compiler
=
'unix'
cmd
.
compiler
=
'unix'
cmd
.
ensure_finalized
()
cmd
.
ensure_finalized
()
cmd
.
run
()
cmd
.
run
()
self
.
assertEqual
s
(
cmd
.
compiler
,
'unix'
)
self
.
assertEqual
(
cmd
.
compiler
,
'unix'
)
def
test_get_outputs
(
self
):
def
test_get_outputs
(
self
):
tmp_dir
=
self
.
mkdtemp
()
tmp_dir
=
self
.
mkdtemp
()
...
@@ -325,7 +325,7 @@ class BuildExtTestCase(TempdirManager,
...
@@ -325,7 +325,7 @@ class BuildExtTestCase(TempdirManager,
cmd
=
build_ext
(
dist
)
cmd
=
build_ext
(
dist
)
self
.
_fixup_command
(
cmd
)
self
.
_fixup_command
(
cmd
)
cmd
.
ensure_finalized
()
cmd
.
ensure_finalized
()
self
.
assertEqual
s
(
len
(
cmd
.
get_outputs
()),
1
)
self
.
assertEqual
(
len
(
cmd
.
get_outputs
()),
1
)
if
os
.
name
==
"nt"
:
if
os
.
name
==
"nt"
:
cmd
.
debug
=
sys
.
executable
.
endswith
(
"_d.exe"
)
cmd
.
debug
=
sys
.
executable
.
endswith
(
"_d.exe"
)
...
@@ -348,7 +348,7 @@ class BuildExtTestCase(TempdirManager,
...
@@ -348,7 +348,7 @@ class BuildExtTestCase(TempdirManager,
so_ext
=
sysconfig
.
get_config_var
(
'SO'
)
so_ext
=
sysconfig
.
get_config_var
(
'SO'
)
self
.
assertTrue
(
so_file
.
endswith
(
so_ext
))
self
.
assertTrue
(
so_file
.
endswith
(
so_ext
))
so_dir
=
os
.
path
.
dirname
(
so_file
)
so_dir
=
os
.
path
.
dirname
(
so_file
)
self
.
assertEqual
s
(
so_dir
,
other_tmp_dir
)
self
.
assertEqual
(
so_dir
,
other_tmp_dir
)
cmd
.
inplace
=
0
cmd
.
inplace
=
0
cmd
.
compiler
=
None
cmd
.
compiler
=
None
...
@@ -357,7 +357,7 @@ class BuildExtTestCase(TempdirManager,
...
@@ -357,7 +357,7 @@ class BuildExtTestCase(TempdirManager,
self
.
assertTrue
(
os
.
path
.
exists
(
so_file
))
self
.
assertTrue
(
os
.
path
.
exists
(
so_file
))
self
.
assertTrue
(
so_file
.
endswith
(
so_ext
))
self
.
assertTrue
(
so_file
.
endswith
(
so_ext
))
so_dir
=
os
.
path
.
dirname
(
so_file
)
so_dir
=
os
.
path
.
dirname
(
so_file
)
self
.
assertEqual
s
(
so_dir
,
cmd
.
build_lib
)
self
.
assertEqual
(
so_dir
,
cmd
.
build_lib
)
# inplace = 0, cmd.package = 'bar'
# inplace = 0, cmd.package = 'bar'
build_py
=
cmd
.
get_finalized_command
(
'build_py'
)
build_py
=
cmd
.
get_finalized_command
(
'build_py'
)
...
@@ -365,7 +365,7 @@ class BuildExtTestCase(TempdirManager,
...
@@ -365,7 +365,7 @@ class BuildExtTestCase(TempdirManager,
path
=
cmd
.
get_ext_fullpath
(
'foo'
)
path
=
cmd
.
get_ext_fullpath
(
'foo'
)
# checking that the last directory is the build_dir
# checking that the last directory is the build_dir
path
=
os
.
path
.
split
(
path
)[
0
]
path
=
os
.
path
.
split
(
path
)[
0
]
self
.
assertEqual
s
(
path
,
cmd
.
build_lib
)
self
.
assertEqual
(
path
,
cmd
.
build_lib
)
# inplace = 1, cmd.package = 'bar'
# inplace = 1, cmd.package = 'bar'
cmd
.
inplace
=
1
cmd
.
inplace
=
1
...
@@ -379,7 +379,7 @@ class BuildExtTestCase(TempdirManager,
...
@@ -379,7 +379,7 @@ class BuildExtTestCase(TempdirManager,
# checking that the last directory is bar
# checking that the last directory is bar
path
=
os
.
path
.
split
(
path
)[
0
]
path
=
os
.
path
.
split
(
path
)[
0
]
lastdir
=
os
.
path
.
split
(
path
)[
-
1
]
lastdir
=
os
.
path
.
split
(
path
)[
-
1
]
self
.
assertEqual
s
(
lastdir
,
'bar'
)
self
.
assertEqual
(
lastdir
,
'bar'
)
def
test_ext_fullpath
(
self
):
def
test_ext_fullpath
(
self
):
ext
=
sysconfig
.
get_config_vars
()[
'SO'
]
ext
=
sysconfig
.
get_config_vars
()[
'SO'
]
...
@@ -395,14 +395,14 @@ class BuildExtTestCase(TempdirManager,
...
@@ -395,14 +395,14 @@ class BuildExtTestCase(TempdirManager,
curdir
=
os
.
getcwd
()
curdir
=
os
.
getcwd
()
wanted
=
os
.
path
.
join
(
curdir
,
'src'
,
'lxml'
,
'etree'
+
ext
)
wanted
=
os
.
path
.
join
(
curdir
,
'src'
,
'lxml'
,
'etree'
+
ext
)
path
=
cmd
.
get_ext_fullpath
(
'lxml.etree'
)
path
=
cmd
.
get_ext_fullpath
(
'lxml.etree'
)
self
.
assertEqual
s
(
wanted
,
path
)
self
.
assertEqual
(
wanted
,
path
)
# building lxml.etree not inplace
# building lxml.etree not inplace
cmd
.
inplace
=
0
cmd
.
inplace
=
0
cmd
.
build_lib
=
os
.
path
.
join
(
curdir
,
'tmpdir'
)
cmd
.
build_lib
=
os
.
path
.
join
(
curdir
,
'tmpdir'
)
wanted
=
os
.
path
.
join
(
curdir
,
'tmpdir'
,
'lxml'
,
'etree'
+
ext
)
wanted
=
os
.
path
.
join
(
curdir
,
'tmpdir'
,
'lxml'
,
'etree'
+
ext
)
path
=
cmd
.
get_ext_fullpath
(
'lxml.etree'
)
path
=
cmd
.
get_ext_fullpath
(
'lxml.etree'
)
self
.
assertEqual
s
(
wanted
,
path
)
self
.
assertEqual
(
wanted
,
path
)
# building twisted.runner.portmap not inplace
# building twisted.runner.portmap not inplace
build_py
=
cmd
.
get_finalized_command
(
'build_py'
)
build_py
=
cmd
.
get_finalized_command
(
'build_py'
)
...
@@ -411,13 +411,13 @@ class BuildExtTestCase(TempdirManager,
...
@@ -411,13 +411,13 @@ class BuildExtTestCase(TempdirManager,
path
=
cmd
.
get_ext_fullpath
(
'twisted.runner.portmap'
)
path
=
cmd
.
get_ext_fullpath
(
'twisted.runner.portmap'
)
wanted
=
os
.
path
.
join
(
curdir
,
'tmpdir'
,
'twisted'
,
'runner'
,
wanted
=
os
.
path
.
join
(
curdir
,
'tmpdir'
,
'twisted'
,
'runner'
,
'portmap'
+
ext
)
'portmap'
+
ext
)
self
.
assertEqual
s
(
wanted
,
path
)
self
.
assertEqual
(
wanted
,
path
)
# building twisted.runner.portmap inplace
# building twisted.runner.portmap inplace
cmd
.
inplace
=
1
cmd
.
inplace
=
1
path
=
cmd
.
get_ext_fullpath
(
'twisted.runner.portmap'
)
path
=
cmd
.
get_ext_fullpath
(
'twisted.runner.portmap'
)
wanted
=
os
.
path
.
join
(
curdir
,
'twisted'
,
'runner'
,
'portmap'
+
ext
)
wanted
=
os
.
path
.
join
(
curdir
,
'twisted'
,
'runner'
,
'portmap'
+
ext
)
self
.
assertEqual
s
(
wanted
,
path
)
self
.
assertEqual
(
wanted
,
path
)
def
test_suite
():
def
test_suite
():
src
=
_get_source_filename
()
src
=
_get_source_filename
()
...
...
tests/test_check.py
View file @
df79f96e
...
@@ -27,7 +27,7 @@ class CheckTestCase(support.LoggingSilencer,
...
@@ -27,7 +27,7 @@ class CheckTestCase(support.LoggingSilencer,
# by default, check is checking the metadata
# by default, check is checking the metadata
# should have some warnings
# should have some warnings
cmd
=
self
.
_run
()
cmd
=
self
.
_run
()
self
.
assertEqual
s
(
cmd
.
_warnings
,
2
)
self
.
assertEqual
(
cmd
.
_warnings
,
2
)
# now let's add the required fields
# now let's add the required fields
# and run it again, to make sure we don't get
# and run it again, to make sure we don't get
...
@@ -36,7 +36,7 @@ class CheckTestCase(support.LoggingSilencer,
...
@@ -36,7 +36,7 @@ class CheckTestCase(support.LoggingSilencer,
'author_email'
:
'xxx'
,
'author_email'
:
'xxx'
,
'name'
:
'xxx'
,
'version'
:
'xxx'
}
'name'
:
'xxx'
,
'version'
:
'xxx'
}
cmd
=
self
.
_run
(
metadata
)
cmd
=
self
.
_run
(
metadata
)
self
.
assertEqual
s
(
cmd
.
_warnings
,
0
)
self
.
assertEqual
(
cmd
.
_warnings
,
0
)
# now with the strict mode, we should
# now with the strict mode, we should
# get an error if there are missing metadata
# get an error if there are missing metadata
...
@@ -44,7 +44,7 @@ class CheckTestCase(support.LoggingSilencer,
...
@@ -44,7 +44,7 @@ class CheckTestCase(support.LoggingSilencer,
# and of course, no error when all metadata are present
# and of course, no error when all metadata are present
cmd
=
self
.
_run
(
metadata
,
strict
=
1
)
cmd
=
self
.
_run
(
metadata
,
strict
=
1
)
self
.
assertEqual
s
(
cmd
.
_warnings
,
0
)
self
.
assertEqual
(
cmd
.
_warnings
,
0
)
def
test_check_document
(
self
):
def
test_check_document
(
self
):
if
not
HAS_DOCUTILS
:
# won't test without docutils
if
not
HAS_DOCUTILS
:
# won't test without docutils
...
@@ -55,12 +55,12 @@ class CheckTestCase(support.LoggingSilencer,
...
@@ -55,12 +55,12 @@ class CheckTestCase(support.LoggingSilencer,
# let's see if it detects broken rest
# let's see if it detects broken rest
broken_rest
=
'title
\
n
===
\
n
\
n
test'
broken_rest
=
'title
\
n
===
\
n
\
n
test'
msgs
=
cmd
.
_check_rst_data
(
broken_rest
)
msgs
=
cmd
.
_check_rst_data
(
broken_rest
)
self
.
assertEqual
s
(
len
(
msgs
),
1
)
self
.
assertEqual
(
len
(
msgs
),
1
)
# and non-broken rest
# and non-broken rest
rest
=
'title
\
n
=====
\
n
\
n
test'
rest
=
'title
\
n
=====
\
n
\
n
test'
msgs
=
cmd
.
_check_rst_data
(
rest
)
msgs
=
cmd
.
_check_rst_data
(
rest
)
self
.
assertEqual
s
(
len
(
msgs
),
0
)
self
.
assertEqual
(
len
(
msgs
),
0
)
def
test_check_restructuredtext
(
self
):
def
test_check_restructuredtext
(
self
):
if
not
HAS_DOCUTILS
:
# won't test without docutils
if
not
HAS_DOCUTILS
:
# won't test without docutils
...
@@ -70,7 +70,7 @@ class CheckTestCase(support.LoggingSilencer,
...
@@ -70,7 +70,7 @@ class CheckTestCase(support.LoggingSilencer,
pkg_info
,
dist
=
self
.
create_dist
(
long_description
=
broken_rest
)
pkg_info
,
dist
=
self
.
create_dist
(
long_description
=
broken_rest
)
cmd
=
check
(
dist
)
cmd
=
check
(
dist
)
cmd
.
check_restructuredtext
()
cmd
.
check_restructuredtext
()
self
.
assertEqual
s
(
cmd
.
_warnings
,
1
)
self
.
assertEqual
(
cmd
.
_warnings
,
1
)
# let's see if we have an error with strict=1
# let's see if we have an error with strict=1
metadata
=
{
'url'
:
'xxx'
,
'author'
:
'xxx'
,
metadata
=
{
'url'
:
'xxx'
,
'author'
:
'xxx'
,
...
@@ -83,7 +83,7 @@ class CheckTestCase(support.LoggingSilencer,
...
@@ -83,7 +83,7 @@ class CheckTestCase(support.LoggingSilencer,
# and non-broken rest
# and non-broken rest
metadata
[
'long_description'
]
=
'title
\
n
=====
\
n
\
n
test'
metadata
[
'long_description'
]
=
'title
\
n
=====
\
n
\
n
test'
cmd
=
self
.
_run
(
metadata
,
strict
=
1
,
restructuredtext
=
1
)
cmd
=
self
.
_run
(
metadata
,
strict
=
1
,
restructuredtext
=
1
)
self
.
assertEqual
s
(
cmd
.
_warnings
,
0
)
self
.
assertEqual
(
cmd
.
_warnings
,
0
)
def
test_check_all
(
self
):
def
test_check_all
(
self
):
...
...
tests/test_cmd.py
View file @
df79f96e
...
@@ -44,7 +44,7 @@ class CommandTestCase(unittest.TestCase):
...
@@ -44,7 +44,7 @@ class CommandTestCase(unittest.TestCase):
# making sure execute gets called properly
# making sure execute gets called properly
def
_execute
(
func
,
args
,
exec_msg
,
level
):
def
_execute
(
func
,
args
,
exec_msg
,
level
):
self
.
assertEqual
s
(
exec_msg
,
'generating out from in'
)
self
.
assertEqual
(
exec_msg
,
'generating out from in'
)
cmd
.
force
=
True
cmd
.
force
=
True
cmd
.
execute
=
_execute
cmd
.
execute
=
_execute
cmd
.
make_file
(
infiles
=
'in'
,
outfile
=
'out'
,
func
=
'func'
,
args
=
())
cmd
.
make_file
(
infiles
=
'in'
,
outfile
=
'out'
,
func
=
'func'
,
args
=
())
...
@@ -63,7 +63,7 @@ class CommandTestCase(unittest.TestCase):
...
@@ -63,7 +63,7 @@ class CommandTestCase(unittest.TestCase):
wanted
=
[
"command options for 'MyCmd':"
,
' option1 = 1'
,
wanted
=
[
"command options for 'MyCmd':"
,
' option1 = 1'
,
' option2 = 1'
]
' option2 = 1'
]
self
.
assertEqual
s
(
msgs
,
wanted
)
self
.
assertEqual
(
msgs
,
wanted
)
def
test_ensure_string
(
self
):
def
test_ensure_string
(
self
):
cmd
=
self
.
cmd
cmd
=
self
.
cmd
...
@@ -81,7 +81,7 @@ class CommandTestCase(unittest.TestCase):
...
@@ -81,7 +81,7 @@ class CommandTestCase(unittest.TestCase):
cmd
=
self
.
cmd
cmd
=
self
.
cmd
cmd
.
option1
=
'ok,dok'
cmd
.
option1
=
'ok,dok'
cmd
.
ensure_string_list
(
'option1'
)
cmd
.
ensure_string_list
(
'option1'
)
self
.
assertEqual
s
(
cmd
.
option1
,
[
'ok'
,
'dok'
])
self
.
assertEqual
(
cmd
.
option1
,
[
'ok'
,
'dok'
])
cmd
.
option2
=
[
'xxx'
,
'www'
]
cmd
.
option2
=
[
'xxx'
,
'www'
]
cmd
.
ensure_string_list
(
'option2'
)
cmd
.
ensure_string_list
(
'option2'
)
...
@@ -109,14 +109,14 @@ class CommandTestCase(unittest.TestCase):
...
@@ -109,14 +109,14 @@ class CommandTestCase(unittest.TestCase):
with
captured_stdout
()
as
stdout
:
with
captured_stdout
()
as
stdout
:
cmd
.
debug_print
(
'xxx'
)
cmd
.
debug_print
(
'xxx'
)
stdout
.
seek
(
0
)
stdout
.
seek
(
0
)
self
.
assertEqual
s
(
stdout
.
read
(),
''
)
self
.
assertEqual
(
stdout
.
read
(),
''
)
debug
.
DEBUG
=
True
debug
.
DEBUG
=
True
try
:
try
:
with
captured_stdout
()
as
stdout
:
with
captured_stdout
()
as
stdout
:
cmd
.
debug_print
(
'xxx'
)
cmd
.
debug_print
(
'xxx'
)
stdout
.
seek
(
0
)
stdout
.
seek
(
0
)
self
.
assertEqual
s
(
stdout
.
read
(),
'xxx
\
n
'
)
self
.
assertEqual
(
stdout
.
read
(),
'xxx
\
n
'
)
finally
:
finally
:
debug
.
DEBUG
=
False
debug
.
DEBUG
=
False
...
...
tests/test_config.py
View file @
df79f96e
...
@@ -89,7 +89,7 @@ class PyPIRCCommandTestCase(support.TempdirManager,
...
@@ -89,7 +89,7 @@ class PyPIRCCommandTestCase(support.TempdirManager,
waited
=
[(
'password'
,
'secret'
),
(
'realm'
,
'pypi'
),
waited
=
[(
'password'
,
'secret'
),
(
'realm'
,
'pypi'
),
(
'repository'
,
'http://pypi.python.org/pypi'
),
(
'repository'
,
'http://pypi.python.org/pypi'
),
(
'server'
,
'server1'
),
(
'username'
,
'me'
)]
(
'server'
,
'server1'
),
(
'username'
,
'me'
)]
self
.
assertEqual
s
(
config
,
waited
)
self
.
assertEqual
(
config
,
waited
)
# old format
# old format
self
.
write_file
(
self
.
rc
,
PYPIRC_OLD
)
self
.
write_file
(
self
.
rc
,
PYPIRC_OLD
)
...
@@ -98,7 +98,7 @@ class PyPIRCCommandTestCase(support.TempdirManager,
...
@@ -98,7 +98,7 @@ class PyPIRCCommandTestCase(support.TempdirManager,
waited
=
[(
'password'
,
'secret'
),
(
'realm'
,
'pypi'
),
waited
=
[(
'password'
,
'secret'
),
(
'realm'
,
'pypi'
),
(
'repository'
,
'http://pypi.python.org/pypi'
),
(
'repository'
,
'http://pypi.python.org/pypi'
),
(
'server'
,
'server-login'
),
(
'username'
,
'tarek'
)]
(
'server'
,
'server-login'
),
(
'username'
,
'tarek'
)]
self
.
assertEqual
s
(
config
,
waited
)
self
.
assertEqual
(
config
,
waited
)
def
test_server_empty_registration
(
self
):
def
test_server_empty_registration
(
self
):
cmd
=
self
.
_cmd
(
self
.
dist
)
cmd
=
self
.
_cmd
(
self
.
dist
)
...
@@ -109,7 +109,7 @@ class PyPIRCCommandTestCase(support.TempdirManager,
...
@@ -109,7 +109,7 @@ class PyPIRCCommandTestCase(support.TempdirManager,
f
=
open
(
rc
)
f
=
open
(
rc
)
try
:
try
:
content
=
f
.
read
()
content
=
f
.
read
()
self
.
assertEqual
s
(
content
,
WANTED
)
self
.
assertEqual
(
content
,
WANTED
)
finally
:
finally
:
f
.
close
()
f
.
close
()
...
...
tests/test_config_cmd.py
View file @
df79f96e
...
@@ -35,7 +35,7 @@ class ConfigTestCase(support.LoggingSilencer,
...
@@ -35,7 +35,7 @@ class ConfigTestCase(support.LoggingSilencer,
f
.
close
()
f
.
close
()
dump_file
(
this_file
,
'I am the header'
)
dump_file
(
this_file
,
'I am the header'
)
self
.
assertEqual
s
(
len
(
self
.
_logs
),
numlines
+
1
)
self
.
assertEqual
(
len
(
self
.
_logs
),
numlines
+
1
)
def
test_search_cpp
(
self
):
def
test_search_cpp
(
self
):
if
sys
.
platform
==
'win32'
:
if
sys
.
platform
==
'win32'
:
...
@@ -45,10 +45,10 @@ class ConfigTestCase(support.LoggingSilencer,
...
@@ -45,10 +45,10 @@ class ConfigTestCase(support.LoggingSilencer,
# simple pattern searches
# simple pattern searches
match
=
cmd
.
search_cpp
(
pattern
=
'xxx'
,
body
=
'// xxx'
)
match
=
cmd
.
search_cpp
(
pattern
=
'xxx'
,
body
=
'// xxx'
)
self
.
assertEqual
s
(
match
,
0
)
self
.
assertEqual
(
match
,
0
)
match
=
cmd
.
search_cpp
(
pattern
=
'_configtest'
,
body
=
'// xxx'
)
match
=
cmd
.
search_cpp
(
pattern
=
'_configtest'
,
body
=
'// xxx'
)
self
.
assertEqual
s
(
match
,
1
)
self
.
assertEqual
(
match
,
1
)
def
test_finalize_options
(
self
):
def
test_finalize_options
(
self
):
# finalize_options does a bit of transformation
# finalize_options does a bit of transformation
...
@@ -60,9 +60,9 @@ class ConfigTestCase(support.LoggingSilencer,
...
@@ -60,9 +60,9 @@ class ConfigTestCase(support.LoggingSilencer,
cmd
.
library_dirs
=
'three%sfour'
%
os
.
pathsep
cmd
.
library_dirs
=
'three%sfour'
%
os
.
pathsep
cmd
.
ensure_finalized
()
cmd
.
ensure_finalized
()
self
.
assertEqual
s
(
cmd
.
include_dirs
,
[
'one'
,
'two'
])
self
.
assertEqual
(
cmd
.
include_dirs
,
[
'one'
,
'two'
])
self
.
assertEqual
s
(
cmd
.
libraries
,
[
'one'
])
self
.
assertEqual
(
cmd
.
libraries
,
[
'one'
])
self
.
assertEqual
s
(
cmd
.
library_dirs
,
[
'three'
,
'four'
])
self
.
assertEqual
(
cmd
.
library_dirs
,
[
'three'
,
'four'
])
def
test_clean
(
self
):
def
test_clean
(
self
):
# _clean removes files
# _clean removes files
...
...
tests/test_core.py
View file @
df79f96e
...
@@ -89,7 +89,7 @@ class CoreTestCase(support.EnvironGuard, unittest.TestCase):
...
@@ -89,7 +89,7 @@ class CoreTestCase(support.EnvironGuard, unittest.TestCase):
with
captured_stdout
()
as
stdout
:
with
captured_stdout
()
as
stdout
:
distutils
.
core
.
setup
(
name
=
'bar'
)
distutils
.
core
.
setup
(
name
=
'bar'
)
stdout
.
seek
(
0
)
stdout
.
seek
(
0
)
self
.
assertEqual
s
(
stdout
.
read
(),
'bar
\
n
'
)
self
.
assertEqual
(
stdout
.
read
(),
'bar
\
n
'
)
distutils
.
core
.
DEBUG
=
True
distutils
.
core
.
DEBUG
=
True
try
:
try
:
...
@@ -99,7 +99,7 @@ class CoreTestCase(support.EnvironGuard, unittest.TestCase):
...
@@ -99,7 +99,7 @@ class CoreTestCase(support.EnvironGuard, unittest.TestCase):
distutils
.
core
.
DEBUG
=
False
distutils
.
core
.
DEBUG
=
False
stdout
.
seek
(
0
)
stdout
.
seek
(
0
)
wanted
=
"options (after parsing config files):
\
n
"
wanted
=
"options (after parsing config files):
\
n
"
self
.
assertEqual
s
(
stdout
.
readlines
()[
0
],
wanted
)
self
.
assertEqual
(
stdout
.
readlines
()[
0
],
wanted
)
def
test_suite
():
def
test_suite
():
return
unittest
.
makeSuite
(
CoreTestCase
)
return
unittest
.
makeSuite
(
CoreTestCase
)
...
...
tests/test_cygwinccompiler.py
View file @
df79f96e
...
@@ -66,82 +66,82 @@ class CygwinCCompilerTestCase(support.TempdirManager,
...
@@ -66,82 +66,82 @@ class CygwinCCompilerTestCase(support.TempdirManager,
sys
.
version
=
(
'2.6.1 (r261:67515, Dec 6 2008, 16:42:21)
\
n
[GCC '
sys
.
version
=
(
'2.6.1 (r261:67515, Dec 6 2008, 16:42:21)
\
n
[GCC '
'4.0.1 (Apple Computer, Inc. build 5370)]'
)
'4.0.1 (Apple Computer, Inc. build 5370)]'
)
self
.
assertEqual
s
(
check_config_h
()[
0
],
CONFIG_H_OK
)
self
.
assertEqual
(
check_config_h
()[
0
],
CONFIG_H_OK
)
# then it tries to see if it can find "__GNUC__" in pyconfig.h
# then it tries to see if it can find "__GNUC__" in pyconfig.h
sys
.
version
=
'something without the *CC word'
sys
.
version
=
'something without the *CC word'
# if the file doesn't exist it returns CONFIG_H_UNCERTAIN
# if the file doesn't exist it returns CONFIG_H_UNCERTAIN
self
.
assertEqual
s
(
check_config_h
()[
0
],
CONFIG_H_UNCERTAIN
)
self
.
assertEqual
(
check_config_h
()[
0
],
CONFIG_H_UNCERTAIN
)
# if it exists but does not contain __GNUC__, it returns CONFIG_H_NOTOK
# if it exists but does not contain __GNUC__, it returns CONFIG_H_NOTOK
self
.
write_file
(
self
.
python_h
,
'xxx'
)
self
.
write_file
(
self
.
python_h
,
'xxx'
)
self
.
assertEqual
s
(
check_config_h
()[
0
],
CONFIG_H_NOTOK
)
self
.
assertEqual
(
check_config_h
()[
0
],
CONFIG_H_NOTOK
)
# and CONFIG_H_OK if __GNUC__ is found
# and CONFIG_H_OK if __GNUC__ is found
self
.
write_file
(
self
.
python_h
,
'xxx __GNUC__ xxx'
)
self
.
write_file
(
self
.
python_h
,
'xxx __GNUC__ xxx'
)
self
.
assertEqual
s
(
check_config_h
()[
0
],
CONFIG_H_OK
)
self
.
assertEqual
(
check_config_h
()[
0
],
CONFIG_H_OK
)
def
test_get_versions
(
self
):
def
test_get_versions
(
self
):
# get_versions calls distutils.spawn.find_executable on
# get_versions calls distutils.spawn.find_executable on
# 'gcc', 'ld' and 'dllwrap'
# 'gcc', 'ld' and 'dllwrap'
self
.
assertEqual
s
(
get_versions
(),
(
None
,
None
,
None
))
self
.
assertEqual
(
get_versions
(),
(
None
,
None
,
None
))
# Let's fake we have 'gcc' and it returns '3.4.5'
# Let's fake we have 'gcc' and it returns '3.4.5'
self
.
_exes
[
'gcc'
]
=
b'gcc (GCC) 3.4.5 (mingw special)
\
n
FSF'
self
.
_exes
[
'gcc'
]
=
b'gcc (GCC) 3.4.5 (mingw special)
\
n
FSF'
res
=
get_versions
()
res
=
get_versions
()
self
.
assertEqual
s
(
str
(
res
[
0
]),
'3.4.5'
)
self
.
assertEqual
(
str
(
res
[
0
]),
'3.4.5'
)
# and let's see what happens when the version
# and let's see what happens when the version
# doesn't match the regular expression
# doesn't match the regular expression
# (\d+\.\d+(\.\d+)*)
# (\d+\.\d+(\.\d+)*)
self
.
_exes
[
'gcc'
]
=
b'very strange output'
self
.
_exes
[
'gcc'
]
=
b'very strange output'
res
=
get_versions
()
res
=
get_versions
()
self
.
assertEqual
s
(
res
[
0
],
None
)
self
.
assertEqual
(
res
[
0
],
None
)
# same thing for ld
# same thing for ld
self
.
_exes
[
'ld'
]
=
b'GNU ld version 2.17.50 20060824'
self
.
_exes
[
'ld'
]
=
b'GNU ld version 2.17.50 20060824'
res
=
get_versions
()
res
=
get_versions
()
self
.
assertEqual
s
(
str
(
res
[
1
]),
'2.17.50'
)
self
.
assertEqual
(
str
(
res
[
1
]),
'2.17.50'
)
self
.
_exes
[
'ld'
]
=
b'@(#)PROGRAM:ld PROJECT:ld64-77'
self
.
_exes
[
'ld'
]
=
b'@(#)PROGRAM:ld PROJECT:ld64-77'
res
=
get_versions
()
res
=
get_versions
()
self
.
assertEqual
s
(
res
[
1
],
None
)
self
.
assertEqual
(
res
[
1
],
None
)
# and dllwrap
# and dllwrap
self
.
_exes
[
'dllwrap'
]
=
b'GNU dllwrap 2.17.50 20060824
\
n
FSF'
self
.
_exes
[
'dllwrap'
]
=
b'GNU dllwrap 2.17.50 20060824
\
n
FSF'
res
=
get_versions
()
res
=
get_versions
()
self
.
assertEqual
s
(
str
(
res
[
2
]),
'2.17.50'
)
self
.
assertEqual
(
str
(
res
[
2
]),
'2.17.50'
)
self
.
_exes
[
'dllwrap'
]
=
b'Cheese Wrap'
self
.
_exes
[
'dllwrap'
]
=
b'Cheese Wrap'
res
=
get_versions
()
res
=
get_versions
()
self
.
assertEqual
s
(
res
[
2
],
None
)
self
.
assertEqual
(
res
[
2
],
None
)
def
test_get_msvcr
(
self
):
def
test_get_msvcr
(
self
):
# none
# none
sys
.
version
=
(
'2.6.1 (r261:67515, Dec 6 2008, 16:42:21) '
sys
.
version
=
(
'2.6.1 (r261:67515, Dec 6 2008, 16:42:21) '
'
\
n
[GCC 4.0.1 (Apple Computer, Inc. build 5370)]'
)
'
\
n
[GCC 4.0.1 (Apple Computer, Inc. build 5370)]'
)
self
.
assertEqual
s
(
get_msvcr
(),
None
)
self
.
assertEqual
(
get_msvcr
(),
None
)
# MSVC 7.0
# MSVC 7.0
sys
.
version
=
(
'2.5.1 (r251:54863, Apr 18 2007, 08:51:08) '
sys
.
version
=
(
'2.5.1 (r251:54863, Apr 18 2007, 08:51:08) '
'[MSC v.1300 32 bits (Intel)]'
)
'[MSC v.1300 32 bits (Intel)]'
)
self
.
assertEqual
s
(
get_msvcr
(),
[
'msvcr70'
])
self
.
assertEqual
(
get_msvcr
(),
[
'msvcr70'
])
# MSVC 7.1
# MSVC 7.1
sys
.
version
=
(
'2.5.1 (r251:54863, Apr 18 2007, 08:51:08) '
sys
.
version
=
(
'2.5.1 (r251:54863, Apr 18 2007, 08:51:08) '
'[MSC v.1310 32 bits (Intel)]'
)
'[MSC v.1310 32 bits (Intel)]'
)
self
.
assertEqual
s
(
get_msvcr
(),
[
'msvcr71'
])
self
.
assertEqual
(
get_msvcr
(),
[
'msvcr71'
])
# VS2005 / MSVC 8.0
# VS2005 / MSVC 8.0
sys
.
version
=
(
'2.5.1 (r251:54863, Apr 18 2007, 08:51:08) '
sys
.
version
=
(
'2.5.1 (r251:54863, Apr 18 2007, 08:51:08) '
'[MSC v.1400 32 bits (Intel)]'
)
'[MSC v.1400 32 bits (Intel)]'
)
self
.
assertEqual
s
(
get_msvcr
(),
[
'msvcr80'
])
self
.
assertEqual
(
get_msvcr
(),
[
'msvcr80'
])
# VS2008 / MSVC 9.0
# VS2008 / MSVC 9.0
sys
.
version
=
(
'2.5.1 (r251:54863, Apr 18 2007, 08:51:08) '
sys
.
version
=
(
'2.5.1 (r251:54863, Apr 18 2007, 08:51:08) '
'[MSC v.1500 32 bits (Intel)]'
)
'[MSC v.1500 32 bits (Intel)]'
)
self
.
assertEqual
s
(
get_msvcr
(),
[
'msvcr90'
])
self
.
assertEqual
(
get_msvcr
(),
[
'msvcr90'
])
# unknown
# unknown
sys
.
version
=
(
'2.5.1 (r251:54863, Apr 18 2007, 08:51:08) '
sys
.
version
=
(
'2.5.1 (r251:54863, Apr 18 2007, 08:51:08) '
...
...
tests/test_dep_util.py
View file @
df79f96e
...
@@ -43,8 +43,8 @@ class DepUtilTestCase(support.TempdirManager, unittest.TestCase):
...
@@ -43,8 +43,8 @@ class DepUtilTestCase(support.TempdirManager, unittest.TestCase):
self
.
write_file
(
two
)
self
.
write_file
(
two
)
self
.
write_file
(
four
)
self
.
write_file
(
four
)
self
.
assertEqual
s
(
newer_pairwise
([
one
,
two
],
[
three
,
four
]),
self
.
assertEqual
(
newer_pairwise
([
one
,
two
],
[
three
,
four
]),
([
one
],[
three
]))
([
one
],[
three
]))
def
test_newer_group
(
self
):
def
test_newer_group
(
self
):
tmpdir
=
self
.
mkdtemp
()
tmpdir
=
self
.
mkdtemp
()
...
...
tests/test_dir_util.py
View file @
df79f96e
...
@@ -38,18 +38,18 @@ class DirUtilTestCase(support.TempdirManager, unittest.TestCase):
...
@@ -38,18 +38,18 @@ class DirUtilTestCase(support.TempdirManager, unittest.TestCase):
mkpath
(
self
.
target
,
verbose
=
0
)
mkpath
(
self
.
target
,
verbose
=
0
)
wanted
=
[]
wanted
=
[]
self
.
assertEqual
s
(
self
.
_logs
,
wanted
)
self
.
assertEqual
(
self
.
_logs
,
wanted
)
remove_tree
(
self
.
root_target
,
verbose
=
0
)
remove_tree
(
self
.
root_target
,
verbose
=
0
)
mkpath
(
self
.
target
,
verbose
=
1
)
mkpath
(
self
.
target
,
verbose
=
1
)
wanted
=
[
'creating %s'
%
self
.
root_target
,
wanted
=
[
'creating %s'
%
self
.
root_target
,
'creating %s'
%
self
.
target
]
'creating %s'
%
self
.
target
]
self
.
assertEqual
s
(
self
.
_logs
,
wanted
)
self
.
assertEqual
(
self
.
_logs
,
wanted
)
self
.
_logs
=
[]
self
.
_logs
=
[]
remove_tree
(
self
.
root_target
,
verbose
=
1
)
remove_tree
(
self
.
root_target
,
verbose
=
1
)
wanted
=
[
"removing '%s' (and everything under it)"
%
self
.
root_target
]
wanted
=
[
"removing '%s' (and everything under it)"
%
self
.
root_target
]
self
.
assertEqual
s
(
self
.
_logs
,
wanted
)
self
.
assertEqual
(
self
.
_logs
,
wanted
)
@
unittest
.
skipIf
(
sys
.
platform
.
startswith
(
'win'
),
@
unittest
.
skipIf
(
sys
.
platform
.
startswith
(
'win'
),
"This test is only appropriate for POSIX-like systems."
)
"This test is only appropriate for POSIX-like systems."
)
...
@@ -67,12 +67,12 @@ class DirUtilTestCase(support.TempdirManager, unittest.TestCase):
...
@@ -67,12 +67,12 @@ class DirUtilTestCase(support.TempdirManager, unittest.TestCase):
def
test_create_tree_verbosity
(
self
):
def
test_create_tree_verbosity
(
self
):
create_tree
(
self
.
root_target
,
[
'one'
,
'two'
,
'three'
],
verbose
=
0
)
create_tree
(
self
.
root_target
,
[
'one'
,
'two'
,
'three'
],
verbose
=
0
)
self
.
assertEqual
s
(
self
.
_logs
,
[])
self
.
assertEqual
(
self
.
_logs
,
[])
remove_tree
(
self
.
root_target
,
verbose
=
0
)
remove_tree
(
self
.
root_target
,
verbose
=
0
)
wanted
=
[
'creating %s'
%
self
.
root_target
]
wanted
=
[
'creating %s'
%
self
.
root_target
]
create_tree
(
self
.
root_target
,
[
'one'
,
'two'
,
'three'
],
verbose
=
1
)
create_tree
(
self
.
root_target
,
[
'one'
,
'two'
,
'three'
],
verbose
=
1
)
self
.
assertEqual
s
(
self
.
_logs
,
wanted
)
self
.
assertEqual
(
self
.
_logs
,
wanted
)
remove_tree
(
self
.
root_target
,
verbose
=
0
)
remove_tree
(
self
.
root_target
,
verbose
=
0
)
...
@@ -82,7 +82,7 @@ class DirUtilTestCase(support.TempdirManager, unittest.TestCase):
...
@@ -82,7 +82,7 @@ class DirUtilTestCase(support.TempdirManager, unittest.TestCase):
mkpath
(
self
.
target
,
verbose
=
0
)
mkpath
(
self
.
target
,
verbose
=
0
)
copy_tree
(
self
.
target
,
self
.
target2
,
verbose
=
0
)
copy_tree
(
self
.
target
,
self
.
target2
,
verbose
=
0
)
self
.
assertEqual
s
(
self
.
_logs
,
[])
self
.
assertEqual
(
self
.
_logs
,
[])
remove_tree
(
self
.
root_target
,
verbose
=
0
)
remove_tree
(
self
.
root_target
,
verbose
=
0
)
...
@@ -96,18 +96,18 @@ class DirUtilTestCase(support.TempdirManager, unittest.TestCase):
...
@@ -96,18 +96,18 @@ class DirUtilTestCase(support.TempdirManager, unittest.TestCase):
wanted
=
[
'copying %s -> %s'
%
(
a_file
,
self
.
target2
)]
wanted
=
[
'copying %s -> %s'
%
(
a_file
,
self
.
target2
)]
copy_tree
(
self
.
target
,
self
.
target2
,
verbose
=
1
)
copy_tree
(
self
.
target
,
self
.
target2
,
verbose
=
1
)
self
.
assertEqual
s
(
self
.
_logs
,
wanted
)
self
.
assertEqual
(
self
.
_logs
,
wanted
)
remove_tree
(
self
.
root_target
,
verbose
=
0
)
remove_tree
(
self
.
root_target
,
verbose
=
0
)
remove_tree
(
self
.
target2
,
verbose
=
0
)
remove_tree
(
self
.
target2
,
verbose
=
0
)
def
test_ensure_relative
(
self
):
def
test_ensure_relative
(
self
):
if
os
.
sep
==
'/'
:
if
os
.
sep
==
'/'
:
self
.
assertEqual
s
(
ensure_relative
(
'/home/foo'
),
'home/foo'
)
self
.
assertEqual
(
ensure_relative
(
'/home/foo'
),
'home/foo'
)
self
.
assertEqual
s
(
ensure_relative
(
'some/path'
),
'some/path'
)
self
.
assertEqual
(
ensure_relative
(
'some/path'
),
'some/path'
)
else
:
# \\
else
:
# \\
self
.
assertEqual
s
(
ensure_relative
(
'c:
\
\
home
\
\
foo'
),
'c:home
\
\
foo'
)
self
.
assertEqual
(
ensure_relative
(
'c:
\
\
home
\
\
foo'
),
'c:home
\
\
foo'
)
self
.
assertEqual
s
(
ensure_relative
(
'home
\
\
foo'
),
'home
\
\
foo'
)
self
.
assertEqual
(
ensure_relative
(
'home
\
\
foo'
),
'home
\
\
foo'
)
def
test_suite
():
def
test_suite
():
return
unittest
.
makeSuite
(
DirUtilTestCase
)
return
unittest
.
makeSuite
(
DirUtilTestCase
)
...
...
tests/test_dist.py
View file @
df79f96e
...
@@ -124,7 +124,7 @@ class DistributionTestCase(support.LoggingSilencer,
...
@@ -124,7 +124,7 @@ class DistributionTestCase(support.LoggingSilencer,
finally
:
finally
:
warnings
.
warn
=
old_warn
warnings
.
warn
=
old_warn
self
.
assertEqual
s
(
len
(
warns
),
0
)
self
.
assertEqual
(
len
(
warns
),
0
)
def
test_finalize_options
(
self
):
def
test_finalize_options
(
self
):
...
@@ -135,20 +135,20 @@ class DistributionTestCase(support.LoggingSilencer,
...
@@ -135,20 +135,20 @@ class DistributionTestCase(support.LoggingSilencer,
dist
.
finalize_options
()
dist
.
finalize_options
()
# finalize_option splits platforms and keywords
# finalize_option splits platforms and keywords
self
.
assertEqual
s
(
dist
.
metadata
.
platforms
,
[
'one'
,
'two'
])
self
.
assertEqual
(
dist
.
metadata
.
platforms
,
[
'one'
,
'two'
])
self
.
assertEqual
s
(
dist
.
metadata
.
keywords
,
[
'one'
,
'two'
])
self
.
assertEqual
(
dist
.
metadata
.
keywords
,
[
'one'
,
'two'
])
def
test_get_command_packages
(
self
):
def
test_get_command_packages
(
self
):
dist
=
Distribution
()
dist
=
Distribution
()
self
.
assertEqual
s
(
dist
.
command_packages
,
None
)
self
.
assertEqual
(
dist
.
command_packages
,
None
)
cmds
=
dist
.
get_command_packages
()
cmds
=
dist
.
get_command_packages
()
self
.
assertEqual
s
(
cmds
,
[
'distutils.command'
])
self
.
assertEqual
(
cmds
,
[
'distutils.command'
])
self
.
assertEqual
s
(
dist
.
command_packages
,
self
.
assertEqual
(
dist
.
command_packages
,
[
'distutils.command'
])
[
'distutils.command'
])
dist
.
command_packages
=
'one,two'
dist
.
command_packages
=
'one,two'
cmds
=
dist
.
get_command_packages
()
cmds
=
dist
.
get_command_packages
()
self
.
assertEqual
s
(
cmds
,
[
'distutils.command'
,
'one'
,
'two'
])
self
.
assertEqual
(
cmds
,
[
'distutils.command'
,
'one'
,
'two'
])
def
test_announce
(
self
):
def
test_announce
(
self
):
...
@@ -287,8 +287,8 @@ class MetadataTestCase(support.TempdirManager, support.EnvironGuard,
...
@@ -287,8 +287,8 @@ class MetadataTestCase(support.TempdirManager, support.EnvironGuard,
def
test_fix_help_options
(
self
):
def
test_fix_help_options
(
self
):
help_tuples
=
[(
'a'
,
'b'
,
'c'
,
'd'
),
(
1
,
2
,
3
,
4
)]
help_tuples
=
[(
'a'
,
'b'
,
'c'
,
'd'
),
(
1
,
2
,
3
,
4
)]
fancy_options
=
fix_help_options
(
help_tuples
)
fancy_options
=
fix_help_options
(
help_tuples
)
self
.
assertEqual
s
(
fancy_options
[
0
],
(
'a'
,
'b'
,
'c'
))
self
.
assertEqual
(
fancy_options
[
0
],
(
'a'
,
'b'
,
'c'
))
self
.
assertEqual
s
(
fancy_options
[
1
],
(
1
,
2
,
3
))
self
.
assertEqual
(
fancy_options
[
1
],
(
1
,
2
,
3
))
def
test_show_help
(
self
):
def
test_show_help
(
self
):
# smoke test, just makes sure some help is displayed
# smoke test, just makes sure some help is displayed
...
...
tests/test_extension.py
View file @
df79f96e
...
@@ -28,38 +28,38 @@ class ExtensionTestCase(unittest.TestCase):
...
@@ -28,38 +28,38 @@ class ExtensionTestCase(unittest.TestCase):
'rect'
,
'rwobject'
,
'scrap'
,
'surface'
,
'surflock'
,
'rect'
,
'rwobject'
,
'scrap'
,
'surface'
,
'surflock'
,
'time'
,
'transform'
]
'time'
,
'transform'
]
self
.
assertEqual
s
(
names
,
wanted
)
self
.
assertEqual
(
names
,
wanted
)
def
test_extension_init
(
self
):
def
test_extension_init
(
self
):
# the first argument, which is the name, must be a string
# the first argument, which is the name, must be a string
self
.
assertRaises
(
AssertionError
,
Extension
,
1
,
[])
self
.
assertRaises
(
AssertionError
,
Extension
,
1
,
[])
ext
=
Extension
(
'name'
,
[])
ext
=
Extension
(
'name'
,
[])
self
.
assertEqual
s
(
ext
.
name
,
'name'
)
self
.
assertEqual
(
ext
.
name
,
'name'
)
# the second argument, which is the list of files, must
# the second argument, which is the list of files, must
# be a list of strings
# be a list of strings
self
.
assertRaises
(
AssertionError
,
Extension
,
'name'
,
'file'
)
self
.
assertRaises
(
AssertionError
,
Extension
,
'name'
,
'file'
)
self
.
assertRaises
(
AssertionError
,
Extension
,
'name'
,
[
'file'
,
1
])
self
.
assertRaises
(
AssertionError
,
Extension
,
'name'
,
[
'file'
,
1
])
ext
=
Extension
(
'name'
,
[
'file1'
,
'file2'
])
ext
=
Extension
(
'name'
,
[
'file1'
,
'file2'
])
self
.
assertEqual
s
(
ext
.
sources
,
[
'file1'
,
'file2'
])
self
.
assertEqual
(
ext
.
sources
,
[
'file1'
,
'file2'
])
# others arguments have defaults
# others arguments have defaults
for
attr
in
(
'include_dirs'
,
'define_macros'
,
'undef_macros'
,
for
attr
in
(
'include_dirs'
,
'define_macros'
,
'undef_macros'
,
'library_dirs'
,
'libraries'
,
'runtime_library_dirs'
,
'library_dirs'
,
'libraries'
,
'runtime_library_dirs'
,
'extra_objects'
,
'extra_compile_args'
,
'extra_link_args'
,
'extra_objects'
,
'extra_compile_args'
,
'extra_link_args'
,
'export_symbols'
,
'swig_opts'
,
'depends'
):
'export_symbols'
,
'swig_opts'
,
'depends'
):
self
.
assertEqual
s
(
getattr
(
ext
,
attr
),
[])
self
.
assertEqual
(
getattr
(
ext
,
attr
),
[])
self
.
assertEqual
s
(
ext
.
language
,
None
)
self
.
assertEqual
(
ext
.
language
,
None
)
self
.
assertEqual
s
(
ext
.
optional
,
None
)
self
.
assertEqual
(
ext
.
optional
,
None
)
# if there are unknown keyword options, warn about them
# if there are unknown keyword options, warn about them
with
check_warnings
()
as
w
:
with
check_warnings
()
as
w
:
warnings
.
simplefilter
(
'always'
)
warnings
.
simplefilter
(
'always'
)
ext
=
Extension
(
'name'
,
[
'file1'
,
'file2'
],
chic
=
True
)
ext
=
Extension
(
'name'
,
[
'file1'
,
'file2'
],
chic
=
True
)
self
.
assertEqual
s
(
len
(
w
.
warnings
),
1
)
self
.
assertEqual
(
len
(
w
.
warnings
),
1
)
self
.
assertEqual
s
(
str
(
w
.
warnings
[
0
].
message
),
self
.
assertEqual
(
str
(
w
.
warnings
[
0
].
message
),
"Unknown Extension options: 'chic'"
)
"Unknown Extension options: 'chic'"
)
def
test_suite
():
def
test_suite
():
...
...
tests/test_file_util.py
View file @
df79f96e
...
@@ -39,14 +39,14 @@ class FileUtilTestCase(support.TempdirManager, unittest.TestCase):
...
@@ -39,14 +39,14 @@ class FileUtilTestCase(support.TempdirManager, unittest.TestCase):
move_file
(
self
.
source
,
self
.
target
,
verbose
=
0
)
move_file
(
self
.
source
,
self
.
target
,
verbose
=
0
)
wanted
=
[]
wanted
=
[]
self
.
assertEqual
s
(
self
.
_logs
,
wanted
)
self
.
assertEqual
(
self
.
_logs
,
wanted
)
# back to original state
# back to original state
move_file
(
self
.
target
,
self
.
source
,
verbose
=
0
)
move_file
(
self
.
target
,
self
.
source
,
verbose
=
0
)
move_file
(
self
.
source
,
self
.
target
,
verbose
=
1
)
move_file
(
self
.
source
,
self
.
target
,
verbose
=
1
)
wanted
=
[
'moving %s -> %s'
%
(
self
.
source
,
self
.
target
)]
wanted
=
[
'moving %s -> %s'
%
(
self
.
source
,
self
.
target
)]
self
.
assertEqual
s
(
self
.
_logs
,
wanted
)
self
.
assertEqual
(
self
.
_logs
,
wanted
)
# back to original state
# back to original state
move_file
(
self
.
target
,
self
.
source
,
verbose
=
0
)
move_file
(
self
.
target
,
self
.
source
,
verbose
=
0
)
...
@@ -56,7 +56,7 @@ class FileUtilTestCase(support.TempdirManager, unittest.TestCase):
...
@@ -56,7 +56,7 @@ class FileUtilTestCase(support.TempdirManager, unittest.TestCase):
os
.
mkdir
(
self
.
target_dir
)
os
.
mkdir
(
self
.
target_dir
)
move_file
(
self
.
source
,
self
.
target_dir
,
verbose
=
1
)
move_file
(
self
.
source
,
self
.
target_dir
,
verbose
=
1
)
wanted
=
[
'moving %s -> %s'
%
(
self
.
source
,
self
.
target_dir
)]
wanted
=
[
'moving %s -> %s'
%
(
self
.
source
,
self
.
target_dir
)]
self
.
assertEqual
s
(
self
.
_logs
,
wanted
)
self
.
assertEqual
(
self
.
_logs
,
wanted
)
def
test_suite
():
def
test_suite
():
...
...
tests/test_filelist.py
View file @
df79f96e
...
@@ -9,29 +9,29 @@ class FileListTestCase(unittest.TestCase):
...
@@ -9,29 +9,29 @@ class FileListTestCase(unittest.TestCase):
def
test_glob_to_re
(
self
):
def
test_glob_to_re
(
self
):
# simple cases
# simple cases
self
.
assertEqual
s
(
glob_to_re
(
'foo*'
),
'foo[^/]*
\
\
Z(?ms)'
)
self
.
assertEqual
(
glob_to_re
(
'foo*'
),
'foo[^/]*
\
\
Z(?ms)'
)
self
.
assertEqual
s
(
glob_to_re
(
'foo?'
),
'foo[^/]
\
\
Z(?ms)'
)
self
.
assertEqual
(
glob_to_re
(
'foo?'
),
'foo[^/]
\
\
Z(?ms)'
)
self
.
assertEqual
s
(
glob_to_re
(
'foo??'
),
'foo[^/][^/]
\
\
Z(?ms)'
)
self
.
assertEqual
(
glob_to_re
(
'foo??'
),
'foo[^/][^/]
\
\
Z(?ms)'
)
# special cases
# special cases
self
.
assertEqual
s
(
glob_to_re
(
r'foo\\*'
),
r'foo\\\\[^/]*\
Z(?ms)
')
self
.
assertEqual
(
glob_to_re
(
r'foo\\*'
),
r'foo\\\\[^/]*\
Z(?ms)
')
self.assertEqual
s
(glob_to_re(r'
foo
\\\
*
'), r'
foo
\\\\\\
[
^/
]
*
\
Z
(
?
ms
)
')
self.assertEqual(glob_to_re(r'
foo
\\\
*
'), r'
foo
\\\\\\
[
^/
]
*
\
Z
(
?
ms
)
')
self.assertEqual
s
(glob_to_re('
foo
????
'), r'
foo
[
^/
][
^/
][
^/
][
^/
]
\
Z
(
?
ms
)
')
self.assertEqual(glob_to_re('
foo
????
'), r'
foo
[
^/
][
^/
][
^/
][
^/
]
\
Z
(
?
ms
)
')
self.assertEqual
s
(glob_to_re(r'
foo
\\
??
'), r'
foo
\\\\
[
^/
][
^/
]
\
Z
(
?
ms
)
')
self.assertEqual(glob_to_re(r'
foo
\\
??
'), r'
foo
\\\\
[
^/
][
^/
]
\
Z
(
?
ms
)
')
def test_debug_print(self):
def test_debug_print(self):
file_list = FileList()
file_list = FileList()
with captured_stdout() as stdout:
with captured_stdout() as stdout:
file_list.debug_print('
xxx
')
file_list.debug_print('
xxx
')
stdout.seek(0)
stdout.seek(0)
self.assertEqual
s
(stdout.read(), '')
self.assertEqual(stdout.read(), '')
debug.DEBUG = True
debug.DEBUG = True
try:
try:
with captured_stdout() as stdout:
with captured_stdout() as stdout:
file_list.debug_print('
xxx
')
file_list.debug_print('
xxx
')
stdout.seek(0)
stdout.seek(0)
self.assertEqual
s
(stdout.read(), '
xxx
\
n
')
self.assertEqual(stdout.read(), '
xxx
\
n
')
finally:
finally:
debug.DEBUG = False
debug.DEBUG = False
...
...
tests/test_install.py
View file @
df79f96e
...
@@ -123,23 +123,23 @@ class InstallTestCase(support.TempdirManager,
...
@@ -123,23 +123,23 @@ class InstallTestCase(support.TempdirManager,
# two elements
# two elements
cmd
.
handle_extra_path
()
cmd
.
handle_extra_path
()
self
.
assertEqual
s
(
cmd
.
extra_path
,
[
'path'
,
'dirs'
])
self
.
assertEqual
(
cmd
.
extra_path
,
[
'path'
,
'dirs'
])
self
.
assertEqual
s
(
cmd
.
extra_dirs
,
'dirs'
)
self
.
assertEqual
(
cmd
.
extra_dirs
,
'dirs'
)
self
.
assertEqual
s
(
cmd
.
path_file
,
'path'
)
self
.
assertEqual
(
cmd
.
path_file
,
'path'
)
# one element
# one element
cmd
.
extra_path
=
[
'path'
]
cmd
.
extra_path
=
[
'path'
]
cmd
.
handle_extra_path
()
cmd
.
handle_extra_path
()
self
.
assertEqual
s
(
cmd
.
extra_path
,
[
'path'
])
self
.
assertEqual
(
cmd
.
extra_path
,
[
'path'
])
self
.
assertEqual
s
(
cmd
.
extra_dirs
,
'path'
)
self
.
assertEqual
(
cmd
.
extra_dirs
,
'path'
)
self
.
assertEqual
s
(
cmd
.
path_file
,
'path'
)
self
.
assertEqual
(
cmd
.
path_file
,
'path'
)
# none
# none
dist
.
extra_path
=
cmd
.
extra_path
=
None
dist
.
extra_path
=
cmd
.
extra_path
=
None
cmd
.
handle_extra_path
()
cmd
.
handle_extra_path
()
self
.
assertEqual
s
(
cmd
.
extra_path
,
None
)
self
.
assertEqual
(
cmd
.
extra_path
,
None
)
self
.
assertEqual
s
(
cmd
.
extra_dirs
,
''
)
self
.
assertEqual
(
cmd
.
extra_dirs
,
''
)
self
.
assertEqual
s
(
cmd
.
path_file
,
None
)
self
.
assertEqual
(
cmd
.
path_file
,
None
)
# three elements (no way !)
# three elements (no way !)
cmd
.
extra_path
=
'path,dirs,again'
cmd
.
extra_path
=
'path,dirs,again'
...
@@ -184,7 +184,7 @@ class InstallTestCase(support.TempdirManager,
...
@@ -184,7 +184,7 @@ class InstallTestCase(support.TempdirManager,
# line (the egg info file)
# line (the egg info file)
f
=
open
(
cmd
.
record
)
f
=
open
(
cmd
.
record
)
try
:
try
:
self
.
assertEqual
s
(
len
(
f
.
readlines
()),
1
)
self
.
assertEqual
(
len
(
f
.
readlines
()),
1
)
finally
:
finally
:
f
.
close
()
f
.
close
()
...
...
tests/test_install_data.py
View file @
df79f96e
...
@@ -28,14 +28,14 @@ class InstallDataTestCase(support.TempdirManager,
...
@@ -28,14 +28,14 @@ class InstallDataTestCase(support.TempdirManager,
self
.
write_file
(
two
,
'xxx'
)
self
.
write_file
(
two
,
'xxx'
)
cmd
.
data_files
=
[
one
,
(
inst2
,
[
two
])]
cmd
.
data_files
=
[
one
,
(
inst2
,
[
two
])]
self
.
assertEqual
s
(
cmd
.
get_inputs
(),
[
one
,
(
inst2
,
[
two
])])
self
.
assertEqual
(
cmd
.
get_inputs
(),
[
one
,
(
inst2
,
[
two
])])
# let's run the command
# let's run the command
cmd
.
ensure_finalized
()
cmd
.
ensure_finalized
()
cmd
.
run
()
cmd
.
run
()
# let's check the result
# let's check the result
self
.
assertEqual
s
(
len
(
cmd
.
get_outputs
()),
2
)
self
.
assertEqual
(
len
(
cmd
.
get_outputs
()),
2
)
rtwo
=
os
.
path
.
split
(
two
)[
-
1
]
rtwo
=
os
.
path
.
split
(
two
)[
-
1
]
self
.
assertTrue
(
os
.
path
.
exists
(
os
.
path
.
join
(
inst2
,
rtwo
)))
self
.
assertTrue
(
os
.
path
.
exists
(
os
.
path
.
join
(
inst2
,
rtwo
)))
rone
=
os
.
path
.
split
(
one
)[
-
1
]
rone
=
os
.
path
.
split
(
one
)[
-
1
]
...
@@ -48,7 +48,7 @@ class InstallDataTestCase(support.TempdirManager,
...
@@ -48,7 +48,7 @@ class InstallDataTestCase(support.TempdirManager,
cmd
.
run
()
cmd
.
run
()
# let's check the result
# let's check the result
self
.
assertEqual
s
(
len
(
cmd
.
get_outputs
()),
2
)
self
.
assertEqual
(
len
(
cmd
.
get_outputs
()),
2
)
self
.
assertTrue
(
os
.
path
.
exists
(
os
.
path
.
join
(
inst2
,
rtwo
)))
self
.
assertTrue
(
os
.
path
.
exists
(
os
.
path
.
join
(
inst2
,
rtwo
)))
self
.
assertTrue
(
os
.
path
.
exists
(
os
.
path
.
join
(
inst
,
rone
)))
self
.
assertTrue
(
os
.
path
.
exists
(
os
.
path
.
join
(
inst
,
rone
)))
cmd
.
outfiles
=
[]
cmd
.
outfiles
=
[]
...
@@ -66,7 +66,7 @@ class InstallDataTestCase(support.TempdirManager,
...
@@ -66,7 +66,7 @@ class InstallDataTestCase(support.TempdirManager,
cmd
.
run
()
cmd
.
run
()
# let's check the result
# let's check the result
self
.
assertEqual
s
(
len
(
cmd
.
get_outputs
()),
4
)
self
.
assertEqual
(
len
(
cmd
.
get_outputs
()),
4
)
self
.
assertTrue
(
os
.
path
.
exists
(
os
.
path
.
join
(
inst2
,
rtwo
)))
self
.
assertTrue
(
os
.
path
.
exists
(
os
.
path
.
join
(
inst2
,
rtwo
)))
self
.
assertTrue
(
os
.
path
.
exists
(
os
.
path
.
join
(
inst
,
rone
)))
self
.
assertTrue
(
os
.
path
.
exists
(
os
.
path
.
join
(
inst
,
rone
)))
...
...
tests/test_install_headers.py
View file @
df79f96e
...
@@ -24,7 +24,7 @@ class InstallHeadersTestCase(support.TempdirManager,
...
@@ -24,7 +24,7 @@ class InstallHeadersTestCase(support.TempdirManager,
pkg_dir
,
dist
=
self
.
create_dist
(
headers
=
headers
)
pkg_dir
,
dist
=
self
.
create_dist
(
headers
=
headers
)
cmd
=
install_headers
(
dist
)
cmd
=
install_headers
(
dist
)
self
.
assertEqual
s
(
cmd
.
get_inputs
(),
headers
)
self
.
assertEqual
(
cmd
.
get_inputs
(),
headers
)
# let's run the command
# let's run the command
cmd
.
install_dir
=
os
.
path
.
join
(
pkg_dir
,
'inst'
)
cmd
.
install_dir
=
os
.
path
.
join
(
pkg_dir
,
'inst'
)
...
@@ -32,7 +32,7 @@ class InstallHeadersTestCase(support.TempdirManager,
...
@@ -32,7 +32,7 @@ class InstallHeadersTestCase(support.TempdirManager,
cmd
.
run
()
cmd
.
run
()
# let's check the results
# let's check the results
self
.
assertEqual
s
(
len
(
cmd
.
get_outputs
()),
2
)
self
.
assertEqual
(
len
(
cmd
.
get_outputs
()),
2
)
def
test_suite
():
def
test_suite
():
return
unittest
.
makeSuite
(
InstallHeadersTestCase
)
return
unittest
.
makeSuite
(
InstallHeadersTestCase
)
...
...
tests/test_install_lib.py
View file @
df79f96e
...
@@ -19,8 +19,8 @@ class InstallLibTestCase(support.TempdirManager,
...
@@ -19,8 +19,8 @@ class InstallLibTestCase(support.TempdirManager,
cmd
=
install_lib
(
dist
)
cmd
=
install_lib
(
dist
)
cmd
.
finalize_options
()
cmd
.
finalize_options
()
self
.
assertEqual
s
(
cmd
.
compile
,
1
)
self
.
assertEqual
(
cmd
.
compile
,
1
)
self
.
assertEqual
s
(
cmd
.
optimize
,
0
)
self
.
assertEqual
(
cmd
.
optimize
,
0
)
# optimize must be 0, 1, or 2
# optimize must be 0, 1, or 2
cmd
.
optimize
=
'foo'
cmd
.
optimize
=
'foo'
...
@@ -30,7 +30,7 @@ class InstallLibTestCase(support.TempdirManager,
...
@@ -30,7 +30,7 @@ class InstallLibTestCase(support.TempdirManager,
cmd
.
optimize
=
'2'
cmd
.
optimize
=
'2'
cmd
.
finalize_options
()
cmd
.
finalize_options
()
self
.
assertEqual
s
(
cmd
.
optimize
,
2
)
self
.
assertEqual
(
cmd
.
optimize
,
2
)
@
unittest
.
skipUnless
(
not
sys
.
dont_write_bytecode
,
@
unittest
.
skipUnless
(
not
sys
.
dont_write_bytecode
,
'byte-compile not supported'
)
'byte-compile not supported'
)
...
@@ -77,7 +77,7 @@ class InstallLibTestCase(support.TempdirManager,
...
@@ -77,7 +77,7 @@ class InstallLibTestCase(support.TempdirManager,
cmd
.
distribution
.
script_name
=
'setup.py'
cmd
.
distribution
.
script_name
=
'setup.py'
# get_input should return 2 elements
# get_input should return 2 elements
self
.
assertEqual
s
(
len
(
cmd
.
get_inputs
()),
2
)
self
.
assertEqual
(
len
(
cmd
.
get_inputs
()),
2
)
def
test_dont_write_bytecode
(
self
):
def
test_dont_write_bytecode
(
self
):
# makes sure byte_compile is not used
# makes sure byte_compile is not used
...
...
tests/test_log.py
View file @
df79f96e
...
@@ -23,9 +23,9 @@ class TestLog(unittest.TestCase):
...
@@ -23,9 +23,9 @@ class TestLog(unittest.TestCase):
log
.
debug
(
"debug:
\
xe9
"
)
log
.
debug
(
"debug:
\
xe9
"
)
log
.
fatal
(
"fatal:
\
xe9
"
)
log
.
fatal
(
"fatal:
\
xe9
"
)
stdout
.
seek
(
0
)
stdout
.
seek
(
0
)
self
.
assertEqual
s
(
stdout
.
read
().
rstrip
(),
"debug:
\
\
xe9"
)
self
.
assertEqual
(
stdout
.
read
().
rstrip
(),
"debug:
\
\
xe9"
)
stderr
.
seek
(
0
)
stderr
.
seek
(
0
)
self
.
assertEqual
s
(
stderr
.
read
().
rstrip
(),
"fatal:
\
\
xe9"
)
self
.
assertEqual
(
stderr
.
read
().
rstrip
(),
"fatal:
\
\
xe9"
)
finally
:
finally
:
sys
.
stdout
=
old_stdout
sys
.
stdout
=
old_stdout
sys
.
stderr
=
old_stderr
sys
.
stderr
=
old_stderr
...
...
tests/test_msvc9compiler.py
View file @
df79f96e
...
@@ -104,7 +104,7 @@ class msvc9compilerTestCase(support.TempdirManager,
...
@@ -104,7 +104,7 @@ class msvc9compilerTestCase(support.TempdirManager,
import
winreg
import
winreg
HKCU
=
winreg
.
HKEY_CURRENT_USER
HKCU
=
winreg
.
HKEY_CURRENT_USER
keys
=
Reg
.
read_keys
(
HKCU
,
'xxxx'
)
keys
=
Reg
.
read_keys
(
HKCU
,
'xxxx'
)
self
.
assertEqual
s
(
keys
,
None
)
self
.
assertEqual
(
keys
,
None
)
keys
=
Reg
.
read_keys
(
HKCU
,
r'Control Panel'
)
keys
=
Reg
.
read_keys
(
HKCU
,
r'Control Panel'
)
self
.
assertTrue
(
'Desktop'
in
keys
)
self
.
assertTrue
(
'Desktop'
in
keys
)
...
@@ -131,7 +131,7 @@ class msvc9compilerTestCase(support.TempdirManager,
...
@@ -131,7 +131,7 @@ class msvc9compilerTestCase(support.TempdirManager,
f
.
close
()
f
.
close
()
# makes sure the manifest was properly cleaned
# makes sure the manifest was properly cleaned
self
.
assertEqual
s
(
content
,
_CLEANED_MANIFEST
)
self
.
assertEqual
(
content
,
_CLEANED_MANIFEST
)
def
test_suite
():
def
test_suite
():
...
...
tests/test_register.py
View file @
df79f96e
...
@@ -121,7 +121,7 @@ class RegisterTestCase(PyPIRCCommandTestCase):
...
@@ -121,7 +121,7 @@ class RegisterTestCase(PyPIRCCommandTestCase):
f
=
open
(
self
.
rc
)
f
=
open
(
self
.
rc
)
try
:
try
:
content
=
f
.
read
()
content
=
f
.
read
()
self
.
assertEqual
s
(
content
,
WANTED_PYPIRC
)
self
.
assertEqual
(
content
,
WANTED_PYPIRC
)
finally
:
finally
:
f
.
close
()
f
.
close
()
...
@@ -141,8 +141,8 @@ class RegisterTestCase(PyPIRCCommandTestCase):
...
@@ -141,8 +141,8 @@ class RegisterTestCase(PyPIRCCommandTestCase):
req1
=
dict
(
self
.
conn
.
reqs
[
0
].
headers
)
req1
=
dict
(
self
.
conn
.
reqs
[
0
].
headers
)
req2
=
dict
(
self
.
conn
.
reqs
[
1
].
headers
)
req2
=
dict
(
self
.
conn
.
reqs
[
1
].
headers
)
self
.
assertEqual
s
(
req1
[
'Content-length'
],
'1374'
)
self
.
assertEqual
(
req1
[
'Content-length'
],
'1374'
)
self
.
assertEqual
s
(
req2
[
'Content-length'
],
'1374'
)
self
.
assertEqual
(
req2
[
'Content-length'
],
'1374'
)
self
.
assertTrue
((
b'xxx'
)
in
self
.
conn
.
reqs
[
1
].
data
)
self
.
assertTrue
((
b'xxx'
)
in
self
.
conn
.
reqs
[
1
].
data
)
def
test_password_not_in_file
(
self
):
def
test_password_not_in_file
(
self
):
...
@@ -155,7 +155,7 @@ class RegisterTestCase(PyPIRCCommandTestCase):
...
@@ -155,7 +155,7 @@ class RegisterTestCase(PyPIRCCommandTestCase):
# dist.password should be set
# dist.password should be set
# therefore used afterwards by other commands
# therefore used afterwards by other commands
self
.
assertEqual
s
(
cmd
.
distribution
.
password
,
'password'
)
self
.
assertEqual
(
cmd
.
distribution
.
password
,
'password'
)
def
test_registering
(
self
):
def
test_registering
(
self
):
# this test runs choice 2
# this test runs choice 2
...
@@ -172,7 +172,7 @@ class RegisterTestCase(PyPIRCCommandTestCase):
...
@@ -172,7 +172,7 @@ class RegisterTestCase(PyPIRCCommandTestCase):
self
.
assertTrue
(
self
.
conn
.
reqs
,
1
)
self
.
assertTrue
(
self
.
conn
.
reqs
,
1
)
req
=
self
.
conn
.
reqs
[
0
]
req
=
self
.
conn
.
reqs
[
0
]
headers
=
dict
(
req
.
headers
)
headers
=
dict
(
req
.
headers
)
self
.
assertEqual
s
(
headers
[
'Content-length'
],
'608'
)
self
.
assertEqual
(
headers
[
'Content-length'
],
'608'
)
self
.
assertTrue
((
b'tarek'
)
in
req
.
data
)
self
.
assertTrue
((
b'tarek'
)
in
req
.
data
)
def
test_password_reset
(
self
):
def
test_password_reset
(
self
):
...
@@ -190,7 +190,7 @@ class RegisterTestCase(PyPIRCCommandTestCase):
...
@@ -190,7 +190,7 @@ class RegisterTestCase(PyPIRCCommandTestCase):
self
.
assertTrue
(
self
.
conn
.
reqs
,
1
)
self
.
assertTrue
(
self
.
conn
.
reqs
,
1
)
req
=
self
.
conn
.
reqs
[
0
]
req
=
self
.
conn
.
reqs
[
0
]
headers
=
dict
(
req
.
headers
)
headers
=
dict
(
req
.
headers
)
self
.
assertEqual
s
(
headers
[
'Content-length'
],
'290'
)
self
.
assertEqual
(
headers
[
'Content-length'
],
'290'
)
self
.
assertTrue
((
b'tarek'
)
in
req
.
data
)
self
.
assertTrue
((
b'tarek'
)
in
req
.
data
)
def
test_strict
(
self
):
def
test_strict
(
self
):
...
@@ -253,7 +253,7 @@ class RegisterTestCase(PyPIRCCommandTestCase):
...
@@ -253,7 +253,7 @@ class RegisterTestCase(PyPIRCCommandTestCase):
with
check_warnings
()
as
w
:
with
check_warnings
()
as
w
:
warnings
.
simplefilter
(
"always"
)
warnings
.
simplefilter
(
"always"
)
cmd
.
check_metadata
()
cmd
.
check_metadata
()
self
.
assertEqual
s
(
len
(
w
.
warnings
),
1
)
self
.
assertEqual
(
len
(
w
.
warnings
),
1
)
def
test_suite
():
def
test_suite
():
return
unittest
.
makeSuite
(
RegisterTestCase
)
return
unittest
.
makeSuite
(
RegisterTestCase
)
...
...
tests/test_sdist.py
View file @
df79f96e
...
@@ -108,7 +108,7 @@ class SDistTestCase(PyPIRCCommandTestCase):
...
@@ -108,7 +108,7 @@ class SDistTestCase(PyPIRCCommandTestCase):
# now let's check what we have
# now let's check what we have
dist_folder
=
join
(
self
.
tmp_dir
,
'dist'
)
dist_folder
=
join
(
self
.
tmp_dir
,
'dist'
)
files
=
os
.
listdir
(
dist_folder
)
files
=
os
.
listdir
(
dist_folder
)
self
.
assertEqual
s
(
files
,
[
'fake-1.0.zip'
])
self
.
assertEqual
(
files
,
[
'fake-1.0.zip'
])
zip_file
=
zipfile
.
ZipFile
(
join
(
dist_folder
,
'fake-1.0.zip'
))
zip_file
=
zipfile
.
ZipFile
(
join
(
dist_folder
,
'fake-1.0.zip'
))
try
:
try
:
...
@@ -117,7 +117,7 @@ class SDistTestCase(PyPIRCCommandTestCase):
...
@@ -117,7 +117,7 @@ class SDistTestCase(PyPIRCCommandTestCase):
zip_file
.
close
()
zip_file
.
close
()
# making sure everything has been pruned correctly
# making sure everything has been pruned correctly
self
.
assertEqual
s
(
len
(
content
),
4
)
self
.
assertEqual
(
len
(
content
),
4
)
def
test_make_distribution
(
self
):
def
test_make_distribution
(
self
):
...
@@ -138,8 +138,7 @@ class SDistTestCase(PyPIRCCommandTestCase):
...
@@ -138,8 +138,7 @@ class SDistTestCase(PyPIRCCommandTestCase):
dist_folder
=
join
(
self
.
tmp_dir
,
'dist'
)
dist_folder
=
join
(
self
.
tmp_dir
,
'dist'
)
result
=
os
.
listdir
(
dist_folder
)
result
=
os
.
listdir
(
dist_folder
)
result
.
sort
()
result
.
sort
()
self
.
assertEquals
(
result
,
self
.
assertEqual
(
result
,
[
'fake-1.0.tar'
,
'fake-1.0.tar.gz'
]
)
[
'fake-1.0.tar'
,
'fake-1.0.tar.gz'
]
)
os
.
remove
(
join
(
dist_folder
,
'fake-1.0.tar'
))
os
.
remove
(
join
(
dist_folder
,
'fake-1.0.tar'
))
os
.
remove
(
join
(
dist_folder
,
'fake-1.0.tar.gz'
))
os
.
remove
(
join
(
dist_folder
,
'fake-1.0.tar.gz'
))
...
@@ -152,8 +151,7 @@ class SDistTestCase(PyPIRCCommandTestCase):
...
@@ -152,8 +151,7 @@ class SDistTestCase(PyPIRCCommandTestCase):
result
=
os
.
listdir
(
dist_folder
)
result
=
os
.
listdir
(
dist_folder
)
result
.
sort
()
result
.
sort
()
self
.
assertEquals
(
result
,
self
.
assertEqual
(
result
,
[
'fake-1.0.tar'
,
'fake-1.0.tar.gz'
])
[
'fake-1.0.tar'
,
'fake-1.0.tar.gz'
])
def
test_add_defaults
(
self
):
def
test_add_defaults
(
self
):
...
@@ -201,7 +199,7 @@ class SDistTestCase(PyPIRCCommandTestCase):
...
@@ -201,7 +199,7 @@ class SDistTestCase(PyPIRCCommandTestCase):
# now let's check what we have
# now let's check what we have
dist_folder
=
join
(
self
.
tmp_dir
,
'dist'
)
dist_folder
=
join
(
self
.
tmp_dir
,
'dist'
)
files
=
os
.
listdir
(
dist_folder
)
files
=
os
.
listdir
(
dist_folder
)
self
.
assertEqual
s
(
files
,
[
'fake-1.0.zip'
])
self
.
assertEqual
(
files
,
[
'fake-1.0.zip'
])
zip_file
=
zipfile
.
ZipFile
(
join
(
dist_folder
,
'fake-1.0.zip'
))
zip_file
=
zipfile
.
ZipFile
(
join
(
dist_folder
,
'fake-1.0.zip'
))
try
:
try
:
...
@@ -210,13 +208,13 @@ class SDistTestCase(PyPIRCCommandTestCase):
...
@@ -210,13 +208,13 @@ class SDistTestCase(PyPIRCCommandTestCase):
zip_file
.
close
()
zip_file
.
close
()
# making sure everything was added
# making sure everything was added
self
.
assertEqual
s
(
len
(
content
),
11
)
self
.
assertEqual
(
len
(
content
),
11
)
# checking the MANIFEST
# checking the MANIFEST
f
=
open
(
join
(
self
.
tmp_dir
,
'MANIFEST'
))
f
=
open
(
join
(
self
.
tmp_dir
,
'MANIFEST'
))
try
:
try
:
manifest
=
f
.
read
()
manifest
=
f
.
read
()
self
.
assertEqual
s
(
manifest
,
MANIFEST
%
{
'sep'
:
os
.
sep
})
self
.
assertEqual
(
manifest
,
MANIFEST
%
{
'sep'
:
os
.
sep
})
finally
:
finally
:
f
.
close
()
f
.
close
()
...
@@ -229,7 +227,7 @@ class SDistTestCase(PyPIRCCommandTestCase):
...
@@ -229,7 +227,7 @@ class SDistTestCase(PyPIRCCommandTestCase):
cmd
.
ensure_finalized
()
cmd
.
ensure_finalized
()
cmd
.
run
()
cmd
.
run
()
warnings
=
self
.
get_logs
(
WARN
)
warnings
=
self
.
get_logs
(
WARN
)
self
.
assertEqual
s
(
len
(
warnings
),
2
)
self
.
assertEqual
(
len
(
warnings
),
2
)
# trying with a complete set of metadata
# trying with a complete set of metadata
self
.
clear_logs
()
self
.
clear_logs
()
...
@@ -238,7 +236,7 @@ class SDistTestCase(PyPIRCCommandTestCase):
...
@@ -238,7 +236,7 @@ class SDistTestCase(PyPIRCCommandTestCase):
cmd
.
metadata_check
=
0
cmd
.
metadata_check
=
0
cmd
.
run
()
cmd
.
run
()
warnings
=
self
.
get_logs
(
WARN
)
warnings
=
self
.
get_logs
(
WARN
)
self
.
assertEqual
s
(
len
(
warnings
),
0
)
self
.
assertEqual
(
len
(
warnings
),
0
)
def
test_check_metadata_deprecated
(
self
):
def
test_check_metadata_deprecated
(
self
):
# makes sure make_metadata is deprecated
# makes sure make_metadata is deprecated
...
@@ -246,7 +244,7 @@ class SDistTestCase(PyPIRCCommandTestCase):
...
@@ -246,7 +244,7 @@ class SDistTestCase(PyPIRCCommandTestCase):
with
check_warnings
()
as
w
:
with
check_warnings
()
as
w
:
warnings
.
simplefilter
(
"always"
)
warnings
.
simplefilter
(
"always"
)
cmd
.
check_metadata
()
cmd
.
check_metadata
()
self
.
assertEqual
s
(
len
(
w
.
warnings
),
1
)
self
.
assertEqual
(
len
(
w
.
warnings
),
1
)
def
test_show_formats
(
self
):
def
test_show_formats
(
self
):
with
captured_stdout
()
as
stdout
:
with
captured_stdout
()
as
stdout
:
...
@@ -256,7 +254,7 @@ class SDistTestCase(PyPIRCCommandTestCase):
...
@@ -256,7 +254,7 @@ class SDistTestCase(PyPIRCCommandTestCase):
num_formats
=
len
(
ARCHIVE_FORMATS
.
keys
())
num_formats
=
len
(
ARCHIVE_FORMATS
.
keys
())
output
=
[
line
for
line
in
stdout
.
getvalue
().
split
(
'
\
n
'
)
output
=
[
line
for
line
in
stdout
.
getvalue
().
split
(
'
\
n
'
)
if
line
.
strip
().
startswith
(
'--formats='
)]
if
line
.
strip
().
startswith
(
'--formats='
)]
self
.
assertEqual
s
(
len
(
output
),
num_formats
)
self
.
assertEqual
(
len
(
output
),
num_formats
)
def
test_finalize_options
(
self
):
def
test_finalize_options
(
self
):
...
@@ -264,9 +262,9 @@ class SDistTestCase(PyPIRCCommandTestCase):
...
@@ -264,9 +262,9 @@ class SDistTestCase(PyPIRCCommandTestCase):
cmd
.
finalize_options
()
cmd
.
finalize_options
()
# default options set by finalize
# default options set by finalize
self
.
assertEqual
s
(
cmd
.
manifest
,
'MANIFEST'
)
self
.
assertEqual
(
cmd
.
manifest
,
'MANIFEST'
)
self
.
assertEqual
s
(
cmd
.
template
,
'MANIFEST.in'
)
self
.
assertEqual
(
cmd
.
template
,
'MANIFEST.in'
)
self
.
assertEqual
s
(
cmd
.
dist_dir
,
'dist'
)
self
.
assertEqual
(
cmd
.
dist_dir
,
'dist'
)
# formats has to be a string splitable on (' ', ',') or
# formats has to be a string splitable on (' ', ',') or
# a stringlist
# a stringlist
...
@@ -297,7 +295,7 @@ class SDistTestCase(PyPIRCCommandTestCase):
...
@@ -297,7 +295,7 @@ class SDistTestCase(PyPIRCCommandTestCase):
finally
:
finally
:
f
.
close
()
f
.
close
()
self
.
assertEqual
s
(
len
(
manifest
),
5
)
self
.
assertEqual
(
len
(
manifest
),
5
)
# adding a file
# adding a file
self
.
write_file
((
self
.
tmp_dir
,
'somecode'
,
'doc2.txt'
),
'#'
)
self
.
write_file
((
self
.
tmp_dir
,
'somecode'
,
'doc2.txt'
),
'#'
)
...
@@ -317,7 +315,7 @@ class SDistTestCase(PyPIRCCommandTestCase):
...
@@ -317,7 +315,7 @@ class SDistTestCase(PyPIRCCommandTestCase):
f
.
close
()
f
.
close
()
# do we have the new file in MANIFEST ?
# do we have the new file in MANIFEST ?
self
.
assertEqual
s
(
len
(
manifest2
),
6
)
self
.
assertEqual
(
len
(
manifest2
),
6
)
self
.
assertIn
(
'doc2.txt'
,
manifest2
[
-
1
])
self
.
assertIn
(
'doc2.txt'
,
manifest2
[
-
1
])
def
test_manifest_marker
(
self
):
def
test_manifest_marker
(
self
):
...
...
tests/test_spawn.py
View file @
df79f96e
...
@@ -20,7 +20,7 @@ class SpawnTestCase(support.TempdirManager,
...
@@ -20,7 +20,7 @@ class SpawnTestCase(support.TempdirManager,
([
'nochange'
,
'nospace'
],
([
'nochange'
,
'nospace'
],
[
'nochange'
,
'nospace'
])):
[
'nochange'
,
'nospace'
])):
res
=
_nt_quote_args
(
args
)
res
=
_nt_quote_args
(
args
)
self
.
assertEqual
s
(
res
,
wanted
)
self
.
assertEqual
(
res
,
wanted
)
@
unittest
.
skipUnless
(
os
.
name
in
(
'nt'
,
'posix'
),
@
unittest
.
skipUnless
(
os
.
name
in
(
'nt'
,
'posix'
),
...
...
tests/test_sysconfig.py
View file @
df79f96e
...
@@ -70,7 +70,7 @@ class SysconfigTestCase(support.EnvironGuard,
...
@@ -70,7 +70,7 @@ class SysconfigTestCase(support.EnvironGuard,
comp
=
compiler
()
comp
=
compiler
()
sysconfig
.
customize_compiler
(
comp
)
sysconfig
.
customize_compiler
(
comp
)
self
.
assertEqual
s
(
comp
.
exes
[
'archiver'
],
'my_ar -arflags'
)
self
.
assertEqual
(
comp
.
exes
[
'archiver'
],
'my_ar -arflags'
)
def
test_parse_makefile_base
(
self
):
def
test_parse_makefile_base
(
self
):
self
.
makefile
=
TESTFN
self
.
makefile
=
TESTFN
...
@@ -81,8 +81,8 @@ class SysconfigTestCase(support.EnvironGuard,
...
@@ -81,8 +81,8 @@ class SysconfigTestCase(support.EnvironGuard,
finally
:
finally
:
fd
.
close
()
fd
.
close
()
d
=
sysconfig
.
parse_makefile
(
self
.
makefile
)
d
=
sysconfig
.
parse_makefile
(
self
.
makefile
)
self
.
assertEqual
s
(
d
,
{
'CONFIG_ARGS'
:
"'--arg1=optarg1' 'ENV=LIB'"
,
self
.
assertEqual
(
d
,
{
'CONFIG_ARGS'
:
"'--arg1=optarg1' 'ENV=LIB'"
,
'OTHER'
:
'foo'
})
'OTHER'
:
'foo'
})
def
test_parse_makefile_literal_dollar
(
self
):
def
test_parse_makefile_literal_dollar
(
self
):
self
.
makefile
=
TESTFN
self
.
makefile
=
TESTFN
...
@@ -93,16 +93,16 @@ class SysconfigTestCase(support.EnvironGuard,
...
@@ -93,16 +93,16 @@ class SysconfigTestCase(support.EnvironGuard,
finally
:
finally
:
fd
.
close
()
fd
.
close
()
d
=
sysconfig
.
parse_makefile
(
self
.
makefile
)
d
=
sysconfig
.
parse_makefile
(
self
.
makefile
)
self
.
assertEqual
s
(
d
,
{
'CONFIG_ARGS'
:
r"'--arg1=optarg1' 'ENV=\
$LIB
'"
,
self
.
assertEqual
(
d
,
{
'CONFIG_ARGS'
:
r"'--arg1=optarg1' 'ENV=\
$LIB
'"
,
'OTHER'
:
'foo'
})
'OTHER'
:
'foo'
})
def
test_sysconfig_module
(
self
):
def
test_sysconfig_module
(
self
):
import
sysconfig
as
global_sysconfig
import
sysconfig
as
global_sysconfig
self
.
assertEqual
s
(
global_sysconfig
.
get_config_var
(
'CFLAGS'
),
sysconfig
.
get_config_var
(
'CFLAGS'
))
self
.
assertEqual
(
global_sysconfig
.
get_config_var
(
'CFLAGS'
),
sysconfig
.
get_config_var
(
'CFLAGS'
))
self
.
assertEqual
s
(
global_sysconfig
.
get_config_var
(
'LDFLAGS'
),
sysconfig
.
get_config_var
(
'LDFLAGS'
))
self
.
assertEqual
(
global_sysconfig
.
get_config_var
(
'LDFLAGS'
),
sysconfig
.
get_config_var
(
'LDFLAGS'
))
self
.
assertEqual
s
(
global_sysconfig
.
get_config_var
(
'LDSHARED'
),
sysconfig
.
get_config_var
(
'LDSHARED'
))
self
.
assertEqual
(
global_sysconfig
.
get_config_var
(
'LDSHARED'
),
sysconfig
.
get_config_var
(
'LDSHARED'
))
self
.
assertEqual
s
(
global_sysconfig
.
get_config_var
(
'CC'
),
sysconfig
.
get_config_var
(
'CC'
))
self
.
assertEqual
(
global_sysconfig
.
get_config_var
(
'CC'
),
sysconfig
.
get_config_var
(
'CC'
))
...
...
tests/test_text_file.py
View file @
df79f96e
...
@@ -49,7 +49,7 @@ class TextFileTestCase(support.TempdirManager, unittest.TestCase):
...
@@ -49,7 +49,7 @@ class TextFileTestCase(support.TempdirManager, unittest.TestCase):
def
test_input
(
count
,
description
,
file
,
expected_result
):
def
test_input
(
count
,
description
,
file
,
expected_result
):
result
=
file
.
readlines
()
result
=
file
.
readlines
()
self
.
assertEqual
s
(
result
,
expected_result
)
self
.
assertEqual
(
result
,
expected_result
)
tmpdir
=
self
.
mkdtemp
()
tmpdir
=
self
.
mkdtemp
()
filename
=
os
.
path
.
join
(
tmpdir
,
"test.txt"
)
filename
=
os
.
path
.
join
(
tmpdir
,
"test.txt"
)
...
...
tests/test_upload.py
View file @
df79f96e
...
@@ -89,7 +89,7 @@ class uploadTestCase(PyPIRCCommandTestCase):
...
@@ -89,7 +89,7 @@ class uploadTestCase(PyPIRCCommandTestCase):
for
attr
,
waited
in
((
'username'
,
'me'
),
(
'password'
,
'secret'
),
for
attr
,
waited
in
((
'username'
,
'me'
),
(
'password'
,
'secret'
),
(
'realm'
,
'pypi'
),
(
'realm'
,
'pypi'
),
(
'repository'
,
'http://pypi.python.org/pypi'
)):
(
'repository'
,
'http://pypi.python.org/pypi'
)):
self
.
assertEqual
s
(
getattr
(
cmd
,
attr
),
waited
)
self
.
assertEqual
(
getattr
(
cmd
,
attr
),
waited
)
def
test_saved_password
(
self
):
def
test_saved_password
(
self
):
# file with no password
# file with no password
...
@@ -99,14 +99,14 @@ class uploadTestCase(PyPIRCCommandTestCase):
...
@@ -99,14 +99,14 @@ class uploadTestCase(PyPIRCCommandTestCase):
dist
=
Distribution
()
dist
=
Distribution
()
cmd
=
upload
(
dist
)
cmd
=
upload
(
dist
)
cmd
.
finalize_options
()
cmd
.
finalize_options
()
self
.
assertEqual
s
(
cmd
.
password
,
None
)
self
.
assertEqual
(
cmd
.
password
,
None
)
# make sure we get it as well, if another command
# make sure we get it as well, if another command
# initialized it at the dist level
# initialized it at the dist level
dist
.
password
=
'xxx'
dist
.
password
=
'xxx'
cmd
=
upload
(
dist
)
cmd
=
upload
(
dist
)
cmd
.
finalize_options
()
cmd
.
finalize_options
()
self
.
assertEqual
s
(
cmd
.
password
,
'xxx'
)
self
.
assertEqual
(
cmd
.
password
,
'xxx'
)
def
test_upload
(
self
):
def
test_upload
(
self
):
tmp
=
self
.
mkdtemp
()
tmp
=
self
.
mkdtemp
()
...
@@ -124,12 +124,12 @@ class uploadTestCase(PyPIRCCommandTestCase):
...
@@ -124,12 +124,12 @@ class uploadTestCase(PyPIRCCommandTestCase):
# what did we send ?
# what did we send ?
headers
=
dict
(
self
.
conn
.
headers
)
headers
=
dict
(
self
.
conn
.
headers
)
self
.
assertEqual
s
(
headers
[
'Content-length'
],
'2087'
)
self
.
assertEqual
(
headers
[
'Content-length'
],
'2087'
)
self
.
assertTrue
(
headers
[
'Content-type'
].
startswith
(
'multipart/form-data'
))
self
.
assertTrue
(
headers
[
'Content-type'
].
startswith
(
'multipart/form-data'
))
self
.
assertFalse
(
'
\
n
'
in
headers
[
'Authorization'
])
self
.
assertFalse
(
'
\
n
'
in
headers
[
'Authorization'
])
self
.
assertEqual
s
(
self
.
conn
.
requests
,
[(
'POST'
,
'/pypi'
)])
self
.
assertEqual
(
self
.
conn
.
requests
,
[(
'POST'
,
'/pypi'
)])
self
.
assert
_
((
b'xxx'
)
in
self
.
conn
.
body
)
self
.
assert
True
((
b'xxx'
)
in
self
.
conn
.
body
)
def
test_suite
():
def
test_suite
():
return
unittest
.
makeSuite
(
uploadTestCase
)
return
unittest
.
makeSuite
(
uploadTestCase
)
...
...
tests/test_util.py
View file @
df79f96e
...
@@ -67,21 +67,21 @@ class UtilTestCase(support.EnvironGuard, unittest.TestCase):
...
@@ -67,21 +67,21 @@ class UtilTestCase(support.EnvironGuard, unittest.TestCase):
sys
.
version
=
(
'2.4.4 (#71, Oct 18 2006, 08:34:43) '
sys
.
version
=
(
'2.4.4 (#71, Oct 18 2006, 08:34:43) '
'[MSC v.1310 32 bit (Intel)]'
)
'[MSC v.1310 32 bit (Intel)]'
)
sys
.
platform
=
'win32'
sys
.
platform
=
'win32'
self
.
assertEqual
s
(
get_platform
(),
'win32'
)
self
.
assertEqual
(
get_platform
(),
'win32'
)
# windows XP, amd64
# windows XP, amd64
os
.
name
=
'nt'
os
.
name
=
'nt'
sys
.
version
=
(
'2.4.4 (#71, Oct 18 2006, 08:34:43) '
sys
.
version
=
(
'2.4.4 (#71, Oct 18 2006, 08:34:43) '
'[MSC v.1310 32 bit (Amd64)]'
)
'[MSC v.1310 32 bit (Amd64)]'
)
sys
.
platform
=
'win32'
sys
.
platform
=
'win32'
self
.
assertEqual
s
(
get_platform
(),
'win-amd64'
)
self
.
assertEqual
(
get_platform
(),
'win-amd64'
)
# windows XP, itanium
# windows XP, itanium
os
.
name
=
'nt'
os
.
name
=
'nt'
sys
.
version
=
(
'2.4.4 (#71, Oct 18 2006, 08:34:43) '
sys
.
version
=
(
'2.4.4 (#71, Oct 18 2006, 08:34:43) '
'[MSC v.1310 32 bit (Itanium)]'
)
'[MSC v.1310 32 bit (Itanium)]'
)
sys
.
platform
=
'win32'
sys
.
platform
=
'win32'
self
.
assertEqual
s
(
get_platform
(),
'win-ia64'
)
self
.
assertEqual
(
get_platform
(),
'win-ia64'
)
# macbook
# macbook
os
.
name
=
'posix'
os
.
name
=
'posix'
...
@@ -100,7 +100,7 @@ class UtilTestCase(support.EnvironGuard, unittest.TestCase):
...
@@ -100,7 +100,7 @@ class UtilTestCase(support.EnvironGuard, unittest.TestCase):
cursize
=
sys
.
maxsize
cursize
=
sys
.
maxsize
sys
.
maxsize
=
(
2
**
31
)
-
1
sys
.
maxsize
=
(
2
**
31
)
-
1
try
:
try
:
self
.
assertEqual
s
(
get_platform
(),
'macosx-10.3-i386'
)
self
.
assertEqual
(
get_platform
(),
'macosx-10.3-i386'
)
finally
:
finally
:
sys
.
maxsize
=
cursize
sys
.
maxsize
=
cursize
...
@@ -111,33 +111,33 @@ class UtilTestCase(support.EnvironGuard, unittest.TestCase):
...
@@ -111,33 +111,33 @@ class UtilTestCase(support.EnvironGuard, unittest.TestCase):
'-fno-strict-aliasing -fno-common '
'-fno-strict-aliasing -fno-common '
'-dynamic -DNDEBUG -g -O3'
)
'-dynamic -DNDEBUG -g -O3'
)
self
.
assertEqual
s
(
get_platform
(),
'macosx-10.4-fat'
)
self
.
assertEqual
(
get_platform
(),
'macosx-10.4-fat'
)
get_config_vars
()[
'CFLAGS'
]
=
(
'-arch x86_64 -arch i386 -isysroot '
get_config_vars
()[
'CFLAGS'
]
=
(
'-arch x86_64 -arch i386 -isysroot '
'/Developer/SDKs/MacOSX10.4u.sdk '
'/Developer/SDKs/MacOSX10.4u.sdk '
'-fno-strict-aliasing -fno-common '
'-fno-strict-aliasing -fno-common '
'-dynamic -DNDEBUG -g -O3'
)
'-dynamic -DNDEBUG -g -O3'
)
self
.
assertEqual
s
(
get_platform
(),
'macosx-10.4-intel'
)
self
.
assertEqual
(
get_platform
(),
'macosx-10.4-intel'
)
get_config_vars
()[
'CFLAGS'
]
=
(
'-arch x86_64 -arch ppc -arch i386 -isysroot '
get_config_vars
()[
'CFLAGS'
]
=
(
'-arch x86_64 -arch ppc -arch i386 -isysroot '
'/Developer/SDKs/MacOSX10.4u.sdk '
'/Developer/SDKs/MacOSX10.4u.sdk '
'-fno-strict-aliasing -fno-common '
'-fno-strict-aliasing -fno-common '
'-dynamic -DNDEBUG -g -O3'
)
'-dynamic -DNDEBUG -g -O3'
)
self
.
assertEqual
s
(
get_platform
(),
'macosx-10.4-fat3'
)
self
.
assertEqual
(
get_platform
(),
'macosx-10.4-fat3'
)
get_config_vars
()[
'CFLAGS'
]
=
(
'-arch ppc64 -arch x86_64 -arch ppc -arch i386 -isysroot '
get_config_vars
()[
'CFLAGS'
]
=
(
'-arch ppc64 -arch x86_64 -arch ppc -arch i386 -isysroot '
'/Developer/SDKs/MacOSX10.4u.sdk '
'/Developer/SDKs/MacOSX10.4u.sdk '
'-fno-strict-aliasing -fno-common '
'-fno-strict-aliasing -fno-common '
'-dynamic -DNDEBUG -g -O3'
)
'-dynamic -DNDEBUG -g -O3'
)
self
.
assertEqual
s
(
get_platform
(),
'macosx-10.4-universal'
)
self
.
assertEqual
(
get_platform
(),
'macosx-10.4-universal'
)
get_config_vars
()[
'CFLAGS'
]
=
(
'-arch x86_64 -arch ppc64 -isysroot '
get_config_vars
()[
'CFLAGS'
]
=
(
'-arch x86_64 -arch ppc64 -isysroot '
'/Developer/SDKs/MacOSX10.4u.sdk '
'/Developer/SDKs/MacOSX10.4u.sdk '
'-fno-strict-aliasing -fno-common '
'-fno-strict-aliasing -fno-common '
'-dynamic -DNDEBUG -g -O3'
)
'-dynamic -DNDEBUG -g -O3'
)
self
.
assertEqual
s
(
get_platform
(),
'macosx-10.4-fat64'
)
self
.
assertEqual
(
get_platform
(),
'macosx-10.4-fat64'
)
for
arch
in
(
'ppc'
,
'i386'
,
'x86_64'
,
'ppc64'
):
for
arch
in
(
'ppc'
,
'i386'
,
'x86_64'
,
'ppc64'
):
get_config_vars
()[
'CFLAGS'
]
=
(
'-arch %s -isysroot '
get_config_vars
()[
'CFLAGS'
]
=
(
'-arch %s -isysroot '
...
@@ -145,7 +145,7 @@ class UtilTestCase(support.EnvironGuard, unittest.TestCase):
...
@@ -145,7 +145,7 @@ class UtilTestCase(support.EnvironGuard, unittest.TestCase):
'-fno-strict-aliasing -fno-common '
'-fno-strict-aliasing -fno-common '
'-dynamic -DNDEBUG -g -O3'
%
(
arch
,))
'-dynamic -DNDEBUG -g -O3'
%
(
arch
,))
self
.
assertEqual
s
(
get_platform
(),
'macosx-10.4-%s'
%
(
arch
,))
self
.
assertEqual
(
get_platform
(),
'macosx-10.4-%s'
%
(
arch
,))
# linux debian sarge
# linux debian sarge
os
.
name
=
'posix'
os
.
name
=
'posix'
...
@@ -155,7 +155,7 @@ class UtilTestCase(support.EnvironGuard, unittest.TestCase):
...
@@ -155,7 +155,7 @@ class UtilTestCase(support.EnvironGuard, unittest.TestCase):
self
.
_set_uname
((
'Linux'
,
'aglae'
,
'2.6.21.1dedibox-r7'
,
self
.
_set_uname
((
'Linux'
,
'aglae'
,
'2.6.21.1dedibox-r7'
,
'#1 Mon Apr 30 17:25:38 CEST 2007'
,
'i686'
))
'#1 Mon Apr 30 17:25:38 CEST 2007'
,
'i686'
))
self
.
assertEqual
s
(
get_platform
(),
'linux-i686'
)
self
.
assertEqual
(
get_platform
(),
'linux-i686'
)
# XXX more platforms to tests here
# XXX more platforms to tests here
...
@@ -166,8 +166,8 @@ class UtilTestCase(support.EnvironGuard, unittest.TestCase):
...
@@ -166,8 +166,8 @@ class UtilTestCase(support.EnvironGuard, unittest.TestCase):
return
'/'
.
join
(
path
)
return
'/'
.
join
(
path
)
os
.
path
.
join
=
_join
os
.
path
.
join
=
_join
self
.
assertEqual
s
(
convert_path
(
'/home/to/my/stuff'
),
self
.
assertEqual
(
convert_path
(
'/home/to/my/stuff'
),
'/home/to/my/stuff'
)
'/home/to/my/stuff'
)
# win
# win
os
.
sep
=
'
\
\
'
os
.
sep
=
'
\
\
'
...
@@ -178,10 +178,10 @@ class UtilTestCase(support.EnvironGuard, unittest.TestCase):
...
@@ -178,10 +178,10 @@ class UtilTestCase(support.EnvironGuard, unittest.TestCase):
self
.
assertRaises
(
ValueError
,
convert_path
,
'/home/to/my/stuff'
)
self
.
assertRaises
(
ValueError
,
convert_path
,
'/home/to/my/stuff'
)
self
.
assertRaises
(
ValueError
,
convert_path
,
'home/to/my/stuff/'
)
self
.
assertRaises
(
ValueError
,
convert_path
,
'home/to/my/stuff/'
)
self
.
assertEqual
s
(
convert_path
(
'home/to/my/stuff'
),
self
.
assertEqual
(
convert_path
(
'home/to/my/stuff'
),
'home
\
\
to
\
\
my
\
\
stuff'
)
'home
\
\
to
\
\
my
\
\
stuff'
)
self
.
assertEqual
s
(
convert_path
(
'.'
),
self
.
assertEqual
(
convert_path
(
'.'
),
os
.
curdir
)
os
.
curdir
)
def
test_change_root
(
self
):
def
test_change_root
(
self
):
# linux/mac
# linux/mac
...
@@ -193,10 +193,10 @@ class UtilTestCase(support.EnvironGuard, unittest.TestCase):
...
@@ -193,10 +193,10 @@ class UtilTestCase(support.EnvironGuard, unittest.TestCase):
return
'/'
.
join
(
path
)
return
'/'
.
join
(
path
)
os
.
path
.
join
=
_join
os
.
path
.
join
=
_join
self
.
assertEqual
s
(
change_root
(
'/root'
,
'/old/its/here'
),
self
.
assertEqual
(
change_root
(
'/root'
,
'/old/its/here'
),
'/root/old/its/here'
)
'/root/old/its/here'
)
self
.
assertEqual
s
(
change_root
(
'/root'
,
'its/here'
),
self
.
assertEqual
(
change_root
(
'/root'
,
'its/here'
),
'/root/its/here'
)
'/root/its/here'
)
# windows
# windows
os
.
name
=
'nt'
os
.
name
=
'nt'
...
@@ -212,10 +212,10 @@ class UtilTestCase(support.EnvironGuard, unittest.TestCase):
...
@@ -212,10 +212,10 @@ class UtilTestCase(support.EnvironGuard, unittest.TestCase):
return
'
\
\
'
.
join
(
path
)
return
'
\
\
'
.
join
(
path
)
os
.
path
.
join
=
_join
os
.
path
.
join
=
_join
self
.
assertEqual
s
(
change_root
(
'c:
\
\
root'
,
'c:
\
\
old
\
\
its
\
\
here'
),
self
.
assertEqual
(
change_root
(
'c:
\
\
root'
,
'c:
\
\
old
\
\
its
\
\
here'
),
'c:
\
\
root
\
\
old
\
\
its
\
\
here'
)
'c:
\
\
root
\
\
old
\
\
its
\
\
here'
)
self
.
assertEqual
s
(
change_root
(
'c:
\
\
root'
,
'its
\
\
here'
),
self
.
assertEqual
(
change_root
(
'c:
\
\
root'
,
'its
\
\
here'
),
'c:
\
\
root
\
\
its
\
\
here'
)
'c:
\
\
root
\
\
its
\
\
here'
)
# BugsBunny os (it's a great os)
# BugsBunny os (it's a great os)
os
.
name
=
'BugsBunny'
os
.
name
=
'BugsBunny'
...
@@ -233,16 +233,16 @@ class UtilTestCase(support.EnvironGuard, unittest.TestCase):
...
@@ -233,16 +233,16 @@ class UtilTestCase(support.EnvironGuard, unittest.TestCase):
if
os
.
name
==
'posix'
:
# this test won't run on windows
if
os
.
name
==
'posix'
:
# this test won't run on windows
check_environ
()
check_environ
()
import
pwd
import
pwd
self
.
assertEqual
s
(
os
.
environ
[
'HOME'
],
pwd
.
getpwuid
(
os
.
getuid
())[
5
])
self
.
assertEqual
(
os
.
environ
[
'HOME'
],
pwd
.
getpwuid
(
os
.
getuid
())[
5
])
else
:
else
:
check_environ
()
check_environ
()
self
.
assertEqual
s
(
os
.
environ
[
'PLAT'
],
get_platform
())
self
.
assertEqual
(
os
.
environ
[
'PLAT'
],
get_platform
())
self
.
assertEqual
s
(
util
.
_environ_checked
,
1
)
self
.
assertEqual
(
util
.
_environ_checked
,
1
)
def
test_split_quoted
(
self
):
def
test_split_quoted
(
self
):
self
.
assertEqual
s
(
split_quoted
(
'""one"" "two"
\
'
three
\
'
\
\
four'
),
self
.
assertEqual
(
split_quoted
(
'""one"" "two"
\
'
three
\
'
\
\
four'
),
[
'one'
,
'two'
,
'three'
,
'four'
])
[
'one'
,
'two'
,
'three'
,
'four'
])
def
test_strtobool
(
self
):
def
test_strtobool
(
self
):
yes
=
(
'y'
,
'Y'
,
'yes'
,
'True'
,
't'
,
'true'
,
'True'
,
'On'
,
'on'
,
'1'
)
yes
=
(
'y'
,
'Y'
,
'yes'
,
'True'
,
't'
,
'true'
,
'True'
,
'On'
,
'on'
,
'1'
)
...
@@ -259,7 +259,7 @@ class UtilTestCase(support.EnvironGuard, unittest.TestCase):
...
@@ -259,7 +259,7 @@ class UtilTestCase(support.EnvironGuard, unittest.TestCase):
res
=
rfc822_escape
(
header
)
res
=
rfc822_escape
(
header
)
wanted
=
(
'I am a%(8s)spoor%(8s)slonesome%(8s)s'
wanted
=
(
'I am a%(8s)spoor%(8s)slonesome%(8s)s'
'header%(8s)s'
)
%
{
'8s'
:
'
\
n
'
+
8
*
' '
}
'header%(8s)s'
)
%
{
'8s'
:
'
\
n
'
+
8
*
' '
}
self
.
assertEqual
s
(
res
,
wanted
)
self
.
assertEqual
(
res
,
wanted
)
def
test_dont_write_bytecode
(
self
):
def
test_dont_write_bytecode
(
self
):
# makes sure byte_compile raise a DistutilsError
# makes sure byte_compile raise a DistutilsError
...
...
tests/test_version.py
View file @
df79f96e
...
@@ -8,12 +8,12 @@ class VersionTestCase(unittest.TestCase):
...
@@ -8,12 +8,12 @@ class VersionTestCase(unittest.TestCase):
def
test_prerelease
(
self
):
def
test_prerelease
(
self
):
version
=
StrictVersion
(
'1.2.3a1'
)
version
=
StrictVersion
(
'1.2.3a1'
)
self
.
assertEqual
s
(
version
.
version
,
(
1
,
2
,
3
))
self
.
assertEqual
(
version
.
version
,
(
1
,
2
,
3
))
self
.
assertEqual
s
(
version
.
prerelease
,
(
'a'
,
1
))
self
.
assertEqual
(
version
.
prerelease
,
(
'a'
,
1
))
self
.
assertEqual
s
(
str
(
version
),
'1.2.3a1'
)
self
.
assertEqual
(
str
(
version
),
'1.2.3a1'
)
version
=
StrictVersion
(
'1.2.0'
)
version
=
StrictVersion
(
'1.2.0'
)
self
.
assertEqual
s
(
str
(
version
),
'1.2'
)
self
.
assertEqual
(
str
(
version
),
'1.2'
)
def
test_cmp_strict
(
self
):
def
test_cmp_strict
(
self
):
versions
=
((
'1.5.1'
,
'1.5.2b2'
,
-
1
),
versions
=
((
'1.5.1'
,
'1.5.2b2'
,
-
1
),
...
@@ -42,9 +42,9 @@ class VersionTestCase(unittest.TestCase):
...
@@ -42,9 +42,9 @@ class VersionTestCase(unittest.TestCase):
raise
AssertionError
((
"cmp(%s, %s) "
raise
AssertionError
((
"cmp(%s, %s) "
"shouldn't raise ValueError"
)
"shouldn't raise ValueError"
)
%
(
v1
,
v2
))
%
(
v1
,
v2
))
self
.
assertEqual
s
(
res
,
wanted
,
self
.
assertEqual
(
res
,
wanted
,
'cmp(%s, %s) should be %s, got %s'
%
'cmp(%s, %s) should be %s, got %s'
%
(
v1
,
v2
,
wanted
,
res
))
(
v1
,
v2
,
wanted
,
res
))
def
test_cmp
(
self
):
def
test_cmp
(
self
):
...
@@ -60,9 +60,9 @@ class VersionTestCase(unittest.TestCase):
...
@@ -60,9 +60,9 @@ class VersionTestCase(unittest.TestCase):
for
v1
,
v2
,
wanted
in
versions
:
for
v1
,
v2
,
wanted
in
versions
:
res
=
LooseVersion
(
v1
).
_cmp
(
LooseVersion
(
v2
))
res
=
LooseVersion
(
v1
).
_cmp
(
LooseVersion
(
v2
))
self
.
assertEqual
s
(
res
,
wanted
,
self
.
assertEqual
(
res
,
wanted
,
'cmp(%s, %s) should be %s, got %s'
%
'cmp(%s, %s) should be %s, got %s'
%
(
v1
,
v2
,
wanted
,
res
))
(
v1
,
v2
,
wanted
,
res
))
def
test_suite
():
def
test_suite
():
return
unittest
.
makeSuite
(
VersionTestCase
)
return
unittest
.
makeSuite
(
VersionTestCase
)
...
...
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