Ejemplo n.º 1
0
def install(entries=None, pathmap=None):
    """
    Replace builtin modules with mockfs equivalents.

    :param entries: Dictionary mapping paths to content

    Example::

        install({'/bin/ls': 'content'})

    """
    mockfs = main.singleton(entries=entries, pathmap=pathmap)
    os.path.exists = mockfs.exists
    os.path.islink = mockfs.islink
    os.path.isdir = mockfs.isdir
    os.path.isfile = mockfs.isfile
    os.walk = mockfs.walk
    os.listdir = mockfs.listdir
Ejemplo n.º 2
0
def add_entries(entries):
    """Add entries to the global mockfs singleton."""
    main.singleton().add_entries(entries)