Back to index

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

List of all members.

Public Member Functions

def setUp
def tearDown
def test_dump_file
def test_search_cpp
def test_finalize_options
def test_clean
def get_logs
def clear_logs
def mkdtemp
def write_file
def create_dist

Public Attributes

 old_log
 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 _info

Private Attributes

 _logs

Detailed Description

Definition at line 13 of file test_config_cmd.py.


Member Function Documentation

def distutils.tests.test_config_cmd.ConfigTestCase._info (   self,
  msg,
  args 
) [private]

Definition at line 15 of file test_config_cmd.py.

00015 
00016     def _info(self, msg, *args):
00017         for line in msg.splitlines():
00018             self._logs.append(line)

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 from distutils.tests.support.LoggingSilencer.

Definition at line 19 of file test_config_cmd.py.

00019 
00020     def setUp(self):
00021         super(ConfigTestCase, self).setUp()
00022         self._logs = []
00023         self.old_log = log.info
00024         log.info = self._info

Here is the caller graph for this function:

Reimplemented from distutils.tests.support.LoggingSilencer.

Definition at line 25 of file test_config_cmd.py.

00025 
00026     def tearDown(self):
00027         log.info = self.old_log
00028         super(ConfigTestCase, self).tearDown()

Here is the caller graph for this function:

Definition at line 67 of file test_config_cmd.py.

00067 
00068     def test_clean(self):
00069         # _clean removes files
00070         tmp_dir = self.mkdtemp()
00071         f1 = os.path.join(tmp_dir, 'one')
00072         f2 = os.path.join(tmp_dir, 'two')
00073 
00074         self.write_file(f1, 'xxx')
00075         self.write_file(f2, 'xxx')
00076 
00077         for f in (f1, f2):
00078             self.assertTrue(os.path.exists(f))
00079 
00080         pkg_dir, dist = self.create_dist()
00081         cmd = config(dist)
00082         cmd._clean(f1, f2)
00083 
00084         for f in (f1, f2):
00085             self.assertTrue(not os.path.exists(f))

Here is the call graph for this function:

Definition at line 29 of file test_config_cmd.py.

00029 
00030     def test_dump_file(self):
00031         this_file = os.path.splitext(__file__)[0] + '.py'
00032         f = open(this_file)
00033         try:
00034             numlines = len(f.readlines())
00035         finally:
00036             f.close()
00037 
00038         dump_file(this_file, 'I am the header')
00039         self.assertEqual(len(self._logs), numlines+1)

Here is the call graph for this function:

Definition at line 53 of file test_config_cmd.py.

00053 
00054     def test_finalize_options(self):
00055         # finalize_options does a bit of transformation
00056         # on options
00057         pkg_dir, dist = self.create_dist()
00058         cmd = config(dist)
00059         cmd.include_dirs = 'one%stwo' % os.pathsep
00060         cmd.libraries = 'one'
00061         cmd.library_dirs = 'three%sfour' % os.pathsep
00062         cmd.ensure_finalized()
00063 
00064         self.assertEqual(cmd.include_dirs, ['one', 'two'])
00065         self.assertEqual(cmd.libraries, ['one'])
00066         self.assertEqual(cmd.library_dirs, ['three', 'four'])

Here is the call graph for this function:

Definition at line 40 of file test_config_cmd.py.

00040 
00041     def test_search_cpp(self):
00042         if sys.platform == 'win32':
00043             return
00044         pkg_dir, dist = self.create_dist()
00045         cmd = config(dist)
00046 
00047         # simple pattern searches
00048         match = cmd.search_cpp(pattern='xxx', body='// xxx')
00049         self.assertEqual(match, 0)
00050 
00051         match = cmd.search_cpp(pattern='_configtest', body='// xxx')
00052         self.assertEqual(match, 1)

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

Definition at line 22 of file test_config_cmd.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: