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
6672ea94
Kaydet (Commit)
6672ea94
authored
Kas 08, 2010
tarafından
Alexander Belopolsky
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Streamlined code in trace.Ignore and added unit tests.
üst
551f02ca
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
16 deletions
+27
-16
test_trace.py
Lib/test/test_trace.py
+14
-0
trace.py
Lib/trace.py
+13
-16
No files found.
Lib/test/test_trace.py
Dosyayı görüntüle @
6672ea94
...
@@ -334,6 +334,20 @@ class TestCoverage(unittest.TestCase):
...
@@ -334,6 +334,20 @@ class TestCoverage(unittest.TestCase):
self
.
assertIn
(
modname
,
coverage
)
self
.
assertIn
(
modname
,
coverage
)
self
.
assertEqual
(
coverage
[
modname
],
(
5
,
100
))
self
.
assertEqual
(
coverage
[
modname
],
(
5
,
100
))
### Tests that don't mess with sys.settrace and can be traced
### themselves TODO: Skip tests that do mess with sys.settrace when
### regrtest is invoked with -T option.
class
Test_Ignore
(
unittest
.
TestCase
):
def
test_ignored
(
self
):
ignore
=
trace
.
Ignore
([
'x'
,
'y.z'
],
[
'/foo/bar'
])
self
.
assertTrue
(
ignore
.
names
(
'x.py'
,
'x'
))
self
.
assertFalse
(
ignore
.
names
(
'xy.py'
,
'xy'
))
self
.
assertFalse
(
ignore
.
names
(
'y.py'
,
'y'
))
self
.
assertTrue
(
ignore
.
names
(
'/foo/bar/baz.py'
,
'baz'
))
self
.
assertFalse
(
ignore
.
names
(
'bar/z.py'
,
'z'
))
# Matched before.
self
.
assertTrue
(
ignore
.
names
(
'bar/baz.py'
,
'baz'
))
def
test_main
():
def
test_main
():
run_unittest
(
__name__
)
run_unittest
(
__name__
)
...
...
Lib/trace.py
Dosyayı görüntüle @
6672ea94
...
@@ -128,11 +128,10 @@ PRAGMA_NOCOVER = "#pragma NO COVER"
...
@@ -128,11 +128,10 @@ PRAGMA_NOCOVER = "#pragma NO COVER"
rx_blank
=
re
.
compile
(
r'^\s*(#.*)?$'
)
rx_blank
=
re
.
compile
(
r'^\s*(#.*)?$'
)
class
Ignore
:
class
Ignore
:
def
__init__
(
self
,
modules
=
None
,
dirs
=
None
):
def
__init__
(
self
,
modules
=
None
,
dirs
=
None
):
self
.
_mods
=
modules
or
[]
self
.
_mods
=
set
()
if
not
modules
else
set
(
modules
)
self
.
_dirs
=
dirs
or
[]
self
.
_dirs
=
[]
if
not
dirs
else
[
os
.
path
.
normpath
(
d
)
for
d
in
dirs
]
self
.
_dirs
=
list
(
map
(
os
.
path
.
normpath
,
self
.
_dirs
))
self
.
_ignore
=
{
'<string>'
:
1
}
self
.
_ignore
=
{
'<string>'
:
1
}
def
names
(
self
,
filename
,
modulename
):
def
names
(
self
,
filename
,
modulename
):
...
@@ -140,24 +139,22 @@ class Ignore:
...
@@ -140,24 +139,22 @@ class Ignore:
return
self
.
_ignore
[
modulename
]
return
self
.
_ignore
[
modulename
]
# haven't seen this one before, so see if the module name is
# haven't seen this one before, so see if the module name is
# on the ignore list. Need to take some care since ignoring
# on the ignore list.
# "cmp" musn't mean ignoring "cmpcache" but ignoring
if
modulename
in
self
.
_mods
:
# Identical names, so ignore
# "Spam" must also mean ignoring "Spam.Eggs".
for
mod
in
self
.
_mods
:
if
mod
==
modulename
:
# Identical names, so ignore
self
.
_ignore
[
modulename
]
=
1
self
.
_ignore
[
modulename
]
=
1
return
1
return
1
# check if the module is a proper submodule of something on
# check if the module is a proper submodule of something on
# the ignore list
# the ignore list
n
=
len
(
mod
)
for
mod
in
self
.
_mods
:
#
(will not overflow since if the first n characters are the
#
Need to take some care since ignoring
#
same and the name has not already occurred, then the size
#
"cmp" mustn't mean ignoring "cmpcache" but ignoring
#
of "name" is greater than that of "mod")
#
"Spam" must also mean ignoring "Spam.Eggs".
if
mod
==
modulename
[:
n
]
and
modulename
[
n
]
==
'.'
:
if
mod
ulename
.
startswith
(
mod
+
'.'
)
:
self
.
_ignore
[
modulename
]
=
1
self
.
_ignore
[
modulename
]
=
1
return
1
return
1
# Now check that
__file__
isn't in one of the directories
# Now check that
filename
isn't in one of the directories
if
filename
is
None
:
if
filename
is
None
:
# must be a built-in, so we must ignore
# must be a built-in, so we must ignore
self
.
_ignore
[
modulename
]
=
1
self
.
_ignore
[
modulename
]
=
1
...
...
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