[py-svn] r57557 - in py/trunk/py/cmdline: . testing
hpk at codespeak.net
hpk at codespeak.net
Thu Aug 21 16:25:26 CEST 2008
Author: hpk
Date: Thu Aug 21 16:25:24 2008
New Revision: 57557
Added:
py/trunk/py/cmdline/testing/test_cmdline.py
Modified:
py/trunk/py/cmdline/pylookup.py
Log:
add lookup in filenames and test machinery.
Modified: py/trunk/py/cmdline/pylookup.py
==============================================================================
--- py/trunk/py/cmdline/pylookup.py (original)
+++ py/trunk/py/cmdline/pylookup.py Thu Aug 21 16:25:24 2008
@@ -41,6 +41,13 @@
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:
Added: py/trunk/py/cmdline/testing/test_cmdline.py
==============================================================================
--- (empty file)
+++ py/trunk/py/cmdline/testing/test_cmdline.py Thu Aug 21 16:25:24 2008
@@ -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)]
+ )
+
More information about the pytest-commit
mailing list