SILENT KILLERPanel

Current Path: > > opt > alt > python37 > lib64 > > python3.7 > idlelib > idle_test


Operation   : Linux premium131.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
Software     : Apache
Server IP    : 162.0.232.56 | Your IP: 216.73.216.111
Domains      : 1034 Domain(s)
Permission   : [ 0755 ]

Files and Folders in: //opt/alt/python37/lib64//python3.7/idlelib/idle_test

NameTypeSizeLast ModifiedActions
__pycache__ Directory - -
README.txt File 8729 bytes June 05 2023 20:45:13.
__init__.py File 712 bytes April 17 2024 17:36:04.
htest.py File 15190 bytes April 17 2024 17:36:04.
mock_idle.py File 1943 bytes April 17 2024 17:36:04.
mock_tk.py File 11627 bytes April 17 2024 17:36:04.
template.py File 642 bytes April 17 2024 17:36:04.
test_autocomplete.py File 10717 bytes April 17 2024 17:36:04.
test_autocomplete_w.py File 709 bytes April 17 2024 17:36:04.
test_autoexpand.py File 4638 bytes April 17 2024 17:36:04.
test_browser.py File 7963 bytes April 17 2024 17:36:04.
test_calltip.py File 9937 bytes April 17 2024 17:36:04.
test_calltip_w.py File 686 bytes April 17 2024 17:36:04.
test_codecontext.py File 16120 bytes April 17 2024 17:36:04.
test_colorizer.py File 15017 bytes April 17 2024 17:36:04.
test_config.py File 32046 bytes April 17 2024 17:36:04.
test_config_key.py File 9709 bytes April 17 2024 17:36:04.
test_configdialog.py File 54350 bytes April 17 2024 17:36:04.
test_debugger.py File 571 bytes April 17 2024 17:36:04.
test_debugger_r.py File 631 bytes April 17 2024 17:36:04.
test_debugobj.py File 1561 bytes April 17 2024 17:36:04.
test_debugobj_r.py File 545 bytes April 17 2024 17:36:04.
test_delegator.py File 1567 bytes April 17 2024 17:36:04.
test_editmenu.py File 2564 bytes April 17 2024 17:36:04.
test_editor.py File 7523 bytes April 17 2024 17:36:04.
test_filelist.py File 795 bytes April 17 2024 17:36:04.
test_format.py File 23612 bytes April 17 2024 17:36:04.
test_grep.py File 5072 bytes April 17 2024 17:36:04.
test_help.py File 849 bytes April 17 2024 17:36:04.
test_help_about.py File 5921 bytes April 17 2024 17:36:04.
test_history.py File 5517 bytes April 17 2024 17:36:04.
test_hyperparser.py File 9082 bytes April 17 2024 17:36:04.
test_iomenu.py File 1278 bytes April 17 2024 17:36:04.
test_macosx.py File 3309 bytes April 17 2024 17:36:04.
test_mainmenu.py File 594 bytes April 17 2024 17:36:04.
test_multicall.py File 1316 bytes April 17 2024 17:36:04.
test_outwin.py File 5545 bytes April 17 2024 17:36:04.
test_parenmatch.py File 3550 bytes April 17 2024 17:36:04.
test_pathbrowser.py File 2422 bytes April 17 2024 17:36:04.
test_percolator.py File 4065 bytes April 17 2024 17:36:04.
test_pyparse.py File 19227 bytes April 17 2024 17:36:04.
test_pyshell.py File 2171 bytes April 17 2024 17:36:04.
test_query.py File 15280 bytes April 17 2024 17:36:04.
test_redirector.py File 4176 bytes April 17 2024 17:36:04.
test_replace.py File 8305 bytes April 17 2024 17:36:04.
test_rpc.py File 805 bytes April 17 2024 17:36:04.
test_run.py File 11737 bytes April 17 2024 17:36:04.
test_runscript.py File 777 bytes April 17 2024 17:36:04.
test_scrolledlist.py File 496 bytes April 17 2024 17:36:04.
test_search.py File 2459 bytes April 17 2024 17:36:04.
test_searchbase.py File 5635 bytes April 17 2024 17:36:04.
test_searchengine.py File 11543 bytes April 17 2024 17:36:04.
test_sidebar.py File 13231 bytes April 17 2024 17:36:04.
test_squeezer.py File 20088 bytes April 17 2024 17:36:04.
test_stackviewer.py File 1206 bytes April 17 2024 17:36:04.
test_statusbar.py File 1133 bytes April 17 2024 17:36:04.
test_text.py File 6978 bytes April 17 2024 17:36:04.
test_textview.py File 7364 bytes April 17 2024 17:36:04.
test_tooltip.py File 5385 bytes April 17 2024 17:36:04.
test_tree.py File 1752 bytes April 17 2024 17:36:04.
test_undo.py File 4228 bytes April 17 2024 17:36:04.
test_warning.py File 2740 bytes April 17 2024 17:36:04.
test_window.py File 1075 bytes April 17 2024 17:36:04.
test_zoomheight.py File 999 bytes April 17 2024 17:36:04.

Reading File: //opt/alt/python37/lib64//python3.7/idlelib/idle_test/test_grep.py

""" !Changing this line will break Test_findfile.test_found!
Non-gui unit tests for grep.GrepDialog methods.
dummy_command calls grep_it calls findfiles.
An exception raised in one method will fail callers.
Otherwise, tests are mostly independent.
Currently only test grep_it, coverage 51%.
"""
from idlelib import grep
import unittest
from test.support import captured_stdout
from idlelib.idle_test.mock_tk import Var
import os
import re


class Dummy_searchengine:
    '''GrepDialog.__init__ calls parent SearchDiabolBase which attaches the
    passed in SearchEngine instance as attribute 'engine'. Only a few of the
    many possible self.engine.x attributes are needed here.
    '''
    def getpat(self):
        return self._pat

searchengine = Dummy_searchengine()


class Dummy_grep:
    # Methods tested
    #default_command = GrepDialog.default_command
    grep_it = grep.GrepDialog.grep_it
    # Other stuff needed
    recvar = Var(False)
    engine = searchengine
    def close(self):  # gui method
        pass

_grep = Dummy_grep()


class FindfilesTest(unittest.TestCase):

    @classmethod
    def setUpClass(cls):
        cls.realpath = os.path.realpath(__file__)
        cls.path = os.path.dirname(cls.realpath)

    @classmethod
    def tearDownClass(cls):
        del cls.realpath, cls.path

    def test_invaliddir(self):
        with captured_stdout() as s:
            filelist = list(grep.findfiles('invaliddir', '*.*', False))
        self.assertEqual(filelist, [])
        self.assertIn('invalid', s.getvalue())

    def test_curdir(self):
        # Test os.curdir.
        ff = grep.findfiles
        save_cwd = os.getcwd()
        os.chdir(self.path)
        filename = 'test_grep.py'
        filelist = list(ff(os.curdir, filename, False))
        self.assertIn(os.path.join(os.curdir, filename), filelist)
        os.chdir(save_cwd)

    def test_base(self):
        ff = grep.findfiles
        readme = os.path.join(self.path, 'README.txt')

        # Check for Python files in path where this file lives.
        filelist = list(ff(self.path, '*.py', False))
        # This directory has many Python files.
        self.assertGreater(len(filelist), 10)
        self.assertIn(self.realpath, filelist)
        self.assertNotIn(readme, filelist)

        # Look for .txt files in path where this file lives.
        filelist = list(ff(self.path, '*.txt', False))
        self.assertNotEqual(len(filelist), 0)
        self.assertNotIn(self.realpath, filelist)
        self.assertIn(readme, filelist)

        # Look for non-matching pattern.
        filelist = list(ff(self.path, 'grep.*', False))
        self.assertEqual(len(filelist), 0)
        self.assertNotIn(self.realpath, filelist)

    def test_recurse(self):
        ff = grep.findfiles
        parent = os.path.dirname(self.path)
        grepfile = os.path.join(parent, 'grep.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)
        # 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)
        # This file exists in list now.
        self.assertIn(self.realpath, filelist)

        # Check another level up the tree.
        parent = os.path.dirname(parent)
        filelist = list(ff(parent, '*.py', True))
        self.assertIn(self.realpath, filelist)


class Grep_itTest(unittest.TestCase):
    # Test captured reports with 0 and some hits.
    # Should test file names, but Windows reports have mixed / and \ separators
    # from incomplete replacement, so 'later'.

    def report(self, pat):
        _grep.engine._pat = pat
        with captured_stdout() as s:
            _grep.grep_it(re.compile(pat), __file__)
        lines = s.getvalue().split('\n')
        lines.pop()  # remove bogus '' after last \n
        return lines

    def test_unfound(self):
        pat = 'xyz*'*7
        lines = self.report(pat)
        self.assertEqual(len(lines), 2)
        self.assertIn(pat, lines[0])
        self.assertEqual(lines[1], 'No hits.')

    def test_found(self):

        pat = '""" !Changing this line will break Test_findfile.test_found!'
        lines = self.report(pat)
        self.assertEqual(len(lines), 5)
        self.assertIn(pat, lines[0])
        self.assertIn('py: 1:', lines[1])  # line number 1
        self.assertIn('2', lines[3])  # hits found 2
        self.assertTrue(lines[4].startswith('(Hint:'))


class Default_commandTest(unittest.TestCase):
    # To write this, move outwin import to top of GrepDialog
    # so it can be replaced by captured_stdout in class setup/teardown.
    pass


if __name__ == '__main__':
    unittest.main(verbosity=2)

SILENT KILLER Tool