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 HasCustomCliArgs extra mixin class to extend, simply extend Project
    • the add_custom_cli_args method has been renamed into add_cli_args
  • the get_suites method has been renamed into load_suites
  • the get_fixtures method has been renamed into load_fixtures
  • the get_report_title method has been renamed into build_report_title
  • the get_report_info method has been renamed into build_report_info
  • the hide_command_line_in_report attribute has been turned into show_command_line_in_report which is True by default and must be set to False so that the command line is not displayed in the report
  • the project_dir attribute has been renamed into dir
  • to run code before and/or after test session: the pre_run and post_run methods remain while there are no longer extra HasPreRunHook and HasPostRunHook extra mixin classes to extend
  • the overridable get_metadata_policy has been turned into a metadata_policy that it is set to a vanilla MetadataPolicy instance and that can be changed at will; there is no longer a HasMetadataPolicy mixin 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_dict
  • check_that_entry
  • require_that_entry
  • assert_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_items
  • has_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 description method has been renamed into build_description

  • the short_description method has been renamed into build_short_description

  • the conjugate argument of the build_description and build_short_description methods has been replaced by a transformation argument 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 => MatchResult
  • match_success => MatchResult.success
  • match_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.