Home | Trees | Index | Help |
|
---|
Package CedarBackup2 :: Module testutil |
|
Provides unit-testing utilities.
These utilities are kept here, separate from util.py, because they provide common functionality that I do not want exported "publicly" once Cedar Backup is installed on a system. They are only used for unit testing, and are only useful within the source tree.
Many of these functions are in here because they are "good enough" for unit test work but are not robust enough to be real public functions. Others (likeremovedir
do what they are supposed to, but
I don't want responsibility for making them available to others.
Author: Kenneth J. Pronovici <pronovic@ieee.org>
Function Summary | |
---|---|
Returns a dictionary of locations for various resources. | |
Indicates whether a command is available on $PATH somewhere. | |
Builds a complete path from a list of components. | |
Recursively removes an entire directory. | |
Extracts the indicated tar file to the indicated tmpdir. | |
Changes a file age using the os.utime function. | |
Returns the user's current umask inverted to a mode. | |
Returns the name of the currently-logged in user. | |
Equivalent of failUnlessRaises , but used for property
assignments instead. | |
Returns boolean indicating whether the effective user id is root. | |
Returns boolean indicating whether this is the Mac OS X platform. | |
Returns boolean indicating whether this is the Windows platform. | |
Returns boolean indicating whether the platform has a sensible echo command. | |
Returns boolean indicating whether the platform supports soft-links. | |
Returns boolean indicating whether the platform supports UNIX-style file permissions. | |
Returns boolean indicating whether the platform requires binary reads. | |
Returns boolean indicating whether we're running on the indicated platform. | |
Captures the output (stdout, stderr) of a function or a method. | |
Generates a random filename with the given length. | |
Sets up a screen logger for debugging purposes. |
Function Details |
---|
findResources(resources, dataDirs)Returns a dictionary of locations for various resources.
|
commandAvailable(command)Indicates whether a command is available on $PATH somewhere. This should work on both Windows and UNIX platforms.
|
buildPath(components)Builds a complete path from a list of components. For instance, constructs"/a/b/c" from ["/a",
"b", "c",] .
|
removedir(tree)Recursively removes an entire directory. This is basically taken from an example on python.com.
|
extractTar(tmpdir, filepath)Extracts the indicated tar file to the indicated tmpdir.
|
changeFileAge(filename, subtract=None)Changes a file age using theos.utime function.
|
getMaskAsMode()Returns the user's current umask inverted to a mode. A mode is mostly a bitwise inversion of a mask, i.e. mask 002 is mode 775.
|
getLogin()Returns the name of the currently-logged in user. This might fail under some circumstances - but if it does, our tests would fail anyway. |
failUnlessAssignRaises(testCase, exception, object, property, value)Equivalent of It's nice to be able to use This function (which can be easily called by unit test classes) provides an easy way to wrap the assignment checks. It's not pretty, or as intuitive as the original check it's modeled on, but it does work. Let's assume you make this method call:testCase.failUnlessAssignRaises(ValueError, collectDir, "absolutePath", absolutePath)If you do this, a test case failure will be raised unless the assignment: collectDir.absolutePath = absolutePathfails with a ValueError exception. The failure message
differentiates between the case where no exception was raised and the
case where the wrong exception was raised.
|
runningAsRoot()Returns boolean indicating whether the effective user id is root. This is always true on platforms that have no concept of root, like Windows. |
platformMacOsX()Returns boolean indicating whether this is the Mac OS X platform. |
platformWindows()Returns boolean indicating whether this is the Windows platform. |
platformHasEcho()Returns boolean indicating whether the platform has a sensible echo command. On some platforms, like Windows, echo doesn't really work for tests. |
platformSupportsLinks()Returns boolean indicating whether the platform supports soft-links. Some platforms, like Windows, do not support links, and tests need to take this into account. |
platformSupportsPermissions()Returns boolean indicating whether the platform supports UNIX-style file permissions. Some platforms, like Windows, do not support permissions, and tests need to take this into account. |
platformRequiresBinaryRead()Returns boolean indicating whether the platform requires binary reads. Some platforms, like Windows, require a special flag to read binary data from files. |
_isPlatform(name)Returns boolean indicating whether we're running on the indicated platform.
|
captureOutput(callable)Captures the output (stdout, stderr) of a function or a method. Some of our functions don't do anything other than just print output. We need a way to test these functions (at least nominally) but we don't want any of the output spoiling the test suite output. This function just creates a dummy file descriptor that can be used as a target by the callable function, rather thanstdout
or stderr .
|
randomFilename(length, prefix=None, suffix=None)Generates a random filename with the given length.
|
setupDebugLogger()Sets up a screen logger for debugging purposes. Normally, the CLI functionality configures the logger so that things get written to the right place. However, for debugging it's sometimes nice to just get everything -- debug information and output -- dumped to the screen. This function takes care of that. |
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Thu Mar 29 20:58:25 2007 | http://epydoc.sf.net |