converted lookup to dicts

added basic tests
This commit is contained in:
Kurt Grandis
2010-03-07 13:07:20 -05:00
parent 8c90d0cccc
commit ba03eba719
2 changed files with 48 additions and 7 deletions

View File

@@ -21,29 +21,29 @@ class NoseExclude(Plugin):
"""Configure plugin based on command line options"""
super(NoseExclude, self).configure(options, conf)
self.exclude_dirs = {}
if not options.exclude_dirs:
self.enabled = False
return
self.enabled = True
root = os.getcwd()
log.debug('cwd: %s' % root)
cleaned_dirs = []
# Normalize excluded directory names for lookup
for d in options.exclude_dirs:
if os.path.isabs(d):
cleaned_dirs.append(d)
self.exclude_dirs[d] = True
elif os.path.isdir(d):
#see if it's relative
new_abs_d = os.path.join(root,d)
cleaned_dirs.append(new_abs_d)
self.exclude_dirs[new_abs_d] = True
else:
#bad path
raise ValueError("invalid path: %s" % d)
self.exclude_dirs = cleaned_dirs
exclude_str = "excluding dirs: %s" % ",".join(self.exclude_dirs)
exclude_str = "excluding dirs: %s" % ",".join(self.exclude_dirs.keys())
log.debug(exclude_str)
def wantDirectory(self, dirname):

41
tests.py Normal file
View File

@@ -0,0 +1,41 @@
import os
import unittest
from nose.plugins import PluginTester
from nose_exclude import NoseExclude
class TestNoseExcludeDirs_Relative_Args(PluginTester, unittest.TestCase):
exclude_args = "--exclude-dir=test_dirs/build"
activate = exclude_args
root = os.getcwd()
target_arg = os.path.join(root, 'test_dirs')
suitepath = target_arg
args = ['-vvvv', '--exclude-dir=test_dirs/test_not_me']
plugins = [NoseExclude()]
#def __init__(self, *args, **kwargs):
# super(TestNoseExclude, self).__init__(*args, **kwargs)
def test_output(self):
assert "FAILED" not in self.output
def me(self):
print self.argv
#print self.addargs
print "XXXX", self.nose, dir(self.nose)
print "test Names", self.nose.testNames
print "want", self.nose.__dict__
for line in self.output:
print "out", line
#def runTest(self):
# pass
#def makeSuite(self):
# #return self.target_arg
# return unittest.TestSuite(tests=[TestNoseExclude()])
if __name__ == '__main__':
unittest.main()