Back to index

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

List of all members.

Public Member Functions

def setUp
def tearDown
def create_distribution
def test_command_packages_unspecified
def test_command_packages_cmdline
def test_command_packages_configfile
def test_empty_options
def test_finalize_options
def test_get_command_packages
def test_announce
def get_logs
def clear_logs

Public Attributes

 argv
 threshold
 logs
_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 41 of file test_dist.py.


Member Function Documentation

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:

Definition at line 53 of file test_dist.py.

00053 
00054     def create_distribution(self, configfiles=()):
00055         d = TestDistribution()
00056         d._config_files = configfiles
00057         d.parse_config_files()
00058         d.parse_command_line()
00059         return d

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:

Reimplemented from distutils.tests.support.LoggingSilencer.

Definition at line 43 of file test_dist.py.

00043 
00044     def setUp(self):
00045         super(DistributionTestCase, self).setUp()
00046         self.argv = sys.argv, sys.argv[:]
00047         del sys.argv[1:]

Here is the caller graph for this function:

Reimplemented from distutils.tests.support.LoggingSilencer.

Definition at line 48 of file test_dist.py.

00048 
00049     def tearDown(self):
00050         sys.argv = self.argv[0]
00051         sys.argv[:] = self.argv[1]
00052         super(DistributionTestCase, self).tearDown()

Here is the caller graph for this function:

Definition at line 154 of file test_dist.py.

00154 
00155     def test_announce(self):
00156         # make sure the level is known
00157         dist = Distribution()
00158         args = ('ok',)
00159         kwargs = {'level': 'ok2'}
00160         self.assertRaises(ValueError, dist.announce, args, kwargs)

Here is the call graph for this function:

Definition at line 65 of file test_dist.py.

00065 
00066     def test_command_packages_cmdline(self):
00067         from distutils.tests.test_dist import test_dist
00068         sys.argv.extend(["--command-packages",
00069                          "foo.bar,distutils.tests",
00070                          "test_dist",
00071                          "-Ssometext",
00072                          ])
00073         d = self.create_distribution()
00074         # let's actually try to load our test command:
00075         self.assertEqual(d.get_command_packages(),
00076                          ["distutils.command", "foo.bar", "distutils.tests"])
00077         cmd = d.get_command_obj("test_dist")
00078         self.assertTrue(isinstance(cmd, test_dist))
00079         self.assertEqual(cmd.sample_option, "sometext")

Here is the call graph for this function:

Definition at line 80 of file test_dist.py.

00080 
00081     def test_command_packages_configfile(self):
00082         sys.argv.append("build")
00083         self.addCleanup(os.unlink, TESTFN)
00084         f = open(TESTFN, "w")
00085         try:
00086             print("[global]", file=f)
00087             print("command_packages = foo.bar, splat", file=f)
00088         finally:
00089             f.close()
00090 
00091         d = self.create_distribution([TESTFN])
00092         self.assertEqual(d.get_command_packages(),
00093                          ["distutils.command", "foo.bar", "splat"])
00094 
00095         # ensure command line overrides config:
00096         sys.argv[1:] = ["--command-packages", "spork", "build"]
00097         d = self.create_distribution([TESTFN])
00098         self.assertEqual(d.get_command_packages(),
00099                          ["distutils.command", "spork"])
00100 
00101         # Setting --command-packages to '' should cause the default to
00102         # be used even if a config file specified something else:
00103         sys.argv[1:] = ["--command-packages", "", "build"]
00104         d = self.create_distribution([TESTFN])
00105         self.assertEqual(d.get_command_packages(), ["distutils.command"])

Here is the call graph for this function:

Definition at line 60 of file test_dist.py.

00060 
00061     def test_command_packages_unspecified(self):
00062         sys.argv.append("build")
00063         d = self.create_distribution()
00064         self.assertEqual(d.get_command_packages(), ["distutils.command"])

Here is the call graph for this function:

Definition at line 106 of file test_dist.py.

00106 
00107     def test_empty_options(self):
00108         # an empty options dictionary should not stay in the
00109         # list of attributes
00110         klass = Distribution
00111 
00112         # catching warnings
00113         warns = []
00114         def _warn(msg):
00115             warns.append(msg)
00116 
00117         old_warn = warnings.warn
00118         warnings.warn = _warn
00119         try:
00120             dist = klass(attrs={'author': 'xxx',
00121                                 'name': 'xxx',
00122                                 'version': 'xxx',
00123                                 'url': 'xxxx',
00124                                 'options': {}})
00125         finally:
00126             warnings.warn = old_warn
00127 
00128         self.assertEqual(len(warns), 0)

Here is the call graph for this function:

Definition at line 129 of file test_dist.py.

00129 
00130     def test_finalize_options(self):
00131 
00132         attrs = {'keywords': 'one,two',
00133                  'platforms': 'one,two'}
00134 
00135         dist = Distribution(attrs=attrs)
00136         dist.finalize_options()
00137 
00138         # finalize_option splits platforms and keywords
00139         self.assertEqual(dist.metadata.platforms, ['one', 'two'])
00140         self.assertEqual(dist.metadata.keywords, ['one', 'two'])

Here is the call graph for this function:

Definition at line 141 of file test_dist.py.

00141 
00142     def test_get_command_packages(self):
00143         dist = Distribution()
00144         self.assertEqual(dist.command_packages, None)
00145         cmds = dist.get_command_packages()
00146         self.assertEqual(cmds, ['distutils.command'])
00147         self.assertEqual(dist.command_packages,
00148                          ['distutils.command'])
00149 
00150         dist.command_packages = 'one,two'
00151         cmds = dist.get_command_packages()
00152         self.assertEqual(cmds, ['distutils.command', 'one', 'two'])
00153 

Here is the call graph for this function:


Member Data Documentation

Definition at line 45 of file test_dist.py.

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

Definition at line 19 of file support.py.


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