Back to index

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

List of all members.

Public Member Functions

def test_newer
def test_newer_pairwise
def test_newer_group
def setUp
def tearDown
def mkdtemp
def write_file
def create_dist

Public Attributes

 old_cwd
 tempdirs
_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type

Detailed Description

Definition at line 11 of file test_dep_util.py.


Member Function Documentation

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 in distutils.tests.test_dist.MetadataTestCase, distutils.tests.test_register.RegisterTestCase, distutils.tests.test_upload.uploadTestCase, distutils.tests.test_config.PyPIRCCommandTestCase, distutils.tests.test_sdist.SDistTestCase, distutils.tests.test_cygwinccompiler.CygwinCCompilerTestCase, distutils.tests.test_bdist_dumb.BuildDumbTestCase, distutils.tests.test_bdist_rpm.BuildRpmTestCase, distutils.tests.test_dir_util.DirUtilTestCase, distutils.tests.test_file_util.FileUtilTestCase, and distutils.tests.test_config_cmd.ConfigTestCase.

Definition at line 60 of file support.py.

00060 
00061     def tearDown(self):
00062         # Restore working dir, for Solaris and derivatives, where rmdir()
00063         # on the current directory fails.
00064         os.chdir(self.old_cwd)
00065         super().tearDown()
00066         while self.tempdirs:
00067             d = self.tempdirs.pop()
00068             shutil.rmtree(d, os.name in ('nt', 'cygwin'))

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 13 of file test_dep_util.py.

00013 
00014     def test_newer(self):
00015 
00016         tmpdir = self.mkdtemp()
00017         new_file = os.path.join(tmpdir, 'new')
00018         old_file = os.path.abspath(__file__)
00019 
00020         # Raise DistutilsFileError if 'new_file' does not exist.
00021         self.assertRaises(DistutilsFileError, newer, new_file, old_file)
00022 
00023         # Return true if 'new_file' exists and is more recently modified than
00024         # 'old_file', or if 'new_file' exists and 'old_file' doesn't.
00025         self.write_file(new_file)
00026         self.assertTrue(newer(new_file, 'I_dont_exist'))
00027         self.assertTrue(newer(new_file, old_file))
00028 
00029         # Return false if both exist and 'old_file' is the same age or younger
00030         # than 'new_file'.
00031         self.assertFalse(newer(old_file, new_file))

Here is the call graph for this function:

Definition at line 49 of file test_dep_util.py.

00049 
00050     def test_newer_group(self):
00051         tmpdir = self.mkdtemp()
00052         sources = os.path.join(tmpdir, 'sources')
00053         os.mkdir(sources)
00054         one = os.path.join(sources, 'one')
00055         two = os.path.join(sources, 'two')
00056         three = os.path.join(sources, 'three')
00057         old_file = os.path.abspath(__file__)
00058 
00059         # return true if 'old_file' is out-of-date with respect to any file
00060         # listed in 'sources'.
00061         self.write_file(one)
00062         self.write_file(two)
00063         self.write_file(three)
00064         self.assertTrue(newer_group([one, two, three], old_file))
00065         self.assertFalse(newer_group([one, two, old_file], three))
00066 
00067         # missing handling
00068         os.remove(one)
00069         self.assertRaises(OSError, newer_group, [one, two, old_file], three)
00070 
00071         self.assertFalse(newer_group([one, two, old_file], three,
00072                                      missing='ignore'))
00073 
00074         self.assertTrue(newer_group([one, two, old_file], three,
00075                                     missing='newer'))
00076 

Here is the call graph for this function:

Definition at line 32 of file test_dep_util.py.

00032 
00033     def test_newer_pairwise(self):
00034         tmpdir = self.mkdtemp()
00035         sources = os.path.join(tmpdir, 'sources')
00036         targets = os.path.join(tmpdir, 'targets')
00037         os.mkdir(sources)
00038         os.mkdir(targets)
00039         one = os.path.join(sources, 'one')
00040         two = os.path.join(sources, 'two')
00041         three = os.path.abspath(__file__)    # I am the old file
00042         four = os.path.join(targets, 'four')
00043         self.write_file(one)
00044         self.write_file(two)
00045         self.write_file(four)
00046 
00047         self.assertEqual(newer_pairwise([one, two], [three, four]),
00048                          ([one],[three]))

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 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 58 of file support.py.


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