Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Private Member Functions
CMFCore.tests.base.testcase.WritableFSDVTest Class Reference
Inheritance diagram for CMFCore.tests.base.testcase.WritableFSDVTest:
Inheritance graph
[legend]
Collaboration diagram for CMFCore.tests.base.testcase.WritableFSDVTest:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def setUp
def tearDown

Public Attributes

 tempname
 ob
 skin_path_name

Private Member Functions

def _writeFile
def _deleteFile
def _addedOrRemoved

Detailed Description

Definition at line 156 of file testcase.py.


Member Function Documentation

def CMFCore.tests.base.testcase.WritableFSDVTest._addedOrRemoved (   self,
  old_mtime 
) [private]

Definition at line 189 of file testcase.py.

00189 
00190     def _addedOrRemoved(self, old_mtime):
00191         # Called after adding/removing a file from self.skin_path_name.
00192 
00193         if sys.platform == 'win32':
00194             # Windows doesn't reliably update directory mod times, so
00195             # DirectoryView has an expensive workaround.  The
00196             # workaround does not rely on directory mod times.
00197             return
00198         limit = time.time() + 60  # If it takes 60 seconds, give up.
00199         new_mtime = old_mtime
00200         while new_mtime == old_mtime:
00201             # Many systems have a granularity of 1 second.
00202             # Add/remove a file until it actually changes the
00203             # directory mod time.
00204             if time.time() > limit:
00205                 raise RuntimeError(
00206                     "This platform (%s) does not update directory mod times "
00207                     "reliably." % sys.platform)
00208             time.sleep(0.1)
00209             fn = join(self.skin_path_name, '.touch')
00210             f = open(fn, 'w')
00211             f.write('Temporary file')
00212             f.close()
00213             remove(fn)
00214             new_mtime = stat(self.skin_path_name)[8]

Here is the caller graph for this function:

def CMFCore.tests.base.testcase.WritableFSDVTest._deleteFile (   self,
  filename 
) [private]

Definition at line 181 of file testcase.py.

00181 
00182     def _deleteFile(self,filename):
00183         try:
00184             dir_mtime = stat(self.skin_path_name)[8]
00185         except:  # XXX Why bare except?
00186             dir_mtime = 0
00187         remove(join(self.skin_path_name, filename))
00188         self._addedOrRemoved(dir_mtime)

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFCore.tests.base.testcase.WritableFSDVTest._writeFile (   self,
  filename,
  stuff 
) [private]

Definition at line 160 of file testcase.py.

00160 
00161     def _writeFile(self, filename, stuff):
00162         # write some stuff to a file on disk
00163         # make sure the file's modification time has changed
00164         # also make sure the skin folder mod time has changed
00165         try:
00166             dir_mtime = stat(self.skin_path_name)[8]
00167         except:  # XXX Why bare except?
00168             dir_mtime = 0
00169         thePath = join(self.skin_path_name,filename)
00170         try:
00171             mtime1 = stat(thePath)[8]
00172         except:  # XXX Why bare except?
00173             mtime1 = 0
00174         mtime2 = mtime1
00175         while mtime2==mtime1:
00176             f = open(thePath,'w')
00177             f.write(stuff)
00178             f.close()
00179             mtime2 = stat(thePath)[8]
00180         self._addedOrRemoved(dir_mtime)

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented from CMFCore.tests.base.testcase.FSDVTest.

Definition at line 215 of file testcase.py.

00215 
00216     def setUp(self):
00217         # store the place where the skin copy will be created
00218         self.tempname = mktemp(dir=getPackageLocation('Products.CMFCore.tests'))
00219         # create the temporary folder
00220         mkdir(self.tempname)
00221         # copy the source fake skin to the new location
00222         copytree(join(self._sourceprefix,
00223                       self._skinname),
00224                  join(self.tempname,
00225                       self._skinname))
00226         # make sure we have a writable copy
00227         for root, dirs, files in walk(self.tempname):
00228             for name in files:
00229                 chmod(join(root, name), S_IREAD+S_IWRITE)
00230         FSDVTest.setUp(self)

Reimplemented from CMFCore.tests.base.testcase.FSDVTest.

Definition at line 231 of file testcase.py.

00231 
00232     def tearDown(self):
00233         FSDVTest.tearDown(self)
00234         # kill the copy
00235         try:
00236             rmtree(self.tempname)
00237         except OSError:
00238             # try again (some files might be locked temporarily)
00239             time.sleep(0.1)
00240             rmtree(self.tempname)

Member Data Documentation

Definition at line 145 of file testcase.py.

Definition at line 150 of file testcase.py.

Reimplemented from CMFCore.tests.base.testcase.FSDVTest.

Definition at line 217 of file testcase.py.


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