You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gump.apache.org by le...@apache.org on 2005/06/24 12:08:48 UTC
svn commit: r201588 - in /gump/branches/Gump3/bin/pylid-0.3: pylid.py
test/test_tester.py
Author: leosimons
Date: Fri Jun 24 03:08:46 2005
New Revision: 201588
URL: http://svn.apache.org/viewcvs?rev=201588&view=rev
Log:
Implement suggestion from Aldo Cortesi to use action=append for the -b argument on pylid.
* bin/pylid-0.3/pylid.py: rename baseDirs argument to Tester back to baseDir for backward compat, also add a check for the str type, again for backward compat. Change option parsing to suppport multiple -b arguments rather than split based on ':'.
* bin/pylid-0.3/test/test_tester.py: add checks for new baseDir argument support.
Modified:
gump/branches/Gump3/bin/pylid-0.3/pylid.py
gump/branches/Gump3/bin/pylid-0.3/test/test_tester.py
Modified: gump/branches/Gump3/bin/pylid-0.3/pylid.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/bin/pylid-0.3/pylid.py?rev=201588&r1=201587&r2=201588&view=diff
==============================================================================
--- gump/branches/Gump3/bin/pylid-0.3/pylid.py (original)
+++ gump/branches/Gump3/bin/pylid-0.3/pylid.py Fri Jun 24 03:08:46 2005
@@ -248,15 +248,20 @@
class Tester:
- def __init__(self, baseDirs, include, exclude):
+ def __init__(self, baseDir, include, exclude):
"""
Takes the project base directories. These directories are inserted into
our path so that unit tests can import files/modules from there.
"""
# We want to be able to import from the current dir
self.cov = Coverage(include, exclude)
- for baseDir in baseDirs:
+ if(isinstance(baseDir, str)):
+ # support for old calling convention for Tester with just a single basedir...
sys.path.insert(0, baseDir)
+ else:
+ # the new way passes in an array
+ for dir in baseDir:
+ sys.path.insert(0, dir)
# We also insert the current directory, to make sure we can import
# source files in our test directory.
@@ -377,10 +382,10 @@
help="Verbose.")
group = OptionGroup(parser, "Controlling Coverage Paths",
- "If a project is structured correctly, these options will rarely be required.")
+ "These options are only necessary if your project layout deviates from what pylid expects.")
group.add_option("-b", "--base",
- action="store", type="string", dest="base", default="..", metavar="DIR",
- help='Project base directories, seperated by colons. (Default: "..")')
+ action="append", type="string", dest="base", metavar="DIR",
+ help='Project base directory. Can be passed multiple times. (Default: "..")')
group.add_option("-e", "--exclude",
action="append", type="string", dest="exclude", metavar="DIR",
help='Exclude path from coverage analysis. Can be passed multiple times. (Default: ".")')
@@ -393,6 +398,8 @@
(options, args) = parser.parse_args()
+ if not options.base:
+ options.base = [".."]
if not options.exclude:
options.exclude = ["."]
@@ -405,17 +412,17 @@
if options.clear:
for filename in GlobDirectoryWalker(options.include, '*.pyc'):
os.remove(filename)
- for basedir in options.base.split(':'):
+ for basedir in options.base:
for filename in GlobDirectoryWalker(basedir, '*.pyc'):
os.remove(filename)
for filename in GlobDirectoryWalker(options.include, '*.pyo'):
os.remove(filename)
- for basedir in options.base.split(':'):
+ for basedir in options.base:
for filename in GlobDirectoryWalker(basedir, '*.pyo'):
os.remove(filename)
# Do the actual run
- t = Tester(options.base.split(':'), options.include, options.exclude)
+ t = Tester(options.base, options.include, options.exclude)
dostats = options.stats or options.annotate
Modified: gump/branches/Gump3/bin/pylid-0.3/test/test_tester.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/bin/pylid-0.3/test/test_tester.py?rev=201588&r1=201587&r2=201588&view=diff
==============================================================================
--- gump/branches/Gump3/bin/pylid-0.3/test/test_tester.py (original)
+++ gump/branches/Gump3/bin/pylid-0.3/test/test_tester.py Fri Jun 24 03:08:46 2005
@@ -1,6 +1,6 @@
import unittest
import pylid
-
+import sys
class uTester(unittest.TestCase):
def setUp(self):
@@ -13,7 +13,16 @@
def test_addPathDir(self):
self.tt.addPath("testTester/addPath/dir", 0)
self.failUnlessEqual(self.tt.suite.countTestCases(), 2)
+
+ def test_singleBaseDir(self):
+ tt = pylid.Tester(".", "..", "..")
+ self.assert_("." in sys.path)
+ def test_multipleBaseDir(self):
+ tt = pylid.Tester([".", "blah", "blah/blah"], "..", "..")
+ self.assert_("." in sys.path)
+ self.assert_("blah" in sys.path)
+ self.assert_("blah/blah" in sys.path)
def makeSuite():
suite = unittest.makeSuite(uTester)