diff options
author | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2014-11-11 14:50:22 -0600 |
---|---|---|
committer | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2014-11-11 14:50:22 -0600 |
commit | 77cf4a56b3b7ff8cd466705b968abb539efa703f (patch) | |
tree | 9769d560cce0dacda0360dfc434f33774cb01f5e /testsuite/common.py | |
parent | 389ce1a86b704222ddc9458cd49c281e7601b803 (diff) | |
parent | 30634d07d5489f260f37cc86d150315f02c40865 (diff) | |
download | bcfg2-77cf4a56b3b7ff8cd466705b968abb539efa703f.tar.gz bcfg2-77cf4a56b3b7ff8cd466705b968abb539efa703f.tar.bz2 bcfg2-77cf4a56b3b7ff8cd466705b968abb539efa703f.zip |
Merge pull request #211 from stpierre/options-unit-tests
Options unit tests
Diffstat (limited to 'testsuite/common.py')
-rw-r--r-- | testsuite/common.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/testsuite/common.py b/testsuite/common.py index 5a08f8db5..a86e9c5d9 100644 --- a/testsuite/common.py +++ b/testsuite/common.py @@ -38,7 +38,13 @@ def set_setup_default(option, value=None): if not hasattr(Bcfg2.Options.setup, option): setattr(Bcfg2.Options.setup, option, value) +# these two variables do slightly different things for unit tests; the +# former skips config file reading, while the latter sends option +# debug logging to stdout so it can be captured. These are separate +# because we want to enable config file reading in order to test +# option parsing. Bcfg2.Options.Parser.unit_test = True +Bcfg2.Options.Options.unit_test = True try: import django.conf @@ -119,6 +125,19 @@ class Bcfg2TestCase(TestCase): :func:`assertXMLEqual`, a useful assertion method given all the XML used by Bcfg2. """ + capture_stderr = True + + @classmethod + def setUpClass(cls): + cls._stderr = sys.stderr + if cls.capture_stderr: + sys.stderr = sys.stdout + + @classmethod + def tearDownClass(cls): + if cls.capture_stderr: + sys.stderr = cls._stderr + def assertXMLEqual(self, el1, el2, msg=None): """ Test that the two XML trees given are equal. """ if msg is None: |