Back to index

python3.2  3.2.2
Classes | Public Member Functions | Public Attributes | Static Public Attributes
test.test_tempfile.test_mktemp Class Reference
Inheritance diagram for test.test_tempfile.test_mktemp:
Inheritance graph
[legend]
Collaboration diagram for test.test_tempfile.test_mktemp:
Collaboration graph
[legend]

List of all members.

Classes

class  mktemped

Public Member Functions

def setUp
def tearDown
def do_create
def test_basic
def test_many
def failOnException
def nameCheck

Public Attributes

 dir

Static Public Attributes

tuple str_check = re.compile(r"[a-zA-Z0-9_-]{6}$")

Detailed Description

Test mktemp().

Definition at line 502 of file test_tempfile.py.


Member Function Documentation

def test.test_tempfile.test_mktemp.do_create (   self,
  pre = "",
  suf = "" 
)

Definition at line 530 of file test_tempfile.py.

00530 
00531     def do_create(self, pre="", suf=""):
00532         try:
00533             file = self.mktemped(self.dir, pre, suf)
00534         except:
00535             self.failOnException("mktemp")
00536 
00537         self.nameCheck(file.name, self.dir, pre, suf)
00538         return file

Here is the call graph for this function:

Here is the caller graph for this function:

def test.test_tempfile.TC.failOnException (   self,
  what,
  ei = None 
) [inherited]

Definition at line 47 of file test_tempfile.py.

00047 
00048     def failOnException(self, what, ei=None):
00049         if ei is None:
00050             ei = sys.exc_info()
00051         self.fail("%s raised %s: %s" % (what, ei[0], ei[1]))

Here is the call graph for this function:

Here is the caller graph for this function:

def test.test_tempfile.TC.nameCheck (   self,
  name,
  dir,
  pre,
  suf 
) [inherited]

Definition at line 52 of file test_tempfile.py.

00052 
00053     def nameCheck(self, name, dir, pre, suf):
00054         (ndir, nbase) = os.path.split(name)
00055         npre  = nbase[:len(pre)]
00056         nsuf  = nbase[len(nbase)-len(suf):]
00057 
00058         # check for equality of the absolute paths!
00059         self.assertEqual(os.path.abspath(ndir), os.path.abspath(dir),
00060                          "file '%s' not in directory '%s'" % (name, dir))
00061         self.assertEqual(npre, pre,
00062                          "file '%s' does not begin with '%s'" % (nbase, pre))
00063         self.assertEqual(nsuf, suf,
00064                          "file '%s' does not end with '%s'" % (nbase, suf))
00065 
00066         nbase = nbase[len(pre):len(nbase)-len(suf)]
00067         self.assertTrue(self.str_check.match(nbase),
00068                      "random string '%s' does not match /^[a-zA-Z0-9_-]{6}$/"
00069                      % nbase)

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented from test.test_tempfile.TC.

Definition at line 507 of file test_tempfile.py.

00507 
00508     def setUp(self):
00509         self.dir = tempfile.mkdtemp()
00510         super().setUp()

Here is the caller graph for this function:

Reimplemented from test.test_tempfile.TC.

Definition at line 511 of file test_tempfile.py.

00511 
00512     def tearDown(self):
00513         if self.dir:
00514             os.rmdir(self.dir)
00515             self.dir = None
00516         super().tearDown()

Here is the caller graph for this function:

Definition at line 539 of file test_tempfile.py.

00539 
00540     def test_basic(self):
00541         # mktemp can choose usable file names
00542         self.do_create()
00543         self.do_create(pre="a")
00544         self.do_create(suf="b")
00545         self.do_create(pre="a", suf="b")
00546         self.do_create(pre="aa", suf=".txt")

Here is the call graph for this function:

Definition at line 547 of file test_tempfile.py.

00547 
00548     def test_many(self):
00549         # mktemp can choose many usable file names (stochastic)
00550         extant = list(range(TEST_FILES))
00551         for i in extant:
00552             extant[i] = self.do_create(pre="aa")

Here is the call graph for this function:


Member Data Documentation

Definition at line 508 of file test_tempfile.py.

tuple test.test_tempfile.TC.str_check = re.compile(r"[a-zA-Z0-9_-]{6}$") [static, inherited]

Definition at line 35 of file test_tempfile.py.


The documentation for this class was generated from the following file: