• Get Review Board
  • What's New
  • Products
  • Review Board Code review, image review, and document review
  • Documentation
  • Release Notes
  • Power Pack Enterprise integrations, reports, and enhanced document review
  • Try for 60 Days
  • Purchase
  • RBCommons Review Board as a Service, hosted by us
  • Pricing
  • RBTools Command line tools and Python API for Review Board
  • Documentation
  • Release Notes
  • Review Bot Automated code review, connecting tools you already use
  • Documentation
  • Release Notes
  • RB Gateway Manage Git and Mercurial repositories in your network
  • Documentation
  • Release Notes
  • Learn and Explore
  • What is Code Review?
  • Documentation
  • Frequently Asked Questions
  • Support Options
  • Third-Party Integrations
  • Demo
  • Review Board RBTools Power Pack Review Bot Djblets RB Gateway
    1. Review Bot 4.x
    2. Version 4.x
    3. Version 3.0
    4. Version 2.0
    5. Version 1.0
    6. Module and Class Reference
    7. reviewbot.tools.testing.testcases
  • Home
  • Installation
  • Manually Installing Review Bot
  • Review Bot Docker Images
  • Upgrading Review Bot
  • Configuring Review Bot
  • Review Bot Tools
  • Cargo Tool
  • Checkstyle
  • Clang Static Analyzer
  • Cppcheck
  • Cpplint
  • Doc8
  • FBInfer
  • Flake8
  • Go Fmt
  • Go Tool
  • JSHint
  • PMD
  • Pycodestyle
  • Pydocstyle
  • Pyflakes
  • RuboCop
  • Rust Fmt
  • Secret Scanner
  • ShellCheck
  • Module and Class Reference
  • reviewbot.tools.base
  • reviewbot.tools.base.mixins
  • reviewbot.tools.base.registry
  • reviewbot.tools.base.tool
  • reviewbot.testing.testcases
  • reviewbot.testing.utils
  • reviewbot.tools.testing
  • reviewbot.tools.testing.decorators
  • reviewbot.tools.testing.testcases
  • reviewbot.processing.review
  • reviewbot.utils.api
  • reviewbot.utils.filesystem
  • reviewbot.utils.log
  • reviewbot.utils.process
  • reviewbot.utils.text
  • reviewbot.celery
  • reviewbot.config
  • reviewbot.deprecation
  • reviewbot.errors
  • reviewbot.repositories
  • reviewbot.tasks
  • reviewbot.tools.cargotool
  • reviewbot.tools.checkstyle
  • reviewbot.tools.clang
  • reviewbot.tools.cppcheck
  • reviewbot.tools.cpplint
  • reviewbot.tools.doc8
  • reviewbot.tools.fbinfer
  • reviewbot.tools.flake8
  • reviewbot.tools.gofmt
  • reviewbot.tools.gotool
  • reviewbot.tools.jshint
  • reviewbot.tools.pmd
  • reviewbot.tools.pycodestyle
  • reviewbot.tools.pydocstyle
  • reviewbot.tools.pyflakes
  • reviewbot.tools.rbsecretscanner
  • reviewbot.tools.rubocop
  • reviewbot.tools.rustfmt
  • reviewbot.tools.shellcheck
  • General Index
  • Python Module Index
  • Release Notes
  • reviewbot.tools.testing.testcases¶

    Base test case support for tools.

    New in version 3.0.

    Classes

    BaseToolTestCase(*args, **kwargs)

    Base class for Tool test cases.

    ToolTestCaseMetaclass(name, bases, d)

    Metaclass for tool tests.

    class ToolTestCaseMetaclass(name, bases, d)[source]¶

    Bases: type

    Metaclass for tool tests.

    This is required for all subclasses of BaseToolTestCase.

    This will split any test methods that are marked as a simulation and/or integration test into individual tests, set up by the subclass’s setup_simulation_test() or setup_integration_test() method.

    New in version 3.0.

    static __new__(meta, name, bases, d)[source]¶

    Construct a new class.

    Parameters:
    • name (str) – The name of the class.

    • bases (tuple of str) – The parent classes/mixins.

    • d (dict) – The class dictionary.

    Returns:

    The new class.

    Return type:

    type

    classmethod tag_func_name(func_name, tag)[source]¶

    Return a function name tagged with an identifier.

    This will convert a test_* function name into a test_tag_*.

    Parameters:
    • func_name (str) – The original name of the function.

    • tag (str) – The tag to add.

    Returns:

    The resulting function name.

    Return type:

    str

    classmethod make_integration_test_func(func, func_name)[source]¶

    Return a new function for an integration test.

    The function will wrap the original function from the class, and set up the state for an integration test.

    Parameters:
    • func (callable) – The function to wrap.

    • func_name (str) – The name of the function.

    Returns:

    The new integration test function.

    Return type:

    callable

    classmethod make_simulation_test_func(func, func_name)[source]¶

    Return a new function for a simulation test.

    The function will wrap the original function from the class, and set up the state for a simulation test.

    Parameters:
    • func (callable) – The function to wrap.

    • func_name (str) – The name of the function.

    Returns:

    The new simulation test function.

    Return type:

    callable

    __annotations__ = {}¶
    class BaseToolTestCase(*args, **kwargs)[source]¶

    Bases: SpyAgency, TestCase

    Base class for Tool test cases.

    New in version 3.0.

    tool_class = None[source]¶

    The tool class to test.

    This is required.

    Type:

    type

    tool_exe_config_key = None[source]¶

    The key in the configuration identifying the executable of the tool.

    This is required.

    Type:

    str

    tool_exe_path = None[source]¶

    The path to the executable for running the tool.

    This will generally be a fake path for simulated tool runs, but a real one for integration tests. It can be set on the class or during test/test suite setup.

    Type:

    str

    tool_extra_exe_paths = {}[source]¶

    Extra executables needed to run the tool.

    If the tool needs more than one executable for executions or dependency checks, they should be placed here. Keys are equivalent to tool_exe_config_key, and values are equivalent to tool_exe_path.

    Type:

    dict

    run_get_can_handle_file(filename, file_contents=b'', tool_settings={}, file_contents_encoding='utf-8')[source]¶

    Run get_can_handle_file with the given file and settings.

    This will create the review objects, set up a repository (if needed by the tool), apply any configuration, and run get_can_handle_file().

    Changed in version 3.1.2: Added the file_contents_encoding argument.

    Parameters:
    • filename (str) – The filename of the file being reviewed.

    • file_contents (bytes, optional) – File content to review.

    • tool_settings (dict, optional) – The settings to pass to the tool constructor.

    • file_contents_encoding (str, optional) –

      The encoding used for the provided file contents (both in file_contents and other_contents).

      If not provided, this will be utf-8.

      New in version 3.1.2.

    Returns:

    True if the file can be handled. False if it cannot.

    Return type:

    bool

    run_tool_execute(filename, file_contents, checkout_dir=None, tool_settings={}, other_files={}, file_contents_encoding='utf-8')[source]¶

    Run execute with the given file and settings.

    This will create the review objects, set up a repository (if needed by the tool), apply any configuration, and run execute().

    Changed in version 3.1.2: Added the file_contents_encoding argument.

    Parameters:
    • filename (str) – The filename of the file being reviewed.

    • file_contents (bytes) – File content to review.

    • checkout_dir (str, optional) – An explicit directory to use as the checkout directory, for tools that require full-repository checkouts.

    • tool_settings (dict, optional) – The settings to pass to the tool constructor.

    • other_files (dict, optional) –

      Other files to write to the tree. Each will result in a new file added to the review.

      The dictionary is a map of file paths (relative to the checkout directory) to byte strings.

    • file_contents_encoding (str, optional) –

      The encoding used for the provided file contents (both in file_contents and other_contents).

      If not provided, this will be utf-8.

      New in version 3.1.2.

    Returns:

    A 2-tuple containing:

    1. The review (reviewbot.processing.review.Review)

    2. The file entry corresponding to filename (reviewbot.processing.review.File)

    If other_files is specified, the second tuple item will instead be a dictionary of keys from other_files (along with filename) to reviewbot.processing.review.File instances.

    Return type:

    tuple

    setup_integration_test(**kwargs)[source]¶

    Set up an integration test.

    Parameters:

    **kwargs (dict) – Keyword arguments passed to integration_test().

    setup_simulation_test(**kwargs)[source]¶

    Set up a simulation test.

    Parameters:

    **kwargs (dict) – Keyword arguments passed to simulation_test().

    __annotations__ = {}¶

    Keep up with the latest Review Board releases, security updates, and helpful information.

    About
    News
    Demo
    RBCommons Hosting
    Integrations
    Happy Users
    Support Options
    Documentation
    FAQ
    User Manual
    RBTools
    Administration Guide
    Power Pack
    Release Notes
    Downloads
    Review Board
    RBTools
    Djblets
    Power Pack
    Package Store
    PGP Signatures
    Contributing
    Bug Tracker
    Submit Patches
    Development Setup
    Wiki
    Follow Us
    Mailing Lists
    Reddit
    Twitter
    Mastodon
    Facebook
    YouTube

    Copyright © 2006-2025 Beanbag, Inc. All rights reserved.

    Terms of Service — Privacy Policy — AI Ethics Policy — Branding

    On this page

    • [Top]
    • ToolTestCaseMetaclass
      • ToolTestCaseMetaclass.__new__()
      • ToolTestCaseMetaclass.tag_func_name()
      • ToolTestCaseMetaclass.make_integration_test_func()
      • ToolTestCaseMetaclass.make_simulation_test_func()
      • ToolTestCaseMetaclass.__annotations__
    • BaseToolTestCase
      • BaseToolTestCase.tool_class
      • BaseToolTestCase.tool_exe_config_key
      • BaseToolTestCase.tool_exe_path
      • BaseToolTestCase.tool_extra_exe_paths
      • BaseToolTestCase.run_get_can_handle_file()
      • BaseToolTestCase.run_tool_execute()
      • BaseToolTestCase.setup_integration_test()
      • BaseToolTestCase.setup_simulation_test()
      • BaseToolTestCase.__annotations__