luigi.mock module

This module provides a class MockTarget, an implementation of Target. MockTarget contains all data in-memory. The main purpose is unit testing workflows without writing to disk.

class luigi.mock.MockFileSystem[source]

Bases: luigi.target.FileSystem

MockFileSystem inspects/modifies _data to simulate file system operations.

copy(path, dest, raise_if_exists=False)[source]

Copies the contents of a single file path to dest

get_all_data()[source]
get_data(fn)[source]
exists(path)[source]
remove(path, recursive=True, skip_trash=True)[source]

Removes the given mockfile. skip_trash doesn’t have any meaning.

move(path, dest, raise_if_exists=False)[source]

Moves a single file from path to dest

listdir(path)[source]

listdir does a prefix match of self.get_all_data(), but doesn’t yet support globs.

isdir(path)[source]
mkdir(path, parents=True, raise_if_exists=False)[source]

mkdir is a noop.

clear()[source]
class luigi.mock.MockTarget(fn, is_tmp=None, mirror_on_stderr=False, format=None)[source]

Bases: luigi.target.FileSystemTarget

fs = <luigi.mock.MockFileSystem object>
exists()[source]
move(path, raise_if_exists=False)[source]

Call MockFileSystem’s move command

rename(*args, **kwargs)[source]

Call move to rename self

open(mode)[source]
class luigi.mock.MockFile(*args, **kwargs)[source]

Bases: luigi.mock.MockTarget