Commit 1371a28a authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Fix issues caused by assumption that Context.text might be unset

parent cd6e64d1
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
#  Copyright 2021-2022  Dominik Sekotill <dom.sekotill@kodo.org.uk>
#  Copyright 2021-2023  Dominik Sekotill <dom.sekotill@kodo.org.uk>
#
#  This Source Code Form is subject to the terms of the Mozilla Public
#  License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -64,9 +64,7 @@ def create_post(context: Context, post_type: PostType, text: str|None = None) ->
	"""
	Create a WP post of the given type and store it in the context with the type as the name
	"""
	text = text or getattr(context, "text", "")
	assert isinstance(text, str)
	post = use_fixture(wp_post, context, post_type, text)
	post = use_fixture(wp_post, context, post_type, text or context.text or "")
	setattr(context, post_type.value, post)


+2 −2
Original line number Diff line number Diff line
#  Copyright 2022  Dominik Sekotill <dom.sekotill@kodo.org.uk>
#  Copyright 2022-2023  Dominik Sekotill <dom.sekotill@kodo.org.uk>
#
#  This Source Code Form is subject to the terms of the Mozilla Public
#  License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -34,6 +34,6 @@ def container_file(context: Context, path: str, container_name: str) -> Iterator
	"""
	container = getattr(context.site, container_name)
	run = Cli(container)
	run("tee", path, input=getattr(context, "text", "This is a data file!"))
	run("tee", path, input=(context.text or "This is a data file!"))
	yield
	run("rm", path)