Back to index

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

List of all members.

Public Member Functions

def setUp
def test_get_six_char_str
def test_many
def supports_iter
def tearDown
def failOnException
def nameCheck

Public Attributes

 r

Static Public Attributes

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

Detailed Description

Test the internal iterator object _RandomNameSequence.

Definition at line 102 of file test_tempfile.py.


Member Function Documentation

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 105 of file test_tempfile.py.

00105 
00106     def setUp(self):
00107         self.r = tempfile._RandomNameSequence()
00108         super().setUp()

Here is the caller graph for this function:

Definition at line 125 of file test_tempfile.py.

00125 
00126     def supports_iter(self):
00127         # _RandomNameSequence supports the iterator protocol
00128 
00129         i = 0
00130         r = self.r
00131         try:
00132             for s in r:
00133                 i += 1
00134                 if i == 20:
00135                     break
00136         except:
00137             self.failOnException("iteration")
00138 
00139 test_classes.append(test__RandomNameSequence)
00140 

Here is the call graph for this function:

def test.test_tempfile.TC.tearDown (   self) [inherited]

Reimplemented in test.test_tempfile.test_mktemp.

Definition at line 43 of file test_tempfile.py.

00043 
00044     def tearDown(self):
00045         self._warnings_manager.__exit__(None, None, None)
00046 

Here is the caller graph for this function:

Definition at line 109 of file test_tempfile.py.

00109 
00110     def test_get_six_char_str(self):
00111         # _RandomNameSequence returns a six-character string
00112         s = next(self.r)
00113         self.nameCheck(s, '', '', '')

Here is the call graph for this function:

Definition at line 114 of file test_tempfile.py.

00114 
00115     def test_many(self):
00116         # _RandomNameSequence returns no duplicate strings (stochastic)
00117 
00118         dict = {}
00119         r = self.r
00120         for i in range(TEST_FILES):
00121             s = next(r)
00122             self.nameCheck(s, '', '', '')
00123             self.assertNotIn(s, dict)
00124             dict[s] = 1

Here is the call graph for this function:


Member Data Documentation

Definition at line 106 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: