Home | Trees | Indices | Help |
|
---|
|
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 (like removedir) 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>
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|
Returns a dictionary of locations for various resources.
|
Indicates whether a command is available on $PATH somewhere. This should work on both Windows and UNIX platforms.
|
Builds a complete path from a list of components. For instance,
constructs
|
Recursively removes an entire directory. This is basically taken from an example on python.com.
|
Extracts the indicated tar file to the indicated tmpdir.
|
Changes a file age using the
Note: Some platforms don't seem to be able to set an age precisely. As a result, whereas we might have intended to set an age of 86400 seconds, we actually get an age of 86399.375 seconds. When util.calculateFileAge() looks at that the file, it calculates an age of 0.999992766204 days, which then gets truncated down to zero whole days. The tests get very confused. To work around this, I always subtract off one additional second as a fudge factor. That way, the file age will be at least as old as requested later on. |
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.
|
Returns the name of the currently-logged in user. This might fail under some circumstances - but if it does, our tests would fail anyway. |
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 = absolutePath fails with a
Note:
Internally, the See Also:
|
Returns boolean indicating whether the effective user id is root. This is always true on platforms that have no concept of root, like Windows. |
Returns boolean indicating whether the platform has a sensible echo command. On some platforms, like Windows, echo doesn't really work for tests. |
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. |
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. |
Returns boolean indicating whether the platform requires binary reads. Some platforms, like Windows, require a special flag to read binary data from files. |
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. |
Generates a random filename with the given length.
|
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 than
Note:
This method assumes that |
Returns boolean indicating whether we're running on the indicated platform.
|
Returns a list of available locales on the system
|
Indicates whether hex float literals are allowed by the interpreter. As far back as 2004, some Python documentation indicated that octal and hex notation applied only to integer literals. However, prior to Python 2.5, it was legal to construct a float with an argument like 0xAC on some platforms. This check provides a an indication of whether the current interpreter supports that behavior. This check exists so that unit tests can continue to test the same thing as always for pre-2.5 interpreters (i.e. making sure backwards compatibility doesn't break) while still continuing to work for later interpreters. The returned value is True if hex float literals are allowed, False otherwise. |
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sun Aug 16 15:13:22 2009 | http://epydoc.sourceforge.net |