Back to index

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

List of all members.

Public Member Functions

def setUp
def tearDown
def test_check_config_h
def test_get_versions
def test_get_msvcr
def mkdtemp
def write_file
def create_dist

Public Attributes

 version
 python_h
 old_get_config_h_filename
 old_find_executable
 old_popen
 old_cwd
 tempdirs
_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type

Private Member Functions

def _get_config_h_filename
def _find_executable

Private Attributes

 _exes

Detailed Description

Definition at line 30 of file test_cygwinccompiler.py.


Member Function Documentation

Definition at line 57 of file test_cygwinccompiler.py.

00057 
00058     def _find_executable(self, name):
00059         if name in self._exes:
00060             return name
00061         return None

Definition at line 54 of file test_cygwinccompiler.py.

00054 
00055     def _get_config_h_filename(self):
00056         return self.python_h

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

Definition at line 32 of file test_cygwinccompiler.py.

00032 
00033     def setUp(self):
00034         super(CygwinCCompilerTestCase, self).setUp()
00035         self.version = sys.version
00036         self.python_h = os.path.join(self.mkdtemp(), 'python.h')
00037         from distutils import sysconfig
00038         self.old_get_config_h_filename = sysconfig.get_config_h_filename
00039         sysconfig.get_config_h_filename = self._get_config_h_filename
00040         self.old_find_executable = cygwinccompiler.find_executable
00041         cygwinccompiler.find_executable = self._find_executable
00042         self._exes = {}
00043         self.old_popen = cygwinccompiler.Popen
00044         FakePopen.test_class = self
00045         cygwinccompiler.Popen = FakePopen

Here is the caller graph for this function:

Reimplemented from distutils.tests.support.TempdirManager.

Definition at line 46 of file test_cygwinccompiler.py.

00046 
00047     def tearDown(self):
00048         sys.version = self.version
00049         from distutils import sysconfig
00050         sysconfig.get_config_h_filename = self.old_get_config_h_filename
00051         cygwinccompiler.find_executable = self.old_find_executable
00052         cygwinccompiler.Popen = self.old_popen
00053         super(CygwinCCompilerTestCase, self).tearDown()

Here is the caller graph for this function:

Definition at line 62 of file test_cygwinccompiler.py.

00062 
00063     def test_check_config_h(self):
00064 
00065         # check_config_h looks for "GCC" in sys.version first
00066         # returns CONFIG_H_OK if found
00067         sys.version = ('2.6.1 (r261:67515, Dec  6 2008, 16:42:21) \n[GCC '
00068                        '4.0.1 (Apple Computer, Inc. build 5370)]')
00069 
00070         self.assertEqual(check_config_h()[0], CONFIG_H_OK)
00071 
00072         # then it tries to see if it can find "__GNUC__" in pyconfig.h
00073         sys.version = 'something without the *CC word'
00074 
00075         # if the file doesn't exist it returns  CONFIG_H_UNCERTAIN
00076         self.assertEqual(check_config_h()[0], CONFIG_H_UNCERTAIN)
00077 
00078         # if it exists but does not contain __GNUC__, it returns CONFIG_H_NOTOK
00079         self.write_file(self.python_h, 'xxx')
00080         self.assertEqual(check_config_h()[0], CONFIG_H_NOTOK)
00081 
00082         # and CONFIG_H_OK if __GNUC__ is found
00083         self.write_file(self.python_h, 'xxx __GNUC__ xxx')
00084         self.assertEqual(check_config_h()[0], CONFIG_H_OK)

Here is the call graph for this function:

Definition at line 119 of file test_cygwinccompiler.py.

00119 
00120     def test_get_msvcr(self):
00121 
00122         # none
00123         sys.version  = ('2.6.1 (r261:67515, Dec  6 2008, 16:42:21) '
00124                         '\n[GCC 4.0.1 (Apple Computer, Inc. build 5370)]')
00125         self.assertEqual(get_msvcr(), None)
00126 
00127         # MSVC 7.0
00128         sys.version = ('2.5.1 (r251:54863, Apr 18 2007, 08:51:08) '
00129                        '[MSC v.1300 32 bits (Intel)]')
00130         self.assertEqual(get_msvcr(), ['msvcr70'])
00131 
00132         # MSVC 7.1
00133         sys.version = ('2.5.1 (r251:54863, Apr 18 2007, 08:51:08) '
00134                        '[MSC v.1310 32 bits (Intel)]')
00135         self.assertEqual(get_msvcr(), ['msvcr71'])
00136 
00137         # VS2005 / MSVC 8.0
00138         sys.version = ('2.5.1 (r251:54863, Apr 18 2007, 08:51:08) '
00139                        '[MSC v.1400 32 bits (Intel)]')
00140         self.assertEqual(get_msvcr(), ['msvcr80'])
00141 
00142         # VS2008 / MSVC 9.0
00143         sys.version = ('2.5.1 (r251:54863, Apr 18 2007, 08:51:08) '
00144                        '[MSC v.1500 32 bits (Intel)]')
00145         self.assertEqual(get_msvcr(), ['msvcr90'])
00146 
00147         # unknown
00148         sys.version = ('2.5.1 (r251:54863, Apr 18 2007, 08:51:08) '
00149                        '[MSC v.1999 32 bits (Intel)]')
00150         self.assertRaises(ValueError, get_msvcr)

Here is the call graph for this function:

Definition at line 85 of file test_cygwinccompiler.py.

00085 
00086     def test_get_versions(self):
00087 
00088         # get_versions calls distutils.spawn.find_executable on
00089         # 'gcc', 'ld' and 'dllwrap'
00090         self.assertEqual(get_versions(), (None, None, None))
00091 
00092         # Let's fake we have 'gcc' and it returns '3.4.5'
00093         self._exes['gcc'] = b'gcc (GCC) 3.4.5 (mingw special)\nFSF'
00094         res = get_versions()
00095         self.assertEqual(str(res[0]), '3.4.5')
00096 
00097         # and let's see what happens when the version
00098         # doesn't match the regular expression
00099         # (\d+\.\d+(\.\d+)*)
00100         self._exes['gcc'] = b'very strange output'
00101         res = get_versions()
00102         self.assertEqual(res[0], None)
00103 
00104         # same thing for ld
00105         self._exes['ld'] = b'GNU ld version 2.17.50 20060824'
00106         res = get_versions()
00107         self.assertEqual(str(res[1]), '2.17.50')
00108         self._exes['ld'] = b'@(#)PROGRAM:ld  PROJECT:ld64-77'
00109         res = get_versions()
00110         self.assertEqual(res[1], None)
00111 
00112         # and dllwrap
00113         self._exes['dllwrap'] = b'GNU dllwrap 2.17.50 20060824\nFSF'
00114         res = get_versions()
00115         self.assertEqual(str(res[2]), '2.17.50')
00116         self._exes['dllwrap'] = b'Cheese Wrap'
00117         res = get_versions()
00118         self.assertEqual(res[2], None)

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 41 of file test_cygwinccompiler.py.

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 39 of file test_cygwinccompiler.py.

Definition at line 37 of file test_cygwinccompiler.py.

Definition at line 42 of file test_cygwinccompiler.py.

Definition at line 35 of file test_cygwinccompiler.py.

Definition at line 58 of file support.py.

Definition at line 34 of file test_cygwinccompiler.py.


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