descriptionPython library to create test doubles that fake basic system interfaces: filesystem entries, subprocesses.
homepage URLhttps://pypi.python.org/pypi/gajja/
ownerben+repo.or.cz@benfinney.id.au
last changeSun, 14 Feb 2016 22:06:54 +0000 (15 09:06 +1100)
content tags
add:
README
Gajja: Fake objects for real tests
##################################

The `gajja` library provides a system of Python `test double`_ classes
for specific system objects:

* `Filesystem entries`_

* `Subprocesses`_

..  _test double: http://xunitpatterns.com/Test%20Double.html

The Korean word 가짜 (*gajja*; IPA ˈkaːt͡ɕ̤a) means “fake thing”.


============
Test doubles
============

Filesystem entries
==================

* Create a `gajja.FileDouble` instance for the specific filesystem
  path, and the file content you want the fake file to present.

* Register that `FileDouble` instance to the test case, so it will
  only be faked during that one test case.

* Call helper functions that wrap a `mock.patch` object around each of
  the specific system APIs that access the filesystem (e.g.
  `gajja.patch_os_path_exists`, `gajja.patch_os_stat`, etc.).

* Customise the `FileDouble` instance's behaviour in response to any
  of those interfaces (e.g. `FileDouble.set_os_stat_scenario`, etc.),
  or leave the default behaviour.

* Test your program code as normal, letting it call the filesystem
  access APIs. When the program accesses the filesystem path for the
  `FileDouble`, the test double's behaviour will be invoked; for any
  other filesystem path, the normal API's behaviour will occur.

* Inspect the `FileDouble` instance for changes you need to assert in
  the unit test (e.g. `FileDouble.fake_file.getvalue`). Inspect the
  API mock objects to see how they were called (e.g.
  `os.stat.assert_called_with`).

* At the end of the test case, `mock.patch` will ensure the wrapper is
  removed and the normal API behaviour continues.


Subprocesses
============



=======
Copying
=======

Copyright © 2015–2016 Ben Finney <ben+python@benfinney.id.au>

This is free software: you may copy, modify, and/or distribute this work
under the terms of the GNU General Public License as published by the
Free Software Foundation; version 3 of that license or any later version.
No warranty expressed or implied. See the file ‘LICENSE.GPL-3’ for details.


..
    This document is written using `reStructuredText`_ markup, and can
    be rendered with `Docutils`_ to other formats.

    ..  _Docutils: http://docutils.sourceforge.net/
    ..  _reStructuredText: http://docutils.sourceforge.net/rst.html

..
    Local variables:
    coding: utf-8
    mode: text
    mode: rst
    End:
    vim: fileencoding=utf-8 filetype=rst :
shortlog
2016-02-14 Ben FinneyBe explicit about why we use ‘io.BytesIO’ for the fake... mastermob
2016-02-14 Ben FinneyPrepare a new change log entry for development.
2016-02-14 Ben FinneyFinalise version “0.1.3”.version/0.1.3
2016-02-14 Ben FinneyDistribute full source code in generated ‘sdist’.
2016-02-14 Ben FinneyRefactor patch of ‘builtins.open’ to a separate function.
2016-02-14 Ben FinneyExplain why we use ‘tempfile.mktemp’ specifically.
2016-02-10 Ben FinneyRely on Gajja to report the content length from ‘os...
2016-02-10 Ben FinneyImprove wording of what the tutorial is demonstrating.
2016-02-10 Ben FinneyShow examples of default arguments to ‘FileDouble’.
2016-02-10 Ben FinneyShow the normal behaviour of ‘os.stat’ before our changes.
2016-02-01 Ben FinneyPrepare a new change log entry for development.
2016-02-01 Ben FinneyFinalise version “0.1.2”.version/0.1.2
2016-02-01 Ben FinneyAdd a point-form overview of how file doubles solve...
2016-02-01 Ben FinneyGracefully handle the absence of ‘pwd’ module on some...
2016-01-29 Ben FinneyRefine package docstring markup.
2016-01-29 Ben FinneyPrepare a new change log entry for development.
...
tags
8 years ago version/0.1.3 Version 0.1.3
8 years ago version/0.1.2 Version 0.1.2
8 years ago version/0.1.1 Version 0.1.1
8 years ago version/0.1 Version 0.1
heads
8 years ago mob
8 years ago master