luigi.mock
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.
Classes
MockFileSystem inspects/modifies _data to simulate file system operations. |
|
|
Initializes a FileSystemTarget instance. |
- class luigi.mock.MockFileSystem[source]
MockFileSystem inspects/modifies _data to simulate file system operations.
- exists(path)[source]
Return
Trueif file or directory atpathexist,Falseotherwise- Parameters:
path (str) – a path within the FileSystem to check for existence.
- remove(path, recursive=True, skip_trash=True)[source]
Removes the given mockfile. skip_trash doesn’t have any meaning.
- listdir(path)[source]
listdir does a prefix match of self.get_all_data(), but doesn’t yet support globs.
- class luigi.mock.MockTarget(fn, is_tmp=None, mirror_on_stderr=False, format=None)[source]
Initializes a FileSystemTarget instance.
- Parameters:
path – the path associated with this FileSystemTarget.
- fs = <luigi.mock.MockFileSystem object>
- exists()[source]
Returns
Trueif the path for this FileSystemTarget exists;Falseotherwise.This method is implemented by using
fs.
- open(mode='r')[source]
Open the FileSystem target.
This method returns a file-like object which can either be read from or written to depending on the specified mode.
- Parameters:
mode (str) – the mode r opens the FileSystemTarget in read-only mode, whereas w will open the FileSystemTarget in write mode. Subclasses can implement additional options. Using b is not supported; initialize with format=Nop instead.