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
373d90b3
Kaydet (Commit)
373d90b3
authored
Eki 03, 2006
tarafından
Brett Cannon
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Convert test_imp over to unittest.
üst
5a9aa4f3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
29 deletions
+35
-29
test_imp.py
Lib/test/test_imp.py
+33
-29
NEWS
Misc/NEWS
+2
-0
No files found.
Lib/test/test_imp.py
Dosyayı görüntüle @
373d90b3
import
imp
from
test.test_support
import
TestFailed
,
TestSkipped
try
:
import
thread
except
ImportError
:
raise
TestSkipped
(
"test only valid when thread support is available"
)
import
thread
import
unittest
from
test
import
test_support
def
verify_lock_state
(
expected
):
if
imp
.
lock_held
()
!=
expected
:
raise
TestFailed
(
"expected imp.lock_held() to be
%
r"
%
expected
)
def
testLock
():
LOOPS
=
50
class
LockTests
(
unittest
.
TestCase
):
# The import lock may already be held, e.g. if the test suite is run
# via "import test.autotest".
lock_held_at_start
=
imp
.
lock_held
()
verify_lock_state
(
lock_held_at_start
)
"""Very basic test of import lock functions."""
for
i
in
range
(
LOOPS
):
imp
.
acquire_lock
()
verify_lock_state
(
True
)
def
verify_lock_state
(
self
,
expected
):
self
.
failUnlessEqual
(
imp
.
lock_held
(),
expected
,
"expected imp.lock_held() to be
%
r"
%
expected
)
def
testLock
(
self
):
LOOPS
=
50
for
i
in
range
(
LOOPS
):
imp
.
release_lock
()
# The import lock may already be held, e.g. if the test suite is run
# via "import test.autotest".
lock_held_at_start
=
imp
.
lock_held
()
self
.
verify_lock_state
(
lock_held_at_start
)
# The original state should be restored now.
verify_lock_state
(
lock_held_at_start
)
for
i
in
range
(
LOOPS
):
imp
.
acquire_lock
()
self
.
verify_lock_state
(
True
)
if
not
lock_held_at_start
:
try
:
for
i
in
range
(
LOOPS
):
imp
.
release_lock
()
except
RuntimeError
:
pass
else
:
raise
TestFailed
(
"release_lock() without lock should raise "
"RuntimeError"
)
# The original state should be restored now.
self
.
verify_lock_state
(
lock_held_at_start
)
if
not
lock_held_at_start
:
try
:
imp
.
release_lock
()
except
RuntimeError
:
pass
else
:
self
.
fail
(
"release_lock() without lock should raise "
"RuntimeError"
)
def
test_main
():
testLock
()
test_support
.
run_unittest
(
LockTests
,
)
if
__name__
==
"__main__"
:
test_main
()
Misc/NEWS
Dosyayı görüntüle @
373d90b3
...
...
@@ -139,6 +139,8 @@ Extension Modules
Tests
-----
- Converted test_imp to use unittest.
- Fix bsddb test_basics.test06_Transactions to check the version
number properly.
...
...
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