Back to index

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

List of all members.

Public Member Functions

def setUp
def tearDown
def test_finalize_options
def test_saved_password
def test_upload
def test_server_registration
def test_server_empty_registration
def mkdtemp
def write_file
def create_dist
def get_logs
def clear_logs

Public Attributes

 old_class
 conn
 tmp_dir
 rc
 dist
 old_threshold
 old_cwd
 tempdirs
_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type
struct _typeobjectob_type
struct _typeobjectob_type
 threshold
 logs
 old_environ

Detailed Description

Definition at line 71 of file test_upload.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:

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:

Patches the environment.

Reimplemented from distutils.tests.test_config.PyPIRCCommandTestCase.

Definition at line 73 of file test_upload.py.

00073 
00074     def setUp(self):
00075         super(uploadTestCase, self).setUp()
00076         self.old_class = httpclient.HTTPConnection
00077         self.conn = httpclient.HTTPConnection = FakeConnection()

Here is the caller graph for this function:

Removes the patch.

Reimplemented from distutils.tests.test_config.PyPIRCCommandTestCase.

Definition at line 78 of file test_upload.py.

00078 
00079     def tearDown(self):
00080         httpclient.HTTPConnection = self.old_class
00081         super(uploadTestCase, self).tearDown()

Here is the caller graph for this function:

Definition at line 82 of file test_upload.py.

00082 
00083     def test_finalize_options(self):
00084 
00085         # new format
00086         self.write_file(self.rc, PYPIRC)
00087         dist = Distribution()
00088         cmd = upload(dist)
00089         cmd.finalize_options()
00090         for attr, waited in (('username', 'me'), ('password', 'secret'),
00091                              ('realm', 'pypi'),
00092                              ('repository', 'http://pypi.python.org/pypi')):
00093             self.assertEqual(getattr(cmd, attr), waited)

Here is the call graph for this function:

Definition at line 94 of file test_upload.py.

00094 
00095     def test_saved_password(self):
00096         # file with no password
00097         self.write_file(self.rc, PYPIRC_NOPASSWORD)
00098 
00099         # make sure it passes
00100         dist = Distribution()
00101         cmd = upload(dist)
00102         cmd.finalize_options()
00103         self.assertEqual(cmd.password, None)
00104 
00105         # make sure we get it as well, if another command
00106         # initialized it at the dist level
00107         dist.password = 'xxx'
00108         cmd = upload(dist)
00109         cmd.finalize_options()
00110         self.assertEqual(cmd.password, 'xxx')

Here is the call graph for this function:

Definition at line 103 of file test_config.py.

00103 
00104     def test_server_empty_registration(self):
00105         cmd = self._cmd(self.dist)
00106         rc = cmd._get_rc_file()
00107         self.assertTrue(not os.path.exists(rc))
00108         cmd._store_pypirc('tarek', 'xxx')
00109         self.assertTrue(os.path.exists(rc))
00110         f = open(rc)
00111         try:
00112             content = f.read()
00113             self.assertEqual(content, WANTED)
00114         finally:
00115             f.close()

Here is the call graph for this function:

Definition at line 78 of file test_config.py.

00078 
00079     def test_server_registration(self):
00080         # This test makes sure PyPIRCCommand knows how to:
00081         # 1. handle several sections in .pypirc
00082         # 2. handle the old format
00083 
00084         # new format
00085         self.write_file(self.rc, PYPIRC)
00086         cmd = self._cmd(self.dist)
00087         config = cmd._read_pypirc()
00088 
00089         config = list(sorted(config.items()))
00090         waited = [('password', 'secret'), ('realm', 'pypi'),
00091                   ('repository', 'http://pypi.python.org/pypi'),
00092                   ('server', 'server1'), ('username', 'me')]
00093         self.assertEqual(config, waited)
00094 
00095         # old format
00096         self.write_file(self.rc, PYPIRC_OLD)
00097         config = cmd._read_pypirc()
00098         config = list(sorted(config.items()))
00099         waited = [('password', 'secret'), ('realm', 'pypi'),
00100                   ('repository', 'http://pypi.python.org/pypi'),
00101                   ('server', 'server-login'), ('username', 'tarek')]
00102         self.assertEqual(config, waited)

Here is the call graph for this function:

Definition at line 111 of file test_upload.py.

00111 
00112     def test_upload(self):
00113         tmp = self.mkdtemp()
00114         path = os.path.join(tmp, 'xxx')
00115         self.write_file(path)
00116         command, pyversion, filename = 'xxx', '2.6', path
00117         dist_files = [(command, pyversion, filename)]
00118         self.write_file(self.rc, PYPIRC_LONG_PASSWORD)
00119 
00120         # lets run it
00121         pkg_dir, dist = self.create_dist(dist_files=dist_files)
00122         cmd = upload(dist)
00123         cmd.ensure_finalized()
00124         cmd.run()
00125 
00126         # what did we send ?
00127         headers = dict(self.conn.headers)
00128         self.assertEqual(headers['Content-length'], '2087')
00129         self.assertTrue(headers['Content-type'].startswith('multipart/form-data'))
00130         self.assertFalse('\n' in headers['Authorization'])
00131 
00132         self.assertEqual(self.conn.requests, [('POST', '/pypi')])
00133         self.assertTrue((b'xxx') in self.conn.body)

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 76 of file test_upload.py.

Definition at line 61 of file test_config.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.

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.

struct _typeobject* _object::ob_type [inherited]

Definition at line 108 of file object.h.

Definition at line 75 of file test_upload.py.

Definition at line 57 of file support.py.

Definition at line 125 of file support.py.

Definition at line 71 of file test_config.py.

Definition at line 60 of file test_config.py.

Definition at line 58 of file support.py.

Definition at line 19 of file support.py.

Definition at line 58 of file test_config.py.


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