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
cbb16459
Kaydet (Commit)
cbb16459
authored
Ock 09, 2019
tarafından
Sanyam Khurana
Kaydeden (comit)
Senthil Kumaran
Ock 09, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-24746: Avoid stripping trailing whitespace in doctest fancy diff (#10639)
üst
a234e148
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
3 deletions
+49
-3
doctest.py
Lib/doctest.py
+0
-2
test_doctest.py
Lib/test/test_doctest.py
+47
-1
2018-11-22-15-22-56.bpo-24746.eSLKBE.rst
...S.d/next/Library/2018-11-22-15-22-56.bpo-24746.eSLKBE.rst
+2
-0
No files found.
Lib/doctest.py
Dosyayı görüntüle @
cbb16459
...
...
@@ -1690,8 +1690,6 @@ class OutputChecker:
kind
=
'ndiff with -expected +actual'
else
:
assert
0
,
'Bad diff option'
# Remove trailing whitespace on diff output.
diff
=
[
line
.
rstrip
()
+
'
\n
'
for
line
in
diff
]
return
'Differences (
%
s):
\n
'
%
kind
+
_indent
(
''
.
join
(
diff
))
# If we're not using diff, then simply list the expected
...
...
Lib/test/test_doctest.py
Dosyayı görüntüle @
cbb16459
...
...
@@ -2451,6 +2451,11 @@ def test_unittest_reportflags():
Then the default eporting options are ignored:
>>> result = suite.run(unittest.TestResult())
"""
"""
*NOTE*: These doctest are intentionally not placed in raw string to depict
the trailing whitespace using `
\x20
` in the diff below.
>>> print(result.failures[0][1]) # doctest: +ELLIPSIS
Traceback ...
Failed example:
...
...
@@ -2464,7 +2469,7 @@ def test_unittest_reportflags():
Differences (ndiff with -expected +actual):
a
- <BLANKLINE>
+
+
\x20
b
<BLANKLINE>
<BLANKLINE>
...
...
@@ -2953,6 +2958,47 @@ Invalid doctest option:
"""
def
test_no_trailing_whitespace_stripping
():
r"""
The fancy reports had a bug for a long time where any trailing whitespace on
the reported diff lines was stripped, making it impossible to see the
differences in line reported as different that differed only in the amount of
trailing whitespace. The whitespace still isn't particularly visible unless
you use NDIFF, but at least it is now there to be found.
*NOTE*: This snippet was intentionally put inside a raw string to get rid of
leading whitespace error in executing the example below
>>> def f(x):
... r'''
... >>> print('\n'.join(['a ', 'b']))
... a
... b
... '''
"""
"""
*NOTE*: These doctest are not placed in raw string to depict the trailing whitespace
using `
\x20
`
>>> test = doctest.DocTestFinder().find(f)[0]
>>> flags = doctest.REPORT_NDIFF
>>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test)
... # doctest: +ELLIPSIS
**********************************************************************
File ..., line 3, in f
Failed example:
print('
\n
'.join(['a ', 'b']))
Differences (ndiff with -expected +actual):
- a
+ a
b
TestResults(failed=1, attempted=1)
*NOTE*: `
\x20
` is for checking the trailing whitespace on the +a line above.
We cannot use actual spaces there, as a commit hook prevents from committing
patches that contain trailing whitespace. More info on Issue 24746.
"""
######################################################################
## Main
######################################################################
...
...
Misc/NEWS.d/next/Library/2018-11-22-15-22-56.bpo-24746.eSLKBE.rst
0 → 100644
Dosyayı görüntüle @
cbb16459
Avoid stripping trailing whitespace in doctest fancy diff. Orignial patch by
R. David Murray & Jairo Trad. Enhanced by Sanyam Khurana.
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