[svn r57557] add lookup in filenames and test machinery.

--HG--
branch : trunk
This commit is contained in:
hpk 2008-08-21 16:25:24 +02:00
parent 29af0e2d81
commit 3652fbfe85
2 changed files with 25 additions and 0 deletions

View File

@ -41,6 +41,13 @@ def main():
if options.ignorecase: if options.ignorecase:
string = string.lower() string = string.lower()
for x in curdir.visit('*.py', rec): 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: try:
s = x.read() s = x.read()
except py.error.ENOENT: except py.error.ENOENT:

View File

@ -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)]
)