Migrating to 1.x¶
This page lists all the non-compatible changes between 0.22.x and 1.x versions of lemoncheesecake and tell how to migrate.
API¶
Project¶
The project.py entry point of lemoncheesecake projects has been greatly simplified in version 1.x.
The project.py as it was generated by lcc bootstrap looked like this in version 0.22.x:
import os.path
from lemoncheesecake.project import SimpleProjectConfiguration
project_dir = os.path.dirname(__file__)
project = SimpleProjectConfiguration(
suites_dir=os.path.join(project_dir, "suites"),
fixtures_dir=os.path.join(project_dir, "fixtures"),
)
Here is how it looks in version 1.x:
import os.path
from lemoncheesecake.project import Project
project_dir = os.path.dirname(__file__)
project = Project(project_dir)
If you did not change the initial project.py file, you can simply replace the existing content by this new content.
Here is what have been changed:
to add custom CLI arguments to
lcc run:there is no more
HasCustomCliArgsextra mixin class to extend, simply extendProjectthe
add_custom_cli_argsmethod has been renamed intoadd_cli_args
the
get_suitesmethod has been renamed intoload_suitesthe
get_fixturesmethod has been renamed intoload_fixturesthe
get_report_titlemethod has been renamed intobuild_report_titlethe
get_report_infomethod has been renamed intobuild_report_infothe
hide_command_line_in_reportattribute has been turned intoshow_command_line_in_reportwhich isTrueby default and must be set toFalseso that the command line is not displayed in the reportthe
project_dirattribute has been renamed intodirto run code before and/or after test session: the
pre_runandpost_runmethods remain while there are no longer extraHasPreRunHookandHasPostRunHookextra mixin classes to extendthe overridable
get_metadata_policyhas been turned into ametadata_policythat it is set to a vanillaMetadataPolicyinstance and that can be changed at will; there is no longer aHasMetadataPolicymixin class to extend
Also see Project customization for more information.
Test and suite declaration¶
The add_test_in_suite and add_tests_in_suite functions have been removed.
Use add_test_into_suite instead.
The @lcc.conditional(...) decorator has been renamed into @lcc.visible_if(...).
Logging¶
The log_warn function from lemoncheesecake.api has been removed, use log_warning instead.
Matchers¶
The following functions have been removed:
this_dictcheck_that_entryrequire_that_entryassert_that_entry
The corresponding check_that_in, require_that_in and assert_that_in functions must be used instead.
The following matchers have been renamed:
has_values=>has_itemshas_only_values=>has_only_items
In is_text matcher: the second argument (linesep) default value is now "\n" instead of os.linesep.
In Matcher class:
the
descriptionmethod has been renamed intobuild_descriptionthe
short_descriptionmethod has been renamed intobuild_short_descriptionthe
conjugateargument of thebuild_descriptionandbuild_short_descriptionmethods has been replaced by atransformationargument which is callable that will transform the verb used in the matcher description depending on the context, example:def build_description(self, transformation): return transformation("to be equal to 42")
In the Matcher.matches method from lemoncheesecake.matching.base, three functions could be used to build
the match result: match_result, match_success, match_failure.
It has been changed to use the MatchResult class directly:
match_result=>MatchResultmatch_success=>MatchResult.successmatch_failure=>MatchResult.failure
The lemoncheesecake.matching.base module has been renamed into lemoncheesecake.matching.matcher.
The lemoncheesecake.api module no longer exports the matching API, use from lemoncheesecake.matching import * as
it was/is documented.
Fixtures¶
The fixture scope session_prerun has been renamed into pre_run.
The lemoncheesecake.fixtures module has been renamed into lemoncheesecake.fixture.
Attachment logs¶
The binary_mode argument of the save_attachment_content function has been removed. The file opening mode
is now automatically determined upon the type of data passed as argument.
Misc¶
The lemoncheesecake.validators module, that holds the MetadataPolicy class, has been renamed into
lemoncheesecake.metadatapolicy.
Reporting¶
The HTML report now use static resources (also named “fat”) by default, meaning the report can be be read offline
for instance. In other words: the offline_mode attribute of the class lemoncheesecake.reporting.backends.HtmlBackend
has been renamed into fat_html and is now set to True by default.
In Slack & ReportPortal reporting backends, all environment variables used for configuration are now prefixed by
LCC_, example: RP_URL => LCC_RP_URL
CLI¶
The --enable-reporting and --disable-reporting arguments have been removed from lcc run.
Use the --reporting argument instead as documented here.