mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
test_pelican, CWD-independence
This commit is contained in:
parent
513abbfdc6
commit
13866b5742
2 changed files with 11 additions and 6 deletions
|
|
@ -547,12 +547,16 @@ def get_config(args):
|
|||
|
||||
|
||||
def get_instance(args):
|
||||
config_file = args.settings
|
||||
if config_file is None and os.path.isfile(DEFAULT_CONFIG_NAME):
|
||||
config_file = DEFAULT_CONFIG_NAME
|
||||
args.settings = DEFAULT_CONFIG_NAME
|
||||
config_settings_file = args.settings
|
||||
if config_settings_file is None:
|
||||
if os.path.isfile(DEFAULT_CONFIG_NAME):
|
||||
config_settings_file = DEFAULT_CONFIG_NAME
|
||||
args.settings = DEFAULT_CONFIG_NAME
|
||||
else:
|
||||
config_settings_file = "pelicanconf.py"
|
||||
args.settings = "pelicanconf.py"
|
||||
|
||||
settings = read_settings(config_file, override=get_config(args))
|
||||
settings = read_settings(config_settings_file, override=get_config(args))
|
||||
|
||||
cls = settings["PELICAN_CLASS"]
|
||||
if isinstance(cls, str):
|
||||
|
|
|
|||
|
|
@ -295,13 +295,14 @@ class TestPelican(LoggedTestCase):
|
|||
|
||||
def test_main_on_content(self):
|
||||
"""Invoke main on simple_content directory."""
|
||||
content_subdir = "pelican/tests/simple_content"
|
||||
out, err = io.StringIO(), io.StringIO()
|
||||
with contextlib.redirect_stdout(out), contextlib.redirect_stderr(err):
|
||||
with TemporaryDirectory() as temp_dir:
|
||||
# Don't highlight anything.
|
||||
# See https://rich.readthedocs.io/en/stable/highlighting.html
|
||||
with patch("pelican.console", new=Console(highlight=False)):
|
||||
main(["-o", temp_dir, "pelican/tests/simple_content"])
|
||||
main(["-o", temp_dir, content_subdir])
|
||||
self.assertIn("Processed 1 article", out.getvalue())
|
||||
self.assertEqual("", err.getvalue())
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue