Latest Version: 0.9.6.2

TestFileEnvironment

This represents an environment in which files will be written, and scripts will be run.


Attributes

a disabled

True

Methods

f __init__(self, base_path, template_path=None, script_path=None, environ=None, cwd=None, start_clear=True, ignore_paths=None, ignore_hidden=True) ...

Creates an environment. base_path is used as the current working directory, and generally where changes are looked for.

template_path is the directory to look for template files, which are files you'll explicitly add to the environment. This is done with .writefile().

script_path is the PATH for finding executables. Usually grabbed from $PATH.

environ is the operating system environment, os.environ if not given.

cwd is the working directory, base_path by default.

If start_clear is true (default) then the base_path will be cleared (all files deleted) when an instance is created. You can also use .clear() to clear the files.

ignore_paths is a set of specific filenames that should be ignored when created in the environment. ignore_hidden means, if true (default) that filenames and directories starting with '.' will be ignored.

f clear(self) ...

Delete all the files in the base directory.

f run(self, script, *args, **kw) ...

Run the command, with the given arguments. The script argument can have space-separated arguments, or you can use the positional arguments.

Keywords allowed are:

expect_error: (default False)
Don't raise an exception in case of errors
expect_stderr: (default expect_error)
Don't raise an exception if anything is printed to stderr
stdin: (default "")
Input to the script
printresult: (default True)
Print the result after running
cwd: (default self.cwd)
The working directory to run in

Returns a ProcResponse object.

f writefile(self, path, content=None, frompath=None) ...

Write a file to the given path. If content is given then that text is written, otherwise the file in frompath is used. frompath is relative to self.template_path

See the source for more information.

Top