Back to index

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

List of all members.

Public Member Functions

def setUp
def tearDown
def test_simple_metadata
def test_provides
def test_provides_illegal
def test_requires
def test_requires_illegal
def test_obsoletes
def test_obsoletes_illegal
def format_metadata
def test_custom_pydistutils
def test_fix_help_options
def test_show_help
def test_long_description
def mkdtemp
def write_file
def create_dist

Public Attributes

 argv
 old_cwd
 tempdirs
_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type
 old_environ
_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type

Detailed Description

Definition at line 162 of file test_dist.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:

Definition at line 247 of file test_dist.py.

00247 
00248     def format_metadata(self, dist):
00249         sio = io.StringIO()
00250         dist.metadata.write_pkg_file(sio)
00251         return sio.getvalue()

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 164 of file test_dist.py.

00164 
00165     def setUp(self):
00166         super(MetadataTestCase, self).setUp()
00167         self.argv = sys.argv, sys.argv[:]

Here is the caller graph for this function:

Reimplemented from distutils.tests.support.TempdirManager.

Definition at line 168 of file test_dist.py.

00168 
00169     def tearDown(self):
00170         sys.argv = self.argv[0]
00171         sys.argv[:] = self.argv[1]
00172         super(MetadataTestCase, self).tearDown()

Here is the caller graph for this function:

Definition at line 252 of file test_dist.py.

00252 
00253     def test_custom_pydistutils(self):
00254         # fixes #2166
00255         # make sure pydistutils.cfg is found
00256         if os.name == 'posix':
00257             user_filename = ".pydistutils.cfg"
00258         else:
00259             user_filename = "pydistutils.cfg"
00260 
00261         temp_dir = self.mkdtemp()
00262         user_filename = os.path.join(temp_dir, user_filename)
00263         f = open(user_filename, 'w')
00264         try:
00265             f.write('.')
00266         finally:
00267             f.close()
00268 
00269         try:
00270             dist = Distribution()
00271 
00272             # linux-style
00273             if sys.platform in ('linux', 'darwin'):
00274                 os.environ['HOME'] = temp_dir
00275                 files = dist.find_config_files()
00276                 self.assertTrue(user_filename in files)
00277 
00278             # win32-style
00279             if sys.platform == 'win32':
00280                 # home drive should be found
00281                 os.environ['HOME'] = temp_dir
00282                 files = dist.find_config_files()
00283                 self.assertTrue(user_filename in files,
00284                              '%r not found in %r' % (user_filename, files))
00285         finally:
00286             os.remove(user_filename)

Here is the call graph for this function:

Definition at line 287 of file test_dist.py.

00287 
00288     def test_fix_help_options(self):
00289         help_tuples = [('a', 'b', 'c', 'd'), (1, 2, 3, 4)]
00290         fancy_options = fix_help_options(help_tuples)
00291         self.assertEqual(fancy_options[0], ('a', 'b', 'c'))
00292         self.assertEqual(fancy_options[1], (1, 2, 3))

Here is the call graph for this function:

Definition at line 306 of file test_dist.py.

00306 
00307     def test_long_description(self):
00308         long_desc = textwrap.dedent("""\
00309         example::
00310               We start here
00311             and continue here
00312           and end here.""")
00313         attrs = {"name": "package",
00314                  "version": "1.0",
00315                  "long_description": long_desc}
00316 
00317         dist = Distribution(attrs)
00318         meta = self.format_metadata(dist)
00319         meta = meta.replace('\n' + 8 * ' ', '\n')
00320         self.assertTrue(long_desc in meta)

Here is the call graph for this function:

Definition at line 225 of file test_dist.py.

00225 
00226     def test_obsoletes(self):
00227         attrs = {"name": "package",
00228                  "version": "1.0",
00229                  "obsoletes": ["other", "another (<1.0)"]}
00230         dist = Distribution(attrs)
00231         self.assertEqual(dist.metadata.get_obsoletes(),
00232                          ["other", "another (<1.0)"])
00233         self.assertEqual(dist.get_obsoletes(),
00234                          ["other", "another (<1.0)"])
00235         meta = self.format_metadata(dist)
00236         self.assertTrue("Metadata-Version: 1.1" in meta)
00237         self.assertTrue("provides:" not in meta.lower())
00238         self.assertTrue("requires:" not in meta.lower())
00239         self.assertTrue("Obsoletes: other" in meta)
00240         self.assertTrue("Obsoletes: another (<1.0)" in meta)

Here is the call graph for this function:

Definition at line 241 of file test_dist.py.

00241 
00242     def test_obsoletes_illegal(self):
00243         self.assertRaises(ValueError, Distribution,
00244                           {"name": "package",
00245                            "version": "1.0",
00246                            "obsoletes": ["my.pkg (splat)"]})

Here is the call graph for this function:

Definition at line 183 of file test_dist.py.

00183 
00184     def test_provides(self):
00185         attrs = {"name": "package",
00186                  "version": "1.0",
00187                  "provides": ["package", "package.sub"]}
00188         dist = Distribution(attrs)
00189         self.assertEqual(dist.metadata.get_provides(),
00190                          ["package", "package.sub"])
00191         self.assertEqual(dist.get_provides(),
00192                          ["package", "package.sub"])
00193         meta = self.format_metadata(dist)
00194         self.assertTrue("Metadata-Version: 1.1" in meta)
00195         self.assertTrue("requires:" not in meta.lower())
00196         self.assertTrue("obsoletes:" not in meta.lower())

Here is the call graph for this function:

Definition at line 197 of file test_dist.py.

00197 
00198     def test_provides_illegal(self):
00199         self.assertRaises(ValueError, Distribution,
00200                           {"name": "package",
00201                            "version": "1.0",
00202                            "provides": ["my.pkg (splat)"]})

Here is the call graph for this function:

Definition at line 203 of file test_dist.py.

00203 
00204     def test_requires(self):
00205         attrs = {"name": "package",
00206                  "version": "1.0",
00207                  "requires": ["other", "another (==1.0)"]}
00208         dist = Distribution(attrs)
00209         self.assertEqual(dist.metadata.get_requires(),
00210                          ["other", "another (==1.0)"])
00211         self.assertEqual(dist.get_requires(),
00212                          ["other", "another (==1.0)"])
00213         meta = self.format_metadata(dist)
00214         self.assertTrue("Metadata-Version: 1.1" in meta)
00215         self.assertTrue("provides:" not in meta.lower())
00216         self.assertTrue("Requires: other" in meta)
00217         self.assertTrue("Requires: another (==1.0)" in meta)
00218         self.assertTrue("obsoletes:" not in meta.lower())

Here is the call graph for this function:

Definition at line 219 of file test_dist.py.

00219 
00220     def test_requires_illegal(self):
00221         self.assertRaises(ValueError, Distribution,
00222                           {"name": "package",
00223                            "version": "1.0",
00224                            "requires": ["my.pkg (splat)"]})

Here is the call graph for this function:

Definition at line 293 of file test_dist.py.

00293 
00294     def test_show_help(self):
00295         # smoke test, just makes sure some help is displayed
00296         dist = Distribution()
00297         sys.argv = []
00298         dist.help = 1
00299         dist.script_name = 'setup.py'
00300         with captured_stdout() as s:
00301             dist.parse_command_line()
00302 
00303         output = [line for line in s.getvalue().split('\n')
00304                   if line.strip() != '']
00305         self.assertTrue(len(output) > 0)

Here is the call graph for this function:

Definition at line 173 of file test_dist.py.

00173 
00174     def test_simple_metadata(self):
00175         attrs = {"name": "package",
00176                  "version": "1.0"}
00177         dist = Distribution(attrs)
00178         meta = self.format_metadata(dist)
00179         self.assertTrue("Metadata-Version: 1.0" in meta)
00180         self.assertTrue("provides:" not in meta.lower())
00181         self.assertTrue("requires:" not in meta.lower())
00182         self.assertTrue("obsoletes:" not in meta.lower())

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 166 of file test_dist.py.

Definition at line 107 of file object.h.

Definition at line 107 of file object.h.

struct _typeobject* _object::ob_type [inherited]

Definition at line 108 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 125 of file support.py.

Definition at line 58 of file support.py.


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