Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
fe327b97
Kaydet (Commit)
fe327b97
authored
Haz 03, 2009
tarafından
Tarek Ziadé
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
more cleanup and test coverage for distutils.extension
üst
c6709978
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
21 deletions
+45
-21
extension.py
Lib/distutils/extension.py
+11
-20
test_extension.py
Lib/distutils/tests/test_extension.py
+34
-1
No files found.
Lib/distutils/extension.py
Dosyayı görüntüle @
fe327b97
...
@@ -5,13 +5,9 @@ modules in setup scripts."""
...
@@ -5,13 +5,9 @@ modules in setup scripts."""
__revision__
=
"$Id$"
__revision__
=
"$Id$"
import
os
,
string
,
sys
import
os
from
types
import
*
import
sys
import
warnings
try
:
import
warnings
except
ImportError
:
warnings
=
None
# This class is really only used by the "build_ext" command, so it might
# This class is really only used by the "build_ext" command, so it might
# make sense to put it in distutils.command.build_ext. However, that
# make sense to put it in distutils.command.build_ext. However, that
...
@@ -107,9 +103,9 @@ class Extension:
...
@@ -107,9 +103,9 @@ class Extension:
optional
=
None
,
optional
=
None
,
**
kw
# To catch unknown keywords
**
kw
# To catch unknown keywords
):
):
assert
type
(
name
)
is
StringType
,
"'name' must be a string"
assert
isinstance
(
name
,
str
)
assert
(
type
(
sources
)
is
ListType
and
assert
(
isinstance
(
sources
,
list
)
and
map
(
type
,
sources
)
==
[
StringType
]
*
len
(
sources
)),
\
all
(
isinstance
(
v
,
str
)
for
v
in
sources
)),
\
"'sources' must be a list of strings"
"'sources' must be a list of strings"
self
.
name
=
name
self
.
name
=
name
...
@@ -130,16 +126,11 @@ class Extension:
...
@@ -130,16 +126,11 @@ class Extension:
self
.
optional
=
optional
self
.
optional
=
optional
# If there are unknown keyword options, warn about them
# If there are unknown keyword options, warn about them
if
len
(
kw
):
if
len
(
kw
)
>
0
:
L
=
kw
.
keys
()
;
L
.
sort
()
options
=
[
repr
(
option
)
for
option
in
kw
]
L
=
map
(
repr
,
L
)
options
=
', '
.
join
(
sorted
(
options
))
msg
=
"Unknown Extension options: "
+
string
.
join
(
L
,
', '
)
msg
=
"Unknown Extension options:
%
s"
%
options
if
warnings
is
not
None
:
warnings
.
warn
(
msg
)
warnings
.
warn
(
msg
)
else
:
sys
.
stderr
.
write
(
msg
+
'
\n
'
)
# class Extension
def
read_setup_file
(
filename
):
def
read_setup_file
(
filename
):
"""Reads a Setup file and returns Extension instances."""
"""Reads a Setup file and returns Extension instances."""
...
@@ -200,7 +191,7 @@ def read_setup_file(filename):
...
@@ -200,7 +191,7 @@ def read_setup_file(filename):
elif
switch
==
"-I"
:
elif
switch
==
"-I"
:
ext
.
include_dirs
.
append
(
value
)
ext
.
include_dirs
.
append
(
value
)
elif
switch
==
"-D"
:
elif
switch
==
"-D"
:
equals
=
string
.
find
(
value
,
"="
)
equals
=
value
.
find
(
"="
)
if
equals
==
-
1
:
# bare "-DFOO" -- no value
if
equals
==
-
1
:
# bare "-DFOO" -- no value
ext
.
define_macros
.
append
((
value
,
None
))
ext
.
define_macros
.
append
((
value
,
None
))
else
:
# "-DFOO=blah"
else
:
# "-DFOO=blah"
...
...
Lib/distutils/tests/test_extension.py
Dosyayı görüntüle @
fe327b97
"""Tests for distutils.extension."""
"""Tests for distutils.extension."""
import
unittest
import
unittest
import
os
import
os
import
warnings
from
distutils.extension
import
read_setup_file
from
test.test_support
import
check_warnings
from
distutils.extension
import
read_setup_file
,
Extension
class
ExtensionTestCase
(
unittest
.
TestCase
):
class
ExtensionTestCase
(
unittest
.
TestCase
):
...
@@ -28,6 +30,37 @@ class ExtensionTestCase(unittest.TestCase):
...
@@ -28,6 +30,37 @@ class ExtensionTestCase(unittest.TestCase):
self
.
assertEquals
(
names
,
wanted
)
self
.
assertEquals
(
names
,
wanted
)
def
test_extension_init
(
self
):
# the first argument, which is the name, must be a string
self
.
assertRaises
(
AssertionError
,
Extension
,
1
,
[])
ext
=
Extension
(
'name'
,
[])
self
.
assertEquals
(
ext
.
name
,
'name'
)
# the second argument, which is the list of files, must
# be a list of strings
self
.
assertRaises
(
AssertionError
,
Extension
,
'name'
,
'file'
)
self
.
assertRaises
(
AssertionError
,
Extension
,
'name'
,
[
'file'
,
1
])
ext
=
Extension
(
'name'
,
[
'file1'
,
'file2'
])
self
.
assertEquals
(
ext
.
sources
,
[
'file1'
,
'file2'
])
# others arguments have defaults
for
attr
in
(
'include_dirs'
,
'define_macros'
,
'undef_macros'
,
'library_dirs'
,
'libraries'
,
'runtime_library_dirs'
,
'extra_objects'
,
'extra_compile_args'
,
'extra_link_args'
,
'export_symbols'
,
'swig_opts'
,
'depends'
):
self
.
assertEquals
(
getattr
(
ext
,
attr
),
[])
self
.
assertEquals
(
ext
.
language
,
None
)
self
.
assertEquals
(
ext
.
optional
,
None
)
# if there are unknown keyword options, warn about them
with
check_warnings
()
as
w
:
warnings
.
simplefilter
(
'always'
)
ext
=
Extension
(
'name'
,
[
'file1'
,
'file2'
],
chic
=
True
)
self
.
assertEquals
(
len
(
w
.
warnings
),
1
)
self
.
assertEquals
(
str
(
w
.
warnings
[
0
]
.
message
),
"Unknown Extension options: 'chic'"
)
def
test_suite
():
def
test_suite
():
return
unittest
.
makeSuite
(
ExtensionTestCase
)
return
unittest
.
makeSuite
(
ExtensionTestCase
)
...
...
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