summaryrefslogtreecommitdiffstats
path: root/testsuite/Testsrc/test_code_checks.py
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2012-12-10 20:04:22 -0600
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-12-10 20:04:22 -0600
commitfc8c4d81fd81b66c424480ce5aaa91bcf49809bb (patch)
treea9fbadf3975e9036a9f2df71c655fe615796fa70 /testsuite/Testsrc/test_code_checks.py
parent9d6e6241954d001a5b49e4ea9a48c10e2a792958 (diff)
downloadbcfg2-fc8c4d81fd81b66c424480ce5aaa91bcf49809bb.tar.gz
bcfg2-fc8c4d81fd81b66c424480ce5aaa91bcf49809bb.tar.bz2
bcfg2-fc8c4d81fd81b66c424480ce5aaa91bcf49809bb.zip
testsuite: test for exceptions raised without messages
Diffstat (limited to 'testsuite/Testsrc/test_code_checks.py')
-rw-r--r--testsuite/Testsrc/test_code_checks.py21
1 files changed, 14 insertions, 7 deletions
diff --git a/testsuite/Testsrc/test_code_checks.py b/testsuite/Testsrc/test_code_checks.py
index d4ab0aa12..f6b7e991a 100644
--- a/testsuite/Testsrc/test_code_checks.py
+++ b/testsuite/Testsrc/test_code_checks.py
@@ -2,6 +2,7 @@ import os
import re
import sys
import glob
+import copy
from subprocess import Popen, PIPE, STDOUT
# add all parent testsuite directories to sys.path to allow (most)
@@ -15,13 +16,14 @@ while _path != '/':
_path = os.path.dirname(_path)
from common import *
+# path to base testsuite directory
+testdir = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
+
# path to Bcfg2 src directory
-srcpath = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..",
- "src"))
+srcpath = os.path.abspath(os.path.join(testdir, "..", "src"))
# path to pylint rc file
-rcfile = os.path.abspath(os.path.join(os.path.dirname(__file__), "..",
- "pylintrc.conf"))
+rcfile = os.path.join(testdir, "pylintrc.conf")
# test for pylint existence
try:
@@ -140,7 +142,7 @@ def blacklist_filter(filelist, blacklist):
class TestPylint(Bcfg2TestCase):
pylint_cmd = ["pylint", "--rcfile", rcfile, "--init-hook",
- "import sys;sys.path.append('%s')" %
+ "import sys;sys.path.extend('%s')" %
os.path.join(srcpath, "lib")]
# regex to find errors and fatal errors
@@ -156,6 +158,11 @@ class TestPylint(Bcfg2TestCase):
full_blacklist = expand_path_dict(error_checks) + contingent_blacklist + \
blacklist
+ def get_env(self):
+ env = copy.copy(os.environ)
+ env['PYTHONPATH'] = '%s:%s' % (env['PYTHONPATH'], testdir)
+ return env
+
@skipIf(not os.path.exists(srcpath), "%s does not exist" % srcpath)
@skipIf(not os.path.exists(rcfile), "%s does not exist" % rcfile)
@skipUnless(HAS_PYLINT, "pylint not found, skipping")
@@ -206,7 +213,7 @@ class TestPylint(Bcfg2TestCase):
extra_args = []
args = self.pylint_cmd + extra_args + \
[os.path.join(srcpath, p) for p in paths]
- pylint = Popen(args, stdout=PIPE, stderr=STDOUT)
+ pylint = Popen(args, stdout=PIPE, stderr=STDOUT, env=self.get_env())
print(pylint.communicate()[0])
self.assertEqual(pylint.wait(), 0)
@@ -260,7 +267,7 @@ class TestPylint(Bcfg2TestCase):
args = self.pylint_cmd + extra_args + \
["-f", "parseable", "-d", "R0801,E1103"] + \
[os.path.join(srcpath, p) for p in paths]
- pylint = Popen(args, stdout=PIPE, stderr=STDOUT)
+ pylint = Popen(args, stdout=PIPE, stderr=STDOUT, env=self.get_env())
output = pylint.communicate()[0]
rv = pylint.wait()