class documentation

class StructureAssertingMixin:

Known subclasses: twisted.python.test.test_release.CommandsTestMixin

View In Hierarchy

A mixin for TestCase subclasses which provides some methods for asserting the structure and contents of directories and files on the filesystem.

Method assertStructure Assert that a directory is equivalent to one described by a dict.
Method createStructure Create a set of directories and files given a dict defining their structure.
def assertStructure(self, root, dirDict):

Assert that a directory is equivalent to one described by a dict.

Parameters
root:FilePathThe filesystem directory to compare.
dirDict:dictThe dict that should describe the contents of the directory. It should be the same structure as the dirDict parameter to createStructure.
def createStructure(self, root, dirDict):

Create a set of directories and files given a dict defining their structure. @param root: The directory in which to create the structure. It must already exist. @type root: L{FilePath} @param dirDict: The dict defining the structure. Keys should be strings naming files, values should be strings describing file contents OR dicts describing subdirectories. All files are written in binary mode. Any string values are assumed to describe text files and will have their newlines replaced with the platform-native newline convention. For example:: {"foofile": "foocontents", "bardir": {"barfile": "bar contents"}} @type dirDict: C{dict}