ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
pytest_generator Class Reference

Generates pytest test-cases for Python programs. More...

#include <pytest.h>

Public Member Functions

 pytest_generator ()=default
void clear ()
 Clear collected data (called at start of coverage run).
void collect (const symex_target_equationt &target, smt_convt &smt_conv)
 Collect test data from a counterexample (called for each CEX in coverage mode).
void generate (const std::string &output_dir, const std::string &file_name) const
 Generate pytest file from collected data (called at end of coverage mode).
void set_values_only (bool enabled)
 Single-shot generation for non-coverage mode.
void generate_single (const std::string &output_dir, const std::string &file_name, const symex_target_equationt &target, smt_convt &smt_conv, const namespacet &ns)
bool has_tests () const
 Check if any test cases have been collected.

Static Public Member Functions

static std::string extract_module_name (const std::string &input_file)
 Extract module name from input file path and removes .py extension and directory.
static std::string generate_pytest_filename (const std::string &module_name)
 Generate pytest filename from module name.

Static Public Attributes

static constexpr const char * default_output_dir = "esbmc-pytest"
 Default directory for –generate-pytest-testcase output, overridable with –pytest-output-dir (github #6220).

Detailed Description

Generates pytest test-cases for Python programs.

Constructor & Destructor Documentation

◆ pytest_generator()

pytest_generator::pytest_generator ( )
default

Member Function Documentation

◆ clear()

void pytest_generator::clear ( )

Clear collected data (called at start of coverage run).

◆ collect()

void pytest_generator::collect ( const symex_target_equationt & target,
smt_convt & smt_conv )

Collect test data from a counterexample (called for each CEX in coverage mode).

◆ extract_module_name()

std::string pytest_generator::extract_module_name ( const std::string & input_file)
static

Extract module name from input file path and removes .py extension and directory.

◆ generate()

void pytest_generator::generate ( const std::string & output_dir,
const std::string & file_name ) const

Generate pytest file from collected data (called at end of coverage mode).

file_name is the bare filename (e.g. "test_foo.py"); the file is written to output_dir/file_name (github #6220).

◆ generate_pytest_filename()

std::string pytest_generator::generate_pytest_filename ( const std::string & module_name)
static

Generate pytest filename from module name.

◆ generate_single()

void pytest_generator::generate_single ( const std::string & output_dir,
const std::string & file_name,
const symex_target_equationt & target,
smt_convt & smt_conv,
const namespacet & ns )

◆ has_tests()

bool pytest_generator::has_tests ( ) const

Check if any test cases have been collected.

◆ set_values_only()

void pytest_generator::set_values_only ( bool enabled)
inline

Single-shot generation for non-coverage mode.

file_name is the bare filename; the file is written to output_dir/file_name (github #6220). Selects the values-only output (see –pytest-values-only).

Member Data Documentation

◆ default_output_dir

const char* pytest_generator::default_output_dir = "esbmc-pytest"
staticconstexpr

Default directory for –generate-pytest-testcase output, overridable with –pytest-output-dir (github #6220).


The documentation for this class was generated from the following files: