#1016 closed enhancement (fixed)

Add dependency on a mocking library

Reported by: francois Owned by: zooko
Priority: minor Milestone: 1.7.0
Component: code Version: 1.6.1
Keywords: test reviewed Cc:
Launchpad Bug:

Description

A mocking library comes handy for writing tests which exercise only a specific class or function independently of the rest of the code. This is especially useful with system functions like os.listdir() which works differently across platforms.

On #tahoe-lafs, Zooko proposed to use the mock Python library written by Michael Foord.

If nobody objects, I'll post a patch which add a dependency on mock in source:/_auto_deps.py#L1.

Attachments (2)

add-mock-dependency.dpatch (2.0 KB) - added by francois at 2010-04-06T13:27:24Z.
mock-require.dpatch (45.4 KB) - added by zooko at 2010-06-09T05:16:16Z.

Download all attachments as: .zip

Change History (10)

comment:1 Changed at 2010-04-06T12:55:31Z by zooko

Yeah, go ahead.

Changed at 2010-04-06T13:27:24Z by francois

comment:2 Changed at 2010-04-06T13:28:42Z by francois

  • Keywords review-needed added
  • Owner changed from francois to zooko

Here is it.

comment:3 Changed at 2010-05-08T20:18:44Z by zooko

Let's wait til we have tests that use this library and then commit the patch that adds the dependency along with the patch that uses it.

comment:4 Changed at 2010-05-22T14:14:46Z by francois

The patch has been pushed as part of work on #534 (Unicode issues in CLI) in branch ticket534.

comment:5 Changed at 2010-06-03T04:31:24Z by davidsarah

  • Keywords test added; review-needed removed

zooko is merging the ticket534 branch.

comment:6 Changed at 2010-06-09T04:20:47Z by zooko

This was done in b2542b87085be095. But I just now realized that it was done wrong! mock is a test-time dependency not a run-time dependency, so it should be included in tests_require in setup.py and excluded from install_requires in _auto_deps.py.

Changed at 2010-06-09T05:16:16Z by zooko

comment:7 Changed at 2010-06-09T05:16:25Z by zooko

  • Keywords review-needed added

comment:8 Changed at 2010-06-09T07:55:28Z by francois

  • Keywords reviewed added; review-needed removed
  • Resolution set to fixed
  • Status changed from new to closed

I didn't knew about tests_require. That's indeed a good idea to use it.

Zooko, the patch looks correct and the functionality (mock dependency is installed if unit tests are run) is working as expected so I'll close this ticket.

Note: See TracTickets for help on using tickets.