Navigation: home >capturemock>rcfiles
Capture-Replay Mocking with CaptureMock
CaptureMock's Configuration Files
(Often referred to as 'rc files')
CaptureMock options are ordinarily specified in a configuration file, for all other than very basic usage. This makes it easier to re-run it with consistent settings, and avoids cluttering up test code with CaptureMock configuration.
The default name for configuration files is .capturemockrc, in the same directory CaptureMock is being run in. When run from TextTest, definition files called "capturemockrc.<app>" are used instead (see here for details). Most of the settings in the configuration file are tied to your source code and how it should be handled, so it should be stored with your tests, and checked into source control, rather than put in your home directory.
Syntax
A CaptureMock configuration/rc file is in classic .ini file format: sections are introduced by a [section] header, and contain name = value entries. Lines beginning with # or ; are ignored as comments.
Strings don't need quotes. Multiline strings can be created by indenting values on multiple lines.
Boolean values can be specified as on, off, true, false, 1, or 0 and are case-insensitive.
Here's a sample configuration file, amalgamated from various things in the TextTest self-tests:
### Command line interception
[command line]
intercepts = tkdiff,emacs,xterm,time,qsub

[qsub]
asynchronous = True
environment = USECASE_RECORD_SCRIPT,USECASE_REPLAY_SCRIPT

[general]
server_multithreaded = True
use_exact_matching = False

### Python interception
[python]
intercepts = smtplib,matplotlib,locale.getdefaultlocale
ignore_callers = usecase,coverage
alterations = pythonbug1820

[locale.getdefaultlocale]
check_repeated_calls = False

# Return values from os.stat and os.lstat aren't repr-eval friendly, see Python bug 1820
[pythonbug1820]
match_pattern = st_[a-z]*=
replacement =
Documentation
These entries are documented as follows. All lists are comma-separated, i.e. entry1,entry2,entry3
  • intercepts (under [command line]) - list of command-line programs to intercept
  • environment - list of environment variables to track for the program named in the section header
  • asynchronous - whether the program named in the section header will cause files to be written after it has exited (default False)
  • use_exact_matching - Whether to fail as soon as anything is slightly different (True) or try to find a likely candidate when replaying (False). Default False.
  • server_multithreaded - whether the CaptureMock server should handle requests concurrently (default True)
  • intercepts (under [python]) - list of Python modules or attributes to intercept
  • alterations - list of transformations (section header names) to perform on the recorded output
  • ignore_callers - list of Python modules from where no interception should be performed.
  • check_repeated_calls - Whether to record the number of times a function is called (True) or assume it always returns the same thing (False). Default True.
  • match_pattern - Regular expression or string to search for when applying the alteration named in the section header.
  • replacement - What to replace the thing matched by "match_pattern" with.


Last updated: 05 October 2012