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
096c6aae
Kaydet (Commit)
096c6aae
authored
Haz 22, 2016
tarafından
Terry Jan Reedy
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Issue #27365: partial merge
üst
317c56de
06a1fcbb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
8 deletions
+64
-8
test_help_about.py
Lib/idlelib/idle_test/test_help_about.py
+52
-0
test_textview.py
Lib/idlelib/idle_test/test_textview.py
+8
-8
textView.py
Lib/idlelib/textView.py
+4
-0
No files found.
Lib/idlelib/idle_test/test_help_about.py
0 → 100644
Dosyayı görüntüle @
096c6aae
'''Test idlelib.help_about.
Coverage:
'''
from
idlelib
import
aboutDialog
as
help_about
from
idlelib
import
textView
as
textview
from
idlelib.idle_test.mock_idle
import
Func
from
idlelib.idle_test.mock_tk
import
Mbox
import
unittest
About
=
help_about
.
AboutDialog
class
Dummy_about_dialog
():
# Dummy class for testing file display functions.
idle_credits
=
About
.
ShowIDLECredits
idle_readme
=
About
.
ShowIDLEAbout
idle_news
=
About
.
ShowIDLENEWS
# Called by the above
display_file_text
=
About
.
display_file_text
class
DisplayFileTest
(
unittest
.
TestCase
):
"Test that .txt files are found and properly decoded."
dialog
=
Dummy_about_dialog
()
@classmethod
def
setUpClass
(
cls
):
cls
.
orig_mbox
=
textview
.
tkMessageBox
cls
.
orig_view
=
textview
.
view_text
cls
.
mbox
=
Mbox
()
cls
.
view
=
Func
()
textview
.
tkMessageBox
=
cls
.
mbox
textview
.
view_text
=
cls
.
view
cls
.
About
=
Dummy_about_dialog
()
@classmethod
def
tearDownClass
(
cls
):
textview
.
tkMessageBox
=
cls
.
orig_mbox
textview
.
view_text
=
cls
.
orig_view
def
test_file_isplay
(
self
):
for
handler
in
(
self
.
dialog
.
idle_credits
,
self
.
dialog
.
idle_readme
,
self
.
dialog
.
idle_news
):
self
.
mbox
.
showerror
.
message
=
''
self
.
view
.
called
=
False
handler
()
self
.
assertEqual
(
self
.
mbox
.
showerror
.
message
,
''
)
self
.
assertEqual
(
self
.
view
.
called
,
True
)
if
__name__
==
'__main__'
:
unittest
.
main
(
verbosity
=
2
)
Lib/idlelib/idle_test/test_textview.py
Dosyayı görüntüle @
096c6aae
...
...
@@ -5,7 +5,7 @@ is a widget containing multiple widgets, all tests must be gui tests.
Using mock Text would not change this. Other mocks are used to retrieve
information about calls.
The coverage is essentially 100
%
.
Coverage: 94
%
.
'''
from
idlelib
import
textview
as
tv
from
test.support
import
requires
...
...
@@ -15,7 +15,7 @@ import unittest
import
os
from
tkinter
import
Tk
from
idlelib.idle_test.mock_idle
import
Func
from
idlelib.idle_test.mock_tk
import
Mbox
from
idlelib.idle_test.mock_tk
import
Mbox
_func
def
setUpModule
():
global
root
...
...
@@ -64,17 +64,17 @@ class TextViewTest(unittest.TestCase):
view
.
destroy
class
textview
Test
(
unittest
.
TestCase
):
class
ViewFunction
Test
(
unittest
.
TestCase
):
@classmethod
def
setUpClass
(
cls
):
cls
.
orig_
mbox
=
tv
.
tkMessageBox
tv
.
tkMessageBox
=
Mbox
cls
.
orig_
error
=
tv
.
showerror
tv
.
showerror
=
Mbox_func
()
@classmethod
def
tearDownClass
(
cls
):
tv
.
tkMessageBox
=
cls
.
orig_mbox
del
cls
.
orig_
mbox
tv
.
showerror
=
cls
.
orig_error
del
cls
.
orig_
error
def
test_view_text
(
self
):
# If modal True, tkinter will error with 'can't invoke "event" command'
...
...
@@ -89,7 +89,7 @@ class textviewTest(unittest.TestCase):
self
.
assertIn
(
'Test'
,
view
.
textView
.
get
(
'1.0'
,
'1.end'
))
view
.
Ok
()
# Mock
messagebox will be used and view_file will not return anything
# Mock
showerror will be used and view_file will return None
testfile
=
os
.
path
.
join
(
test_dir
,
'../notthere.py'
)
view
=
tv
.
view_file
(
root
,
'Title'
,
testfile
,
modal
=
False
)
self
.
assertIsNone
(
view
)
...
...
Lib/idlelib/textView.py
Dosyayı görüntüle @
096c6aae
...
...
@@ -77,6 +77,10 @@ def view_file(parent, title, filename, encoding=None, modal=True):
tkMessageBox
.
showerror
(
title
=
'File Load Error'
,
message
=
'Unable to load file
%
r .'
%
filename
,
parent
=
parent
)
except
UnicodeDecodeError
as
err
:
tkMessageBox
.
showerror
(
title
=
'Unicode Decode Error'
,
message
=
str
(
err
),
parent
=
parent
)
else
:
return
view_text
(
parent
,
title
,
contents
,
modal
)
...
...
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