Skip to content
Prev Previous commit
Next Next commit
Update tests
  • Loading branch information
vstinner committed Jun 23, 2022
commit 110cab20acba19f106410712661b95350cefdeb0
7 changes: 2 additions & 5 deletions Lib/test/test_idle/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,9 @@ def setUpClass(cls):
cls.config_string = {}

conf = config.IdleConf(_utest=True)
if __name__ != '__main__':
idle_dir = os.path.dirname(__file__)
else:
idle_dir = os.path.abspath(sys.path[0])
idle_dir = os.path.dirname(idlelib.__file__)
for ctype in conf.config_types:
config_path = os.path.join(idle_dir, '../config-%s.def' % ctype)
config_path = os.path.join(idle_dir, 'config-%s.def' % ctype)
with open(config_path, 'r') as f:
cls.config_string[ctype] = f.read()

Expand Down
6 changes: 3 additions & 3 deletions Lib/test/test_idle/test_grep.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,23 +89,23 @@ def test_base(self):
def test_recurse(self):
ff = grep.findfiles
parent = os.path.dirname(self.path)
grepfile = os.path.join(parent, 'grep.py')
test_os = os.path.join(parent, 'test_os.py')
pat = '*.py'

# Get Python files only in parent directory.
filelist = list(ff(parent, pat, False))
parent_size = len(filelist)
# Lots of Python files in idlelib.
self.assertGreater(parent_size, 20)
self.assertIn(grepfile, filelist)
self.assertIn(test_os, filelist)
# Without subdirectories, this file isn't returned.
self.assertNotIn(self.realpath, filelist)

# Include subdirectories.
filelist = list(ff(parent, pat, True))
# More files found now.
self.assertGreater(len(filelist), parent_size)
self.assertIn(grepfile, filelist)
self.assertIn(test_os, filelist)
# This file exists in list now.
self.assertIn(self.realpath, filelist)

Expand Down
3 changes: 2 additions & 1 deletion Lib/test/test_idle/test_help.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"Test help, coverage 87%."

import idlelib
from idlelib import help
import unittest
from test.support import requires
Expand All @@ -15,7 +16,7 @@ def setUpClass(cls):
"By itself, this tests that file parsed without exception."
cls.root = root = Tk()
root.withdraw()
helpfile = join(dirname(dirname(abspath(__file__))), 'help.html')
helpfile = join(dirname(abspath(idlelib.__file__)), 'help.html')
cls.frame = help.HelpFrame(root, helpfile)

@classmethod
Expand Down
3 changes: 2 additions & 1 deletion Lib/test/test_idle/test_textview.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Using mock Text would not change this. Other mocks are used to retrieve
information about calls.
"""
import idlelib
from idlelib import textview as tv
from test.support import requires
requires('gui')
Expand Down Expand Up @@ -176,7 +177,7 @@ def test_bad_file(self):

def test_bad_encoding(self):
p = os.path
fn = p.abspath(p.join(p.dirname(__file__), '..', 'CREDITS.txt'))
fn = p.abspath(p.join(p.dirname(idlelib.__file__), 'CREDITS.txt'))
view = tv.view_file(root, 'Title', fn, 'ascii', modal=False)
self.assertIsNone(view)
self.assertEqual(tv.showerror.title, 'Unicode Decode Error')
Expand Down