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
7bfe8994
Kaydet (Commit)
7bfe8994
authored
Ara 18, 2011
tarafından
Antoine Pitrou
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Followup to #7502: add __hash__ method and tests.
üst
83250bb0
165b1283
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
0 deletions
+29
-0
doctest.py
Lib/doctest.py
+10
-0
test_doctest.py
Lib/test/test_doctest.py
+19
-0
No files found.
Lib/doctest.py
Dosyayı görüntüle @
7bfe8994
...
...
@@ -454,6 +454,9 @@ class Example:
def
__ne__
(
self
,
other
):
return
not
self
==
other
def
__hash__
(
self
):
return
hash
((
self
.
source
,
self
.
want
,
self
.
lineno
,
self
.
indent
,
self
.
exc_msg
))
class
DocTest
:
"""
...
...
@@ -517,6 +520,9 @@ class DocTest:
def
__ne__
(
self
,
other
):
return
not
self
==
other
def
__hash__
(
self
):
return
hash
((
self
.
docstring
,
self
.
name
,
self
.
filename
,
self
.
lineno
))
# This lets us sort tests by name:
def
__lt__
(
self
,
other
):
if
not
isinstance
(
other
,
DocTest
):
...
...
@@ -2247,6 +2253,10 @@ class DocTestCase(unittest.TestCase):
def
__ne__
(
self
,
other
):
return
not
self
==
other
def
__hash__
(
self
):
return
hash
((
self
.
_dt_optionflags
,
self
.
_dt_setUp
,
self
.
_dt_tearDown
,
self
.
_dt_checker
))
def
__repr__
(
self
):
name
=
self
.
_dt_test
.
name
.
split
(
'.'
)
return
"
%
s (
%
s)"
%
(
name
[
-
1
],
'.'
.
join
(
name
[:
-
1
]))
...
...
Lib/test/test_doctest.py
Dosyayı görüntüle @
7bfe8994
...
...
@@ -259,6 +259,21 @@ unless it's `None`:
>>> e = doctest.Example('raise X()', '', exc_msg)
>>> e.exc_msg
'\n'
Compare `Example`:
>>> example = doctest.Example('print 1', '1\n')
>>> same_example = doctest.Example('print 1', '1\n')
>>> other_example = doctest.Example('print 42', '42\n')
>>> example == same_example
True
>>> example != same_example
False
>>> hash(example) == hash(same_example)
True
>>> example == other_example
False
>>> example != other_example
True
"""
def
test_DocTest
():
r"""
...
...
@@ -362,6 +377,8 @@ Compare `DocTest`:
True
>>> test != same_test
False
>>> hash(test) == hash(same_test)
True
>>> docstring = '''
... >>> print 42
... 42
...
...
@@ -383,6 +400,8 @@ Compare `DocTestCase`:
True
>>> test_case != same_test_case
False
>>> hash(test_case) == hash(same_test_case)
True
>>> test == other_test_case
False
>>> test != other_test_case
...
...
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