view tests/doctest.txt @ 22:63ff1b00ec05

first passing test
author Jeff Hammel <jhammel@mozilla.com>
date Wed, 09 Nov 2011 20:11:05 -0800
parents 0706968f01bb
children 1c963875e6cd
line wrap: on
line source

Test fetch
==========

The obligatory imports::

    >>> import fetch
    >>> import os
    >>> import shutil
    >>> import tempfile

Create a staging directory::

    >>> stage = tempfile.mkdtemp()

Create a Fetch object::

    >>> f = fetch.Fetch(relative_to=stage, strict=True)
    
Call Fetch directly::

    >>> def url(*args):
    ...     return 'file://' + os.path.join(*([here] + list(args)))
    >>> f(url=url('sample1.txt'), destination=stage, type='file')
    >>> file(os.path.join(stage, 'sample1.txt')).read().strip()
    'sample1'

Cleanup::

    >>> shutil.rmtree(stage)