diff --git a/src/configobj/__init__.py b/src/configobj/__init__.py index 928c208..16da19d 100644 --- a/src/configobj/__init__.py +++ b/src/configobj/__init__.py @@ -1212,7 +1212,7 @@ def _load(self, infile, configspec): if isinstance(infile, six.string_types): self.filename = infile - if os.path.isfile(infile): + if os.path.exists(infile) and not os.path.isdir(infile): with open(infile, 'rb') as h: content = h.readlines() or [] elif self.file_error: diff --git a/src/tests/conf_envsubst.py b/src/tests/conf_envsubst.py new file mode 100644 index 0000000..be790de --- /dev/null +++ b/src/tests/conf_envsubst.py @@ -0,0 +1,4 @@ +import sys +import configobj + +print(configobj.ConfigObj(sys.argv[1])) diff --git a/src/tests/envsubst.ini.template b/src/tests/envsubst.ini.template new file mode 100644 index 0000000..304e892 --- /dev/null +++ b/src/tests/envsubst.ini.template @@ -0,0 +1,4 @@ +# Template test + +shell = ${SHELL} + diff --git a/src/tests/test_validate_envsubst.py b/src/tests/test_validate_envsubst.py new file mode 100644 index 0000000..bdbae18 --- /dev/null +++ b/src/tests/test_validate_envsubst.py @@ -0,0 +1,18 @@ +# *- coding: utf-8 -*- +# pylint: disable=wildcard-import, missing-docstring, no-self-use, bad-continuation +# pylint: disable=invalid-name, redefined-outer-name, too-few-public-methods + +import os + +import pytest +import subprocess + +@pytest.fixture() +def thisdir(): + return os.path.dirname(os.path.join(os.getcwd(), __file__)) + + +def test_validate_template(thisdir,capsys): + templatepath = os.path.join(thisdir, 'envsubst.ini.template') + out = subprocess.check_output(["bash","-c","export SHELL=/bin/bash && python %s/conf_envsubst.py <(envsubst < %s)"%(thisdir,templatepath)]) + assert out.decode() == "{'shell': '/bin/bash'}\n"