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
e87b7eaf
Kaydet (Commit)
e87b7eaf
authored
Eyl 30, 2014
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
fix windows tests (#16662)
From Robert Collins.
üst
cdfb7691
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
14 deletions
+15
-14
test_discovery.py
Lib/unittest/test/test_discovery.py
+15
-14
No files found.
Lib/unittest/test/test_discovery.py
Dosyayı görüntüle @
e87b7eaf
import
os
import
os.path
from
os.path
import
abspath
import
re
import
sys
import
types
...
...
@@ -250,7 +251,7 @@ class TestDiscovery(unittest.TestCase):
def
restore_isdir
():
os
.
path
.
isdir
=
original_isdir
self
.
addCleanup
(
restore_isdir
)
self
.
addCleanup
(
sys
.
path
.
remove
,
'/foo'
)
self
.
addCleanup
(
sys
.
path
.
remove
,
abspath
(
'/foo'
)
)
# Test data: we expect the following:
# a listdir to find our package, and a isfile and isdir check on it.
...
...
@@ -263,8 +264,8 @@ class TestDiscovery(unittest.TestCase):
# the module load tests for both package and plain module called,
# and the plain module result nested by the package module load_tests
# indicating that it was processed and could have been mutated.
vfs
=
{
'/foo'
:
[
'my_package'
],
'/foo/my_package'
:
[
'__init__.py'
,
'test_module.py'
]}
vfs
=
{
abspath
(
'/foo'
)
:
[
'my_package'
],
abspath
(
'/foo/my_package'
)
:
[
'__init__.py'
,
'test_module.py'
]}
def
list_dir
(
path
):
return
list
(
vfs
[
path
])
os
.
listdir
=
list_dir
...
...
@@ -301,10 +302,10 @@ class TestDiscovery(unittest.TestCase):
loader
.
_get_module_from_name
=
lambda
name
:
Module
(
name
)
loader
.
suiteClass
=
lambda
thing
:
thing
loader
.
_top_level_dir
=
'/foo'
loader
.
_top_level_dir
=
abspath
(
'/foo'
)
# this time no '.py' on the pattern so that it can match
# a test package
suite
=
list
(
loader
.
_find_tests
(
'/foo'
,
'test*.py'
))
suite
=
list
(
loader
.
_find_tests
(
abspath
(
'/foo'
)
,
'test*.py'
))
# We should have loaded tests from both my_package and
# my_pacakge.test_module, and also run the load_tests hook in both.
...
...
@@ -404,8 +405,8 @@ class TestDiscovery(unittest.TestCase):
test
.
test_this_does_not_exist
()
def
test_discover_with_init_modules_that_fail_to_import
(
self
):
vfs
=
{
'/foo'
:
[
'my_package'
],
'/foo/my_package'
:
[
'__init__.py'
,
'test_module.py'
]}
vfs
=
{
abspath
(
'/foo'
)
:
[
'my_package'
],
abspath
(
'/foo/my_package'
)
:
[
'__init__.py'
,
'test_module.py'
]}
self
.
setup_import_issue_package_tests
(
vfs
)
import_calls
=
[]
def
_get_module_from_name
(
name
):
...
...
@@ -413,9 +414,9 @@ class TestDiscovery(unittest.TestCase):
raise
ImportError
(
"Cannot import Name"
)
loader
=
unittest
.
TestLoader
()
loader
.
_get_module_from_name
=
_get_module_from_name
suite
=
loader
.
discover
(
'/foo'
)
suite
=
loader
.
discover
(
abspath
(
'/foo'
)
)
self
.
assertIn
(
'/foo'
,
sys
.
path
)
self
.
assertIn
(
abspath
(
'/foo'
)
,
sys
.
path
)
self
.
assertEqual
(
suite
.
countTestCases
(),
1
)
test
=
list
(
list
(
suite
)[
0
])[
0
]
# extract test from suite
with
self
.
assertRaises
(
ImportError
):
...
...
@@ -439,8 +440,8 @@ class TestDiscovery(unittest.TestCase):
self
.
assertEqual
(
len
(
result
.
skipped
),
1
)
def
test_discover_with_init_module_that_raises_SkipTest_on_import
(
self
):
vfs
=
{
'/foo'
:
[
'my_package'
],
'/foo/my_package'
:
[
'__init__.py'
,
'test_module.py'
]}
vfs
=
{
abspath
(
'/foo'
)
:
[
'my_package'
],
abspath
(
'/foo/my_package'
)
:
[
'__init__.py'
,
'test_module.py'
]}
self
.
setup_import_issue_package_tests
(
vfs
)
import_calls
=
[]
def
_get_module_from_name
(
name
):
...
...
@@ -448,9 +449,9 @@ class TestDiscovery(unittest.TestCase):
raise
unittest
.
SkipTest
(
'skipperoo'
)
loader
=
unittest
.
TestLoader
()
loader
.
_get_module_from_name
=
_get_module_from_name
suite
=
loader
.
discover
(
'/foo'
)
suite
=
loader
.
discover
(
abspath
(
'/foo'
)
)
self
.
assertIn
(
'/foo'
,
sys
.
path
)
self
.
assertIn
(
abspath
(
'/foo'
)
,
sys
.
path
)
self
.
assertEqual
(
suite
.
countTestCases
(),
1
)
result
=
unittest
.
TestResult
()
suite
.
run
(
result
)
...
...
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