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
d3973b57
Kaydet (Commit)
d3973b57
authored
Eki 22, 2006
tarafından
Walter Dörwald
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Port test___future__ to unittest.
üst
8a7a9cf5
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
37 deletions
+41
-37
test___future__.py
Lib/test/test___future__.py
+41
-37
No files found.
Lib/test/test___future__.py
Dosyayı görüntüle @
d3973b57
#! /usr/bin/env python
#! /usr/bin/env python
from
test.test_support
import
verbose
,
verify
import
unittest
from
t
ypes
import
TupleType
,
StringType
,
IntType
from
t
est
import
test_support
import
__future__
import
__future__
GOOD_SERIALS
=
(
"alpha"
,
"beta"
,
"candidate"
,
"final"
)
GOOD_SERIALS
=
(
"alpha"
,
"beta"
,
"candidate"
,
"final"
)
features
=
__future__
.
all_feature_names
features
=
__future__
.
all_feature_names
# Verify that all_feature_names appears correct.
class
FutureTest
(
unittest
.
TestCase
):
given_feature_names
=
features
[:]
for
name
in
dir
(
__future__
):
def
test_names
(
self
):
# Verify that all_feature_names appears correct.
given_feature_names
=
features
[:]
for
name
in
dir
(
__future__
):
obj
=
getattr
(
__future__
,
name
,
None
)
obj
=
getattr
(
__future__
,
name
,
None
)
if
obj
is
not
None
and
isinstance
(
obj
,
__future__
.
_Feature
):
if
obj
is
not
None
and
isinstance
(
obj
,
__future__
.
_Feature
):
verify
(
name
in
given_feature_names
,
self
.
assert_
(
"
%
r should have been in all_feature_names"
%
name
)
name
in
given_feature_names
,
"
%
r should have been in all_feature_names"
%
name
)
given_feature_names
.
remove
(
name
)
given_feature_names
.
remove
(
name
)
verify
(
len
(
given_feature_names
)
==
0
,
self
.
assertEqual
(
len
(
given_feature_names
),
0
,
"all_feature_names has too much:
%
r"
%
given_feature_names
)
"all_feature_names has too much:
%
r"
%
given_feature_names
)
del
given_feature_names
for
feature
in
features
:
def
test_attributes
(
self
):
for
feature
in
features
:
value
=
getattr
(
__future__
,
feature
)
value
=
getattr
(
__future__
,
feature
)
if
verbose
:
print
"Checking __future__ "
,
feature
,
"value"
,
value
optional
=
value
.
getOptionalRelease
()
optional
=
value
.
getOptionalRelease
()
mandatory
=
value
.
getMandatoryRelease
()
mandatory
=
value
.
getMandatoryRelease
()
verify
(
type
(
optional
)
is
TupleType
,
"optional isn't tuple"
)
a
=
self
.
assert_
verify
(
len
(
optional
)
==
5
,
"optional isn't 5-tuple"
)
e
=
self
.
assertEqual
major
,
minor
,
micro
,
level
,
serial
=
optional
def
check
(
t
,
name
):
verify
(
type
(
major
)
is
IntType
,
"optional major isn't int"
)
a
(
isinstance
(
t
,
tuple
),
"
%
s isn't tuple"
%
name
)
verify
(
type
(
minor
)
is
IntType
,
"optional minor isn't int"
)
e
(
len
(
t
),
5
,
"
%
s isn't 5-tuple"
%
name
)
verify
(
type
(
micro
)
is
IntType
,
"optional micro isn't int"
)
(
major
,
minor
,
micro
,
level
,
serial
)
=
t
verify
(
isinstance
(
level
,
basestring
),
"optional level isn't string"
)
a
(
isinstance
(
major
,
int
),
"
%
s major isn't int"
%
name
)
verify
(
level
in
GOOD_SERIALS
,
a
(
isinstance
(
minor
,
int
),
"
%
s minor isn't int"
%
name
)
"optional level string has unknown value"
)
a
(
isinstance
(
micro
,
int
),
"
%
s micro isn't int"
%
name
)
verify
(
type
(
serial
)
is
IntType
,
"optional serial isn't int"
)
a
(
isinstance
(
level
,
basestring
),
"
%
s level isn't string"
%
name
)
verify
(
type
(
mandatory
)
is
TupleType
or
a
(
level
in
GOOD_SERIALS
,
mandatory
is
None
,
"mandatory isn't tuple or None"
)
"
%
s level string has unknown value"
%
name
)
a
(
isinstance
(
serial
,
int
),
"
%
s serial isn't int"
%
name
)
check
(
optional
,
"optional"
)
if
mandatory
is
not
None
:
if
mandatory
is
not
None
:
verify
(
len
(
mandatory
)
==
5
,
"mandatory isn't 5-tuple"
)
check
(
mandatory
,
"mandatory"
)
major
,
minor
,
micro
,
level
,
serial
=
mandatory
a
(
optional
<
mandatory
,
verify
(
type
(
major
)
is
IntType
,
"mandatory major isn't int"
)
verify
(
type
(
minor
)
is
IntType
,
"mandatory minor isn't int"
)
verify
(
type
(
micro
)
is
IntType
,
"mandatory micro isn't int"
)
verify
(
isinstance
(
level
,
basestring
),
"mandatory level isn't string"
)
verify
(
level
in
GOOD_SERIALS
,
"mandatory serial string has unknown value"
)
verify
(
type
(
serial
)
is
IntType
,
"mandatory serial isn't int"
)
verify
(
optional
<
mandatory
,
"optional not less than mandatory, and mandatory not None"
)
"optional not less than mandatory, and mandatory not None"
)
verify
(
hasattr
(
value
,
"compiler_flag"
),
a
(
hasattr
(
value
,
"compiler_flag"
),
"feature is missing a .compiler_flag attr"
)
"feature is missing a .compiler_flag attr"
)
verify
(
type
(
getattr
(
value
,
"compiler_flag"
))
is
IntType
,
a
(
isinstance
(
getattr
(
value
,
"compiler_flag"
),
int
)
,
".compiler_flag isn't int"
)
".compiler_flag isn't int"
)
def
test_main
():
test_support
.
run_unittest
(
FutureTest
)
if
__name__
==
"__main__"
:
test_main
()
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