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
295304d4
Kaydet (Commit)
295304d4
authored
May 18, 2017
tarafından
terryjreedy
Kaydeden (comit)
GitHub
May 18, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
IDLE test_textview: add comments and test, increase coverage to 100% (#1641)
üst
ba365da9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
9 deletions
+25
-9
test_textview.py
Lib/idlelib/idle_test/test_textview.py
+24
-9
textview.py
Lib/idlelib/textview.py
+1
-0
No files found.
Lib/idlelib/idle_test/test_textview.py
Dosyayı görüntüle @
295304d4
...
@@ -5,7 +5,7 @@ is a widget containing multiple widgets, all tests must be gui tests.
...
@@ -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
Using mock Text would not change this. Other mocks are used to retrieve
information about calls.
information about calls.
Coverage:
94
%
.
Coverage:
100
%
.
'''
'''
from
idlelib
import
textview
as
tv
from
idlelib
import
textview
as
tv
from
test.support
import
requires
from
test.support
import
requires
...
@@ -28,14 +28,20 @@ def tearDownModule():
...
@@ -28,14 +28,20 @@ def tearDownModule():
root
.
destroy
()
# Pyflakes falsely sees root as undefined.
root
.
destroy
()
# Pyflakes falsely sees root as undefined.
del
root
del
root
# If we call TextViewer or wrapper functions with defaults
# modal=True, _utest=False, test hangs on call to wait_window.
# Have also gotten tk error 'can't invoke "event" command'.
class
TV
(
tv
.
TextViewer
):
# Used in TextViewTest.
class
TV
(
tv
.
TextViewer
):
# Used in TextViewTest.
transient
=
Func
()
transient
=
Func
()
grab_set
=
Func
()
grab_set
=
Func
()
wait_window
=
Func
()
wait_window
=
Func
()
class
TextViewTest
(
unittest
.
TestCase
):
# Call wrapper class with mock wait_window.
class
TextViewTest
(
unittest
.
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
TV
.
transient
.
__init__
()
TV
.
transient
.
__init__
()
TV
.
grab_set
.
__init__
()
TV
.
grab_set
.
__init__
()
...
@@ -64,6 +70,7 @@ class TextViewTest(unittest.TestCase):
...
@@ -64,6 +70,7 @@ class TextViewTest(unittest.TestCase):
view
.
destroy
()
view
.
destroy
()
# Call TextViewer with modal=False.
class
ViewFunctionTest
(
unittest
.
TestCase
):
class
ViewFunctionTest
(
unittest
.
TestCase
):
@classmethod
@classmethod
...
@@ -77,26 +84,34 @@ class ViewFunctionTest(unittest.TestCase):
...
@@ -77,26 +84,34 @@ class ViewFunctionTest(unittest.TestCase):
del
cls
.
orig_error
del
cls
.
orig_error
def
test_view_text
(
self
):
def
test_view_text
(
self
):
# If modal True, get tk error 'can't invoke "event" command'.
view
=
tv
.
view_text
(
root
,
'Title'
,
'test text'
,
modal
=
False
)
view
=
tv
.
view_text
(
root
,
'Title'
,
'test text'
,
modal
=
False
)
self
.
assertIsInstance
(
view
,
tv
.
TextViewer
)
self
.
assertIsInstance
(
view
,
tv
.
TextViewer
)
view
.
Ok
()
view
.
Ok
()
def
test_view_file
(
self
):
def
test_view_file
(
self
):
test_dir
=
os
.
path
.
dirname
(
__file__
)
view
=
tv
.
view_file
(
root
,
'Title'
,
__file__
,
modal
=
False
)
testfile
=
os
.
path
.
join
(
test_dir
,
'test_textview.py'
)
view
=
tv
.
view_file
(
root
,
'Title'
,
testfile
,
modal
=
False
)
self
.
assertIsInstance
(
view
,
tv
.
TextViewer
)
self
.
assertIsInstance
(
view
,
tv
.
TextViewer
)
self
.
assertIn
(
'Test'
,
view
.
textView
.
get
(
'1.0'
,
'1.end'
))
self
.
assertIn
(
'Test'
,
view
.
textView
.
get
(
'1.0'
,
'1.end'
))
view
.
Ok
()
view
.
Ok
()
def
test_bad_file
(
self
):
# Mock showerror will be used; view_file will return None.
# Mock showerror will be used; view_file will return None.
testfile
=
os
.
path
.
join
(
test_dir
,
'../notthere.py'
)
view
=
tv
.
view_file
(
root
,
'Title'
,
'abc.xyz'
,
modal
=
False
)
view
=
tv
.
view_file
(
root
,
'Title'
,
testfile
,
modal
=
False
)
self
.
assertIsNone
(
view
)
self
.
assertIsNone
(
view
)
self
.
assertEqual
(
tv
.
showerror
.
title
,
'File Load Error'
)
def
test_bad_encoding
(
self
):
p
=
os
.
path
fn
=
p
.
abspath
(
p
.
join
(
p
.
dirname
(
__file__
),
'..'
,
'CREDITS.txt'
))
tv
.
showerror
.
title
=
None
view
=
tv
.
view_file
(
root
,
'Title'
,
fn
,
'ascii'
,
modal
=
False
)
self
.
assertIsNone
(
view
)
self
.
assertEqual
(
tv
.
showerror
.
title
,
'Unicode Decode Error'
)
class
ButtonClickTextViewTest
(
unittest
.
TestCase
):
# Call TextViewer with _utest=True.
class
ButtonClickTest
(
unittest
.
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
view
=
None
self
.
view
=
None
...
...
Lib/idlelib/textview.py
Dosyayı görüntüle @
295304d4
...
@@ -87,6 +87,7 @@ def view_file(parent, title, filename, encoding=None, modal=True, _utest=False):
...
@@ -87,6 +87,7 @@ def view_file(parent, title, filename, encoding=None, modal=True, _utest=False):
parent
=
parent
)
parent
=
parent
)
else
:
else
:
return
view_text
(
parent
,
title
,
contents
,
modal
,
_utest
=
_utest
)
return
view_text
(
parent
,
title
,
contents
,
modal
,
_utest
=
_utest
)
return
None
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
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