Ticket #6165 enhancement closed fixed
Docstring for twisted.trial.unittest.SynchronousTestCase.mktemp not informative enough
| Reported by: | meissenPlate | Owned by: | tom.prince |
|---|---|---|---|
| Priority: | low | Milestone: | |
| Component: | trial | Keywords: | documentation |
| Cc: | jml, tom.prince@… | Branch: |
branches/mktemp-api-docs-6165
(diff, github, buildbot, log) |
| Author: | exarkun | Launchpad Bug: |
Description
twisted.trial.unittest.SynchronousTestCase.mktemp is used to create temporary directories and files in unit tests. This is its docstring:
"""
Returns a unique name that may be used as either a temporary directory
or filename.
@note: you must call os.mkdir on the value returned from this method if
you wish to use it as a directory!
@return: C{str}
"""
Unique in what context? Could it conflict with a name outside the current working directory? Outside of a standard Twisted distribution? Or is it a magic function that magically gives universally unique names?
Generated Doc.s: http://twistedmatrix.com/documents/current/api/twisted.trial.unittest.SynchronousTestCase.html#mktemp
Source: http://twistedmatrix.com/trac/browser/tags/releases/twisted-12.2.0/twisted/trial/unittest.py#L947
Improved docstring:
"""
Return a relative path that is guaranteed to be unique within the
current working directory. Create every directory between the current
working directory and the last one if necessary. Do not create the
last directory/file.
For a temporary directory call os.mkdir on the path, for a temporary
file, just create the file (e.g. by opening the path for writing and
then closing it).
Trial should delete the temporary file automatically.
@return: C{str}
"""
Internally it uses tempfile.mkdtemp (from the standard library), in combination with the name of the test module, test suite, and test.
It CREATES a short directory hierarchy like ".\twisted.test.test_compat\ExecfileCompatTestCase\test_execfileGlobals\fqsdxf" and returns a string like ".\twisted.test.test_compat\ExecfileCompatTestCase\test_execfileGlobals\fqsdxf\temp". The random portion is coming from tempfile.mkdtemp.

