summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2017-03-10 17:55:11 +0100
committerGitHub <noreply@github.com>2017-03-10 17:55:11 +0100
commit9cba60eddee3e01830b0b0941e2b70b32bd9d4ed (patch)
treef159fbe3829d6aab6dd0daf82604bbc1c81e5a3a
parentcc5fb876c005c443763f130f72acb1de0229efca (diff)
parentd5e3fe95e8565b2c9af730473e4b25aecf5395c5 (diff)
downloadbcfg2-9cba60eddee3e01830b0b0941e2b70b32bd9d4ed.tar.gz
bcfg2-9cba60eddee3e01830b0b0941e2b70b32bd9d4ed.tar.bz2
bcfg2-9cba60eddee3e01830b0b0941e2b70b32bd9d4ed.zip
Merge pull request #362 from AlexanderS/fix/missing-config-file
Options: Missing config file is not a fatal error
-rw-r--r--src/lib/Bcfg2/Options/Parser.py2
-rw-r--r--testsuite/Testsrc/Testlib/TestOptions/TestConfigFiles.py8
2 files changed, 7 insertions, 3 deletions
diff --git a/src/lib/Bcfg2/Options/Parser.py b/src/lib/Bcfg2/Options/Parser.py
index af1af976b..ced61c591 100644
--- a/src/lib/Bcfg2/Options/Parser.py
+++ b/src/lib/Bcfg2/Options/Parser.py
@@ -302,7 +302,7 @@ class Parser(argparse.ArgumentParser):
# check whether the specified bcfg2.conf exists
if not self.unit_test and not os.path.exists(bootstrap.config):
- self.error("Could not read %s" % bootstrap.config)
+ sys.stderr.write("Could not read %s\n" % bootstrap.config)
self.add_config_file(self.configfile.dest, bootstrap.config,
reparse=False)
diff --git a/testsuite/Testsrc/Testlib/TestOptions/TestConfigFiles.py b/testsuite/Testsrc/Testlib/TestOptions/TestConfigFiles.py
index 78acadf1f..4277c8efe 100644
--- a/testsuite/Testsrc/Testlib/TestOptions/TestConfigFiles.py
+++ b/testsuite/Testsrc/Testlib/TestOptions/TestConfigFiles.py
@@ -45,6 +45,10 @@ class TestConfigFiles(OptionTestCase):
inner1()
@mock.patch("os.path.exists", mock.Mock(return_value=False))
- def test_no_config_file(self):
+ @make_config()
+ def test_no_config_file(self, config):
"""fail to read config file."""
- self.assertRaises(SystemExit, self.parser.parse, [])
+ try:
+ self.parser.parse(['-C', config])
+ except SystemExit:
+ self.fail('Missing config file should not raise SystemExit')