lemoncheesecake provides logging functions that give the user the ability to log information beyond the checks:

  • log_debug(msg)

  • log_info(msg)

  • log_warn(msg)

  • log_error(msg): this log will mark the test as failed

  • log_url(url[, description])


lcc.log_debug("Some debug message")
lcc.log_info("More important, informational message")
lcc.log_warning("Something looks abnormal")
lcc.log_error("Something bad happened")
lcc.log_url("http://example.com", "Example dot com")


Changed in version 1.10.0.

Debug logs are not displayed by default in the HTML report nor by the lcc report command, unless you check the appropriate checkbox or use the --debug argument respectively. It makes the debug log level particularly useful if you want less-important information to be not displayed by default to the report reader.


Steps provide a way to organize your logs and checks within logical steps:

lcc.set_step("Prepare stuff for test")
value = 42
lcc.log_info("Retrieve data for %d" % value)
data = some_function_that_provide_data(value)
lcc.log_info("Got data: %s" % data)

lcc.set_step("Check data")
    "foo", equal_to(21),
    "bar", equal_to(42)


Within a test, you also have the possibility to attach files to the report:

lcc.save_attachment_file(filename, "file.pdf")

The file will be copied into the report dir and is prefixed by a unique value, making it possible to save multiple times an attachment with the same base file name. The attachment description is optional.

There are other ways to save attachment files depending on your needs.

If the file you want to save is loaded in memory:

lcc.save_attachment_content(data, "file.pdf", "PDF file")

save_attachment_content looks for the type of the data argument to know whether or not the file must be opened in binary mode.

If you need the effective file path to write into:

with lcc.prepare_attachment("file.pdf", "PDF file") as filename:
    with open(filename, "w") as fh:

Each of these three functions as a corresponding function for image attachment:

  • save_image_file

  • save_image_content

  • prepare_image_attachment

In that case, the attached file will be considered as an image and will be displayed inline in the HTML report.