~ubuntu-branches/ubuntu/maverick/python3.1/maverick

« back to all changes in this revision

Viewing changes to Lib/distutils/tests/test_upload.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2009-03-23 00:01:27 UTC
  • Revision ID: james.westby@ubuntu.com-20090323000127-5fstfxju4ufrhthq
Tags: upstream-3.1~a1+20090322
ImportĀ upstreamĀ versionĀ 3.1~a1+20090322

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
"""Tests for distutils.command.upload."""
 
2
import sys
 
3
import os
 
4
import unittest
 
5
 
 
6
from distutils.command.upload import upload
 
7
from distutils.core import Distribution
 
8
 
 
9
from distutils.tests import support
 
10
from distutils.tests.test_config import PYPIRC, PyPIRCCommandTestCase
 
11
 
 
12
PYPIRC_NOPASSWORD = """\
 
13
[distutils]
 
14
 
 
15
index-servers =
 
16
    server1
 
17
 
 
18
[server1]
 
19
username:me
 
20
"""
 
21
 
 
22
 
 
23
class uploadTestCase(PyPIRCCommandTestCase):
 
24
 
 
25
    def test_finalize_options(self):
 
26
 
 
27
        # new format
 
28
        f = open(self.rc, 'w')
 
29
        f.write(PYPIRC)
 
30
        f.close()
 
31
 
 
32
        dist = Distribution()
 
33
        cmd = upload(dist)
 
34
        cmd.finalize_options()
 
35
        for attr, waited in (('username', 'me'), ('password', 'secret'),
 
36
                             ('realm', 'pypi'),
 
37
                             ('repository', 'http://pypi.python.org/pypi')):
 
38
            self.assertEquals(getattr(cmd, attr), waited)
 
39
 
 
40
    def test_saved_password(self):
 
41
        # file with no password
 
42
        f = open(self.rc, 'w')
 
43
        f.write(PYPIRC_NOPASSWORD)
 
44
        f.close()
 
45
 
 
46
        # make sure it passes
 
47
        dist = Distribution()
 
48
        cmd = upload(dist)
 
49
        cmd.finalize_options()
 
50
        self.assertEquals(cmd.password, None)
 
51
 
 
52
        # make sure we get it as well, if another command
 
53
        # initialized it at the dist level
 
54
        dist.password = 'xxx'
 
55
        cmd = upload(dist)
 
56
        cmd.finalize_options()
 
57
        self.assertEquals(cmd.password, 'xxx')
 
58
 
 
59
def test_suite():
 
60
    return unittest.makeSuite(uploadTestCase)
 
61
 
 
62
if __name__ == "__main__":
 
63
    unittest.main(defaultTest="test_suite")