Back to index

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

List of all members.

Public Member Functions

def test_check_metadata
def test_check_document
def test_check_restructuredtext
def test_check_all
def setUp
def tearDown
def get_logs
def clear_logs
def setUp
def tearDown
def mkdtemp
def write_file
def create_dist

Public Attributes

 threshold
 logs
_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type
 old_cwd
 tempdirs
_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type

Private Member Functions

def _run

Detailed Description

Definition at line 11 of file test_check.py.


Member Function Documentation

def distutils.tests.test_check.CheckTestCase._run (   self,
  metadata = None,
  options 
) [private]

Definition at line 13 of file test_check.py.

00013 
00014     def _run(self, metadata=None, **options):
00015         if metadata is None:
00016             metadata = {}
00017         pkg_info, dist = self.create_dist(**metadata)
00018         cmd = check(dist)
00019         cmd.initialize_options()
00020         for name, value in options.items():
00021             setattr(cmd, name, value)
00022         cmd.ensure_finalized()
00023         cmd.run()
00024         return cmd

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 45 of file support.py.

00045 
00046     def clear_logs(self):
00047         self.logs = []
00048 

Here is the caller graph for this function:

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:

def distutils.tests.support.LoggingSilencer.get_logs (   self,
  levels 
) [inherited]

Definition at line 37 of file support.py.

00037 
00038     def get_logs(self, *levels):
00039         def _format(msg, args):
00040             if len(args) == 0:
00041                 return msg
00042             return msg % args
00043         return [_format(msg, args) for level, msg, args
00044                 in self.logs if level in levels]

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_upload.uploadTestCase, distutils.tests.test_register.RegisterTestCase, distutils.tests.test_config.PyPIRCCommandTestCase, distutils.tests.test_sdist.SDistTestCase, distutils.tests.test_dist.DistributionTestCase, distutils.tests.test_bdist_dumb.BuildDumbTestCase, distutils.tests.test_bdist_rpm.BuildRpmTestCase, and distutils.tests.test_config_cmd.ConfigTestCase.

Definition at line 17 of file support.py.

00017 
00018     def setUp(self):
00019         super().setUp()
00020         self.threshold = log.set_threshold(log.FATAL)
00021         # catching warnings
00022         # when log will be replaced by logging
00023         # we won't need such monkey-patch anymore
00024         self._old_log = log.Log._log
00025         log.Log._log = self._log
00026         self.logs = []

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 88 of file test_check.py.

00088 
00089     def test_check_all(self):
00090 
00091         metadata = {'url': 'xxx', 'author': 'xxx'}
00092         self.assertRaises(DistutilsSetupError, self._run,
00093                           {}, **{'strict': 1,
00094                                  'restructuredtext': 1})

Here is the call graph for this function:

Definition at line 49 of file test_check.py.

00049 
00050     def test_check_document(self):
00051         if not HAS_DOCUTILS: # won't test without docutils
00052             return
00053         pkg_info, dist = self.create_dist()
00054         cmd = check(dist)
00055 
00056         # let's see if it detects broken rest
00057         broken_rest = 'title\n===\n\ntest'
00058         msgs = cmd._check_rst_data(broken_rest)
00059         self.assertEqual(len(msgs), 1)
00060 
00061         # and non-broken rest
00062         rest = 'title\n=====\n\ntest'
00063         msgs = cmd._check_rst_data(rest)
00064         self.assertEqual(len(msgs), 0)

Here is the call graph for this function:

Definition at line 25 of file test_check.py.

00025 
00026     def test_check_metadata(self):
00027         # let's run the command with no metadata at all
00028         # by default, check is checking the metadata
00029         # should have some warnings
00030         cmd = self._run()
00031         self.assertEqual(cmd._warnings, 2)
00032 
00033         # now let's add the required fields
00034         # and run it again, to make sure we don't get
00035         # any warning anymore
00036         metadata = {'url': 'xxx', 'author': 'xxx',
00037                     'author_email': 'xxx',
00038                     'name': 'xxx', 'version': 'xxx'}
00039         cmd = self._run(metadata)
00040         self.assertEqual(cmd._warnings, 0)
00041 
00042         # now with the strict mode, we should
00043         # get an error if there are missing metadata
00044         self.assertRaises(DistutilsSetupError, self._run, {}, **{'strict': 1})
00045 
00046         # and of course, no error when all metadata are present
00047         cmd = self._run(metadata, strict=1)
00048         self.assertEqual(cmd._warnings, 0)

Here is the call graph for this function:

Definition at line 65 of file test_check.py.

00065 
00066     def test_check_restructuredtext(self):
00067         if not HAS_DOCUTILS: # won't test without docutils
00068             return
00069         # let's see if it detects broken rest in long_description
00070         broken_rest = 'title\n===\n\ntest'
00071         pkg_info, dist = self.create_dist(long_description=broken_rest)
00072         cmd = check(dist)
00073         cmd.check_restructuredtext()
00074         self.assertEqual(cmd._warnings, 1)
00075 
00076         # let's see if we have an error with strict=1
00077         metadata = {'url': 'xxx', 'author': 'xxx',
00078                     'author_email': 'xxx',
00079                     'name': 'xxx', 'version': 'xxx',
00080                     'long_description': broken_rest}
00081         self.assertRaises(DistutilsSetupError, self._run, metadata,
00082                           **{'strict': 1, 'restructuredtext': 1})
00083 
00084         # and non-broken rest
00085         metadata['long_description'] = 'title\n=====\n\ntest'
00086         cmd = self._run(metadata, strict=1, restructuredtext=1)
00087         self.assertEqual(cmd._warnings, 0)

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

Definition at line 19 of file support.py.


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