Skip to content

Commit

Permalink
Merge pull request #24 from rarylson/develop
Browse files Browse the repository at this point in the history
Fix error message when config file not found
  • Loading branch information
rarylson committed Oct 24, 2022
2 parents fd486ef + 36268b2 commit 30484e0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changelog
=========

1.0.3
-----

- **Fix:** Error message when config file not found

1.0.2
-----

Expand Down
4 changes: 2 additions & 2 deletions tests/test_parse_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def test_nonexistent_config_parse(self):
with self.assertRaises(SystemExit):
main._parse_all()
output = sys.stderr.getvalue()
self.assertTrue("config" in output and "not found" in output)
self.assertTrue("config file '/non-existent' not found" in output)
finally:
sys.stderr = stderr_old

Expand All @@ -129,7 +129,7 @@ def test_wrong_config_parse(self):
with self.assertRaises(SystemExit):
main._parse_all()
output = sys.stderr.getvalue()
self.assertTrue("section" in output and "not found" in output)
self.assertTrue("section name 'non_existent' not found" in output)
finally:
sys.stderr = stderr_old

Expand Down
5 changes: 4 additions & 1 deletion tests/test_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ def test_script_error(self):
args = [utils.APP]
args += ["-f", file_path, "-d", dir_path]
with self.assertRaises(subprocess.CalledProcessError):
subprocess.check_call(args, stderr=subprocess.STDOUT)
subprocess.check_call(
args,
stderr=subprocess.DEVNULL
)

def test_script_verbose(self):
"""Script must print verbose messages when verbose is set
Expand Down
6 changes: 3 additions & 3 deletions update_conf_py/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
__author__ = "Rarylson Freitas"
__email__ = "rarylson@gmail.com"
__program__ = "update-conf.py"
__version__ = "1.0.2.post1"
__version__ = "1.0.3"
__license__ = "Revised BSD"

# Consts
Expand Down Expand Up @@ -110,9 +110,9 @@ def _parse_all():
config_parser = ConfigParser()
# Specific config file
if args.config:
try:
if os.path.isfile(args.config):
config_parser.read(args.config)
except IOError:
else:
parser.error("config file '{0}' not found".format(args.config))
# Default config file
# Options from USER_CONFIG take precedence over SYSTEM_CONFIG
Expand Down

0 comments on commit 30484e0

Please sign in to comment.