From 3652fbfe85b087bf72ab92474a89f926a57809be Mon Sep 17 00:00:00 2001 From: hpk Date: Thu, 21 Aug 2008 16:25:24 +0200 Subject: [PATCH] [svn r57557] add lookup in filenames and test machinery. --HG-- branch : trunk --- py/cmdline/pylookup.py | 7 +++++++ py/cmdline/testing/test_cmdline.py | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 py/cmdline/testing/test_cmdline.py diff --git a/py/cmdline/pylookup.py b/py/cmdline/pylookup.py index 59ae1c62f..8b4562609 100755 --- a/py/cmdline/pylookup.py +++ b/py/cmdline/pylookup.py @@ -41,6 +41,13 @@ def main(): if options.ignorecase: string = string.lower() for x in curdir.visit('*.py', rec): + # match filename directly + s = x.relto(curdir) + if options.ignorecase: + s = s.lower() + if s.find(string) != -1: + print >>sys.stdout, "%s: filename matches %r" %(x, string) + try: s = x.read() except py.error.ENOENT: diff --git a/py/cmdline/testing/test_cmdline.py b/py/cmdline/testing/test_cmdline.py new file mode 100644 index 000000000..9957504c2 --- /dev/null +++ b/py/cmdline/testing/test_cmdline.py @@ -0,0 +1,18 @@ +from py.__.test.testing import suptest +from py.__.test.testing.acceptance_test import AcceptBase + +class TestPyLookup(AcceptBase): + def test_basic(self): + p = self.makepyfile(hello="def x(): pass") + result = self.run("py.lookup", "pass") + suptest.assert_lines_contain_lines(result.outlines, + ['%s:*def x(): pass' %(p.basename)] + ) + + def test_search_in_filename(self): + p = self.makepyfile(hello="def x(): pass") + result = self.run("py.lookup", "hello") + suptest.assert_lines_contain_lines(result.outlines, + ['*%s:*' %(p.basename)] + ) +