Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
distutils.tests.test_file_util.FileUtilTestCase Class Reference
Inheritance diagram for distutils.tests.test_file_util.FileUtilTestCase:
Inheritance graph
[legend]
Collaboration diagram for distutils.tests.test_file_util.FileUtilTestCase:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def setUp
def tearDown
def test_move_file_verbosity
def mkdtemp
def write_file
def create_dist

Public Attributes

 old_log
 source
 target
 target_dir
 old_cwd
 tempdirs
_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type

Private Member Functions

def _log

Private Attributes

 _logs

Detailed Description

Definition at line 11 of file test_file_util.py.


Member Function Documentation

def distutils.tests.test_file_util.FileUtilTestCase._log (   self,
  msg,
  args 
) [private]

Definition at line 13 of file test_file_util.py.

00013 
00014     def _log(self, msg, *args):
00015         if len(args) > 0:
00016             self._logs.append(msg % args)
00017         else:
00018             self._logs.append(msg)

def distutils.tests.support.TempdirManager.create_dist (   self,
  pkg_name = 'foo',
  kw 
) [inherited]
Will generate a test environment.

This function creates:
 - a Distribution instance using keywords
 - a temporary directory with a package structure

It returns the package directory and the distribution
instance.

Definition at line 92 of file support.py.

00092 
00093     def create_dist(self, pkg_name='foo', **kw):
00094         """Will generate a test environment.
00095 
00096         This function creates:
00097          - a Distribution instance using keywords
00098          - a temporary directory with a package structure
00099 
00100         It returns the package directory and the distribution
00101         instance.
00102         """
00103         tmp_dir = self.mkdtemp()
00104         pkg_dir = os.path.join(tmp_dir, pkg_name)
00105         os.mkdir(pkg_dir)
00106         dist = Distribution(attrs=kw)
00107 
00108         return pkg_dir, dist
00109 

Here is the call graph for this function:

Here is the caller graph for this function:

Create a temporary directory that will be cleaned up.

Returns the path of the directory.

Definition at line 69 of file support.py.

00069 
00070     def mkdtemp(self):
00071         """Create a temporary directory that will be cleaned up.
00072 
00073         Returns the path of the directory.
00074         """
00075         d = tempfile.mkdtemp()
00076         self.tempdirs.append(d)
00077         return d

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented from distutils.tests.support.TempdirManager.

Definition at line 19 of file test_file_util.py.

00019 
00020     def setUp(self):
00021         super(FileUtilTestCase, self).setUp()
00022         self._logs = []
00023         self.old_log = log.info
00024         log.info = self._log
00025         tmp_dir = self.mkdtemp()
00026         self.source = os.path.join(tmp_dir, 'f1')
00027         self.target = os.path.join(tmp_dir, 'f2')
00028         self.target_dir = os.path.join(tmp_dir, 'd1')

Here is the caller graph for this function:

Reimplemented from distutils.tests.support.TempdirManager.

Definition at line 29 of file test_file_util.py.

00029 
00030     def tearDown(self):
00031         log.info = self.old_log
00032         super(FileUtilTestCase, self).tearDown()

Here is the caller graph for this function:

Definition at line 33 of file test_file_util.py.

00033 
00034     def test_move_file_verbosity(self):
00035         f = open(self.source, 'w')
00036         try:
00037             f.write('some content')
00038         finally:
00039             f.close()
00040 
00041         move_file(self.source, self.target, verbose=0)
00042         wanted = []
00043         self.assertEqual(self._logs, wanted)
00044 
00045         # back to original state
00046         move_file(self.target, self.source, verbose=0)
00047 
00048         move_file(self.source, self.target, verbose=1)
00049         wanted = ['moving %s -> %s' % (self.source, self.target)]
00050         self.assertEqual(self._logs, wanted)
00051 
00052         # back to original state
00053         move_file(self.target, self.source, verbose=0)
00054 
00055         self._logs = []
00056         # now the target is a dir
00057         os.mkdir(self.target_dir)
00058         move_file(self.source, self.target_dir, verbose=1)
00059         wanted = ['moving %s -> %s' % (self.source, self.target_dir)]
00060         self.assertEqual(self._logs, wanted)
00061 

Here is the call graph for this function:

def distutils.tests.support.TempdirManager.write_file (   self,
  path,
  content = 'xxx' 
) [inherited]
Writes a file in the given path.


path can be a string or a sequence.

Definition at line 78 of file support.py.

00078 
00079     def write_file(self, path, content='xxx'):
00080         """Writes a file in the given path.
00081 
00082 
00083         path can be a string or a sequence.
00084         """
00085         if isinstance(path, (list, tuple)):
00086             path = os.path.join(*path)
00087         f = open(path, 'w')
00088         try:
00089             f.write(content)
00090         finally:
00091             f.close()

Here is the caller graph for this function:


Member Data Documentation

Definition at line 21 of file test_file_util.py.

Definition at line 107 of file object.h.

struct _typeobject* _object::ob_type [inherited]

Definition at line 108 of file object.h.

Definition at line 57 of file support.py.

Definition at line 22 of file test_file_util.py.

Definition at line 25 of file test_file_util.py.

Definition at line 26 of file test_file_util.py.

Definition at line 27 of file test_file_util.py.

Definition at line 58 of file support.py.


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