Mercurial > cpython-lru_cache-weakref
annotate Lib/distutils/tests/test_dist.py @ 54294:dba767bc3155 legacy-trunk
remove mention of old ctypes version
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Sat, 23 May 2009 20:59:09 +0000 |
| parents | f2538183d262 |
| children | d5071d9f7408 |
| rev | line source |
|---|---|
|
48981
4c683ec4415b
Issue #2562: Fix distutils PKG-INFO writing logic to allow having
Marc-André Lemburg <mal@egenix.com>
parents:
46902
diff
changeset
|
1 # -*- coding: latin-1 -*- |
|
4c683ec4415b
Issue #2562: Fix distutils PKG-INFO writing logic to allow having
Marc-André Lemburg <mal@egenix.com>
parents:
46902
diff
changeset
|
2 |
|
32938
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
3 """Tests for distutils.dist.""" |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
4 import os |
|
34785
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
5 import StringIO |
|
32938
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
6 import sys |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
7 import unittest |
|
50366
ad20b69b18b7
Merged revisions 68033 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
48981
diff
changeset
|
8 import warnings |
|
32938
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
9 |
|
54149
f2538183d262
removed sys.platform == 'mac' support in distutils.dist.parse_command_line and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53980
diff
changeset
|
10 from distutils.dist import Distribution, fix_help_options |
|
f2538183d262
removed sys.platform == 'mac' support in distutils.dist.parse_command_line and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53980
diff
changeset
|
11 from distutils.cmd import Command |
|
f2538183d262
removed sys.platform == 'mac' support in distutils.dist.parse_command_line and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53980
diff
changeset
|
12 |
|
f2538183d262
removed sys.platform == 'mac' support in distutils.dist.parse_command_line and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53980
diff
changeset
|
13 from test.test_support import TESTFN, captured_stdout |
|
51626
e5522875b98c
Fix for #5257: refactored all tests in distutils, so they use a temporary directory.
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
50366
diff
changeset
|
14 from distutils.tests import support |
|
32938
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
15 |
|
54149
f2538183d262
removed sys.platform == 'mac' support in distutils.dist.parse_command_line and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53980
diff
changeset
|
16 class test_dist(Command): |
|
32938
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
17 """Sample distutils extension command.""" |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
18 |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
19 user_options = [ |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
20 ("sample-option=", "S", "help text"), |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
21 ] |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
22 |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
23 def initialize_options(self): |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
24 self.sample_option = None |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
25 |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
26 |
|
54149
f2538183d262
removed sys.platform == 'mac' support in distutils.dist.parse_command_line and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53980
diff
changeset
|
27 class TestDistribution(Distribution): |
|
32938
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
28 """Distribution subclasses that avoids the default search for |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
29 configuration files. |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
30 |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
31 The ._config_files attribute must be set before |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
32 .parse_config_files() is called. |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
33 """ |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
34 |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
35 def find_config_files(self): |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
36 return self._config_files |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
37 |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
38 |
|
51626
e5522875b98c
Fix for #5257: refactored all tests in distutils, so they use a temporary directory.
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
50366
diff
changeset
|
39 class DistributionTestCase(support.TempdirManager, unittest.TestCase): |
|
32938
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
40 |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
41 def setUp(self): |
|
53980
17c53fa37890
now using EnvironGuard everywhere
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51627
diff
changeset
|
42 super(DistributionTestCase, self).setUp() |
|
32938
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
43 self.argv = sys.argv[:] |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
44 del sys.argv[1:] |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
45 |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
46 def tearDown(self): |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
47 sys.argv[:] = self.argv |
|
53980
17c53fa37890
now using EnvironGuard everywhere
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51627
diff
changeset
|
48 super(DistributionTestCase, self).tearDown() |
|
32938
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
49 |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
50 def create_distribution(self, configfiles=()): |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
51 d = TestDistribution() |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
52 d._config_files = configfiles |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
53 d.parse_config_files() |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
54 d.parse_command_line() |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
55 return d |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
56 |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
57 def test_command_packages_unspecified(self): |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
58 sys.argv.append("build") |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
59 d = self.create_distribution() |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
60 self.assertEqual(d.get_command_packages(), ["distutils.command"]) |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
61 |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
62 def test_command_packages_cmdline(self): |
|
46881
0df616193b98
#1858: re-apply patch for this, adding the missing files
Andrew M. Kuchling <amk@amk.ca>
parents:
46836
diff
changeset
|
63 from distutils.tests.test_dist import test_dist |
|
32938
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
64 sys.argv.extend(["--command-packages", |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
65 "foo.bar,distutils.tests", |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
66 "test_dist", |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
67 "-Ssometext", |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
68 ]) |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
69 d = self.create_distribution() |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
70 # let's actually try to load our test command: |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
71 self.assertEqual(d.get_command_packages(), |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
72 ["distutils.command", "foo.bar", "distutils.tests"]) |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
73 cmd = d.get_command_obj("test_dist") |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
74 self.assert_(isinstance(cmd, test_dist)) |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
75 self.assertEqual(cmd.sample_option, "sometext") |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
76 |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
77 def test_command_packages_configfile(self): |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
78 sys.argv.append("build") |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
79 f = open(TESTFN, "w") |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
80 try: |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
81 print >>f, "[global]" |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
82 print >>f, "command_packages = foo.bar, splat" |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
83 f.close() |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
84 d = self.create_distribution([TESTFN]) |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
85 self.assertEqual(d.get_command_packages(), |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
86 ["distutils.command", "foo.bar", "splat"]) |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
87 |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
88 # ensure command line overrides config: |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
89 sys.argv[1:] = ["--command-packages", "spork", "build"] |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
90 d = self.create_distribution([TESTFN]) |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
91 self.assertEqual(d.get_command_packages(), |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
92 ["distutils.command", "spork"]) |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
93 |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
94 # Setting --command-packages to '' should cause the default to |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
95 # be used even if a config file specified something else: |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
96 sys.argv[1:] = ["--command-packages", "", "build"] |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
97 d = self.create_distribution([TESTFN]) |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
98 self.assertEqual(d.get_command_packages(), ["distutils.command"]) |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
99 |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
100 finally: |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
101 os.unlink(TESTFN) |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
102 |
|
48981
4c683ec4415b
Issue #2562: Fix distutils PKG-INFO writing logic to allow having
Marc-André Lemburg <mal@egenix.com>
parents:
46902
diff
changeset
|
103 def test_write_pkg_file(self): |
|
4c683ec4415b
Issue #2562: Fix distutils PKG-INFO writing logic to allow having
Marc-André Lemburg <mal@egenix.com>
parents:
46902
diff
changeset
|
104 # Check DistributionMetadata handling of Unicode fields |
|
51626
e5522875b98c
Fix for #5257: refactored all tests in distutils, so they use a temporary directory.
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
50366
diff
changeset
|
105 tmp_dir = self.mkdtemp() |
|
e5522875b98c
Fix for #5257: refactored all tests in distutils, so they use a temporary directory.
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
50366
diff
changeset
|
106 my_file = os.path.join(tmp_dir, 'f') |
|
54149
f2538183d262
removed sys.platform == 'mac' support in distutils.dist.parse_command_line and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53980
diff
changeset
|
107 klass = Distribution |
|
48981
4c683ec4415b
Issue #2562: Fix distutils PKG-INFO writing logic to allow having
Marc-André Lemburg <mal@egenix.com>
parents:
46902
diff
changeset
|
108 |
|
4c683ec4415b
Issue #2562: Fix distutils PKG-INFO writing logic to allow having
Marc-André Lemburg <mal@egenix.com>
parents:
46902
diff
changeset
|
109 dist = klass(attrs={'author': u'Mister Café', |
|
4c683ec4415b
Issue #2562: Fix distutils PKG-INFO writing logic to allow having
Marc-André Lemburg <mal@egenix.com>
parents:
46902
diff
changeset
|
110 'name': 'my.package', |
|
4c683ec4415b
Issue #2562: Fix distutils PKG-INFO writing logic to allow having
Marc-André Lemburg <mal@egenix.com>
parents:
46902
diff
changeset
|
111 'maintainer': u'Café Junior', |
|
4c683ec4415b
Issue #2562: Fix distutils PKG-INFO writing logic to allow having
Marc-André Lemburg <mal@egenix.com>
parents:
46902
diff
changeset
|
112 'description': u'Café torréfié', |
|
4c683ec4415b
Issue #2562: Fix distutils PKG-INFO writing logic to allow having
Marc-André Lemburg <mal@egenix.com>
parents:
46902
diff
changeset
|
113 'long_description': u'Héhéhé'}) |
|
4c683ec4415b
Issue #2562: Fix distutils PKG-INFO writing logic to allow having
Marc-André Lemburg <mal@egenix.com>
parents:
46902
diff
changeset
|
114 |
|
4c683ec4415b
Issue #2562: Fix distutils PKG-INFO writing logic to allow having
Marc-André Lemburg <mal@egenix.com>
parents:
46902
diff
changeset
|
115 |
|
4c683ec4415b
Issue #2562: Fix distutils PKG-INFO writing logic to allow having
Marc-André Lemburg <mal@egenix.com>
parents:
46902
diff
changeset
|
116 # let's make sure the file can be written |
|
4c683ec4415b
Issue #2562: Fix distutils PKG-INFO writing logic to allow having
Marc-André Lemburg <mal@egenix.com>
parents:
46902
diff
changeset
|
117 # with Unicode fields. they are encoded with |
|
4c683ec4415b
Issue #2562: Fix distutils PKG-INFO writing logic to allow having
Marc-André Lemburg <mal@egenix.com>
parents:
46902
diff
changeset
|
118 # PKG_INFO_ENCODING |
|
51626
e5522875b98c
Fix for #5257: refactored all tests in distutils, so they use a temporary directory.
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
50366
diff
changeset
|
119 dist.metadata.write_pkg_file(open(my_file, 'w')) |
|
48981
4c683ec4415b
Issue #2562: Fix distutils PKG-INFO writing logic to allow having
Marc-André Lemburg <mal@egenix.com>
parents:
46902
diff
changeset
|
120 |
|
4c683ec4415b
Issue #2562: Fix distutils PKG-INFO writing logic to allow having
Marc-André Lemburg <mal@egenix.com>
parents:
46902
diff
changeset
|
121 # regular ascii is of course always usable |
|
4c683ec4415b
Issue #2562: Fix distutils PKG-INFO writing logic to allow having
Marc-André Lemburg <mal@egenix.com>
parents:
46902
diff
changeset
|
122 dist = klass(attrs={'author': 'Mister Cafe', |
|
4c683ec4415b
Issue #2562: Fix distutils PKG-INFO writing logic to allow having
Marc-André Lemburg <mal@egenix.com>
parents:
46902
diff
changeset
|
123 'name': 'my.package', |
|
4c683ec4415b
Issue #2562: Fix distutils PKG-INFO writing logic to allow having
Marc-André Lemburg <mal@egenix.com>
parents:
46902
diff
changeset
|
124 'maintainer': 'Cafe Junior', |
|
4c683ec4415b
Issue #2562: Fix distutils PKG-INFO writing logic to allow having
Marc-André Lemburg <mal@egenix.com>
parents:
46902
diff
changeset
|
125 'description': 'Cafe torrefie', |
|
4c683ec4415b
Issue #2562: Fix distutils PKG-INFO writing logic to allow having
Marc-André Lemburg <mal@egenix.com>
parents:
46902
diff
changeset
|
126 'long_description': 'Hehehe'}) |
|
4c683ec4415b
Issue #2562: Fix distutils PKG-INFO writing logic to allow having
Marc-André Lemburg <mal@egenix.com>
parents:
46902
diff
changeset
|
127 |
|
51626
e5522875b98c
Fix for #5257: refactored all tests in distutils, so they use a temporary directory.
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
50366
diff
changeset
|
128 my_file2 = os.path.join(tmp_dir, 'f2') |
|
e5522875b98c
Fix for #5257: refactored all tests in distutils, so they use a temporary directory.
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
50366
diff
changeset
|
129 dist.metadata.write_pkg_file(open(my_file, 'w')) |
|
32938
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
130 |
|
50366
ad20b69b18b7
Merged revisions 68033 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
48981
diff
changeset
|
131 def test_empty_options(self): |
|
ad20b69b18b7
Merged revisions 68033 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
48981
diff
changeset
|
132 # an empty options dictionary should not stay in the |
|
ad20b69b18b7
Merged revisions 68033 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
48981
diff
changeset
|
133 # list of attributes |
|
54149
f2538183d262
removed sys.platform == 'mac' support in distutils.dist.parse_command_line and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53980
diff
changeset
|
134 klass = Distribution |
|
50366
ad20b69b18b7
Merged revisions 68033 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
48981
diff
changeset
|
135 |
|
ad20b69b18b7
Merged revisions 68033 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
48981
diff
changeset
|
136 # catching warnings |
|
ad20b69b18b7
Merged revisions 68033 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
48981
diff
changeset
|
137 warns = [] |
|
ad20b69b18b7
Merged revisions 68033 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
48981
diff
changeset
|
138 def _warn(msg): |
|
ad20b69b18b7
Merged revisions 68033 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
48981
diff
changeset
|
139 warns.append(msg) |
|
ad20b69b18b7
Merged revisions 68033 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
48981
diff
changeset
|
140 |
|
ad20b69b18b7
Merged revisions 68033 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
48981
diff
changeset
|
141 old_warn = warnings.warn |
|
ad20b69b18b7
Merged revisions 68033 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
48981
diff
changeset
|
142 warnings.warn = _warn |
|
ad20b69b18b7
Merged revisions 68033 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
48981
diff
changeset
|
143 try: |
|
ad20b69b18b7
Merged revisions 68033 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
48981
diff
changeset
|
144 dist = klass(attrs={'author': 'xxx', |
|
ad20b69b18b7
Merged revisions 68033 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
48981
diff
changeset
|
145 'name': 'xxx', |
|
ad20b69b18b7
Merged revisions 68033 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
48981
diff
changeset
|
146 'version': 'xxx', |
|
ad20b69b18b7
Merged revisions 68033 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
48981
diff
changeset
|
147 'url': 'xxxx', |
|
ad20b69b18b7
Merged revisions 68033 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
48981
diff
changeset
|
148 'options': {}}) |
|
ad20b69b18b7
Merged revisions 68033 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
48981
diff
changeset
|
149 finally: |
|
ad20b69b18b7
Merged revisions 68033 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
48981
diff
changeset
|
150 warnings.warn = old_warn |
|
ad20b69b18b7
Merged revisions 68033 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
48981
diff
changeset
|
151 |
|
ad20b69b18b7
Merged revisions 68033 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
48981
diff
changeset
|
152 self.assertEquals(len(warns), 0) |
|
ad20b69b18b7
Merged revisions 68033 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
48981
diff
changeset
|
153 |
|
53980
17c53fa37890
now using EnvironGuard everywhere
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51627
diff
changeset
|
154 class MetadataTestCase(support.TempdirManager, support.EnvironGuard, |
|
17c53fa37890
now using EnvironGuard everywhere
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51627
diff
changeset
|
155 unittest.TestCase): |
|
34785
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
156 |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
157 def test_simple_metadata(self): |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
158 attrs = {"name": "package", |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
159 "version": "1.0"} |
|
54149
f2538183d262
removed sys.platform == 'mac' support in distutils.dist.parse_command_line and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53980
diff
changeset
|
160 dist = Distribution(attrs) |
|
34785
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
161 meta = self.format_metadata(dist) |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
162 self.assert_("Metadata-Version: 1.0" in meta) |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
163 self.assert_("provides:" not in meta.lower()) |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
164 self.assert_("requires:" not in meta.lower()) |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
165 self.assert_("obsoletes:" not in meta.lower()) |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
166 |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
167 def test_provides(self): |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
168 attrs = {"name": "package", |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
169 "version": "1.0", |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
170 "provides": ["package", "package.sub"]} |
|
54149
f2538183d262
removed sys.platform == 'mac' support in distutils.dist.parse_command_line and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53980
diff
changeset
|
171 dist = Distribution(attrs) |
|
34785
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
172 self.assertEqual(dist.metadata.get_provides(), |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
173 ["package", "package.sub"]) |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
174 self.assertEqual(dist.get_provides(), |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
175 ["package", "package.sub"]) |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
176 meta = self.format_metadata(dist) |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
177 self.assert_("Metadata-Version: 1.1" in meta) |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
178 self.assert_("requires:" not in meta.lower()) |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
179 self.assert_("obsoletes:" not in meta.lower()) |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
180 |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
181 def test_provides_illegal(self): |
|
54149
f2538183d262
removed sys.platform == 'mac' support in distutils.dist.parse_command_line and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53980
diff
changeset
|
182 self.assertRaises(ValueError, Distribution, |
|
34785
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
183 {"name": "package", |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
184 "version": "1.0", |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
185 "provides": ["my.pkg (splat)"]}) |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
186 |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
187 def test_requires(self): |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
188 attrs = {"name": "package", |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
189 "version": "1.0", |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
190 "requires": ["other", "another (==1.0)"]} |
|
54149
f2538183d262
removed sys.platform == 'mac' support in distutils.dist.parse_command_line and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53980
diff
changeset
|
191 dist = Distribution(attrs) |
|
34785
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
192 self.assertEqual(dist.metadata.get_requires(), |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
193 ["other", "another (==1.0)"]) |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
194 self.assertEqual(dist.get_requires(), |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
195 ["other", "another (==1.0)"]) |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
196 meta = self.format_metadata(dist) |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
197 self.assert_("Metadata-Version: 1.1" in meta) |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
198 self.assert_("provides:" not in meta.lower()) |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
199 self.assert_("Requires: other" in meta) |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
200 self.assert_("Requires: another (==1.0)" in meta) |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
201 self.assert_("obsoletes:" not in meta.lower()) |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
202 |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
203 def test_requires_illegal(self): |
|
54149
f2538183d262
removed sys.platform == 'mac' support in distutils.dist.parse_command_line and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53980
diff
changeset
|
204 self.assertRaises(ValueError, Distribution, |
|
34785
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
205 {"name": "package", |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
206 "version": "1.0", |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
207 "requires": ["my.pkg (splat)"]}) |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
208 |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
209 def test_obsoletes(self): |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
210 attrs = {"name": "package", |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
211 "version": "1.0", |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
212 "obsoletes": ["other", "another (<1.0)"]} |
|
54149
f2538183d262
removed sys.platform == 'mac' support in distutils.dist.parse_command_line and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53980
diff
changeset
|
213 dist = Distribution(attrs) |
|
34785
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
214 self.assertEqual(dist.metadata.get_obsoletes(), |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
215 ["other", "another (<1.0)"]) |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
216 self.assertEqual(dist.get_obsoletes(), |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
217 ["other", "another (<1.0)"]) |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
218 meta = self.format_metadata(dist) |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
219 self.assert_("Metadata-Version: 1.1" in meta) |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
220 self.assert_("provides:" not in meta.lower()) |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
221 self.assert_("requires:" not in meta.lower()) |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
222 self.assert_("Obsoletes: other" in meta) |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
223 self.assert_("Obsoletes: another (<1.0)" in meta) |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
224 |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
225 def test_obsoletes_illegal(self): |
|
54149
f2538183d262
removed sys.platform == 'mac' support in distutils.dist.parse_command_line and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53980
diff
changeset
|
226 self.assertRaises(ValueError, Distribution, |
|
34785
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
227 {"name": "package", |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
228 "version": "1.0", |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
229 "obsoletes": ["my.pkg (splat)"]}) |
|
34818
4eaab38566c9
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
34785
diff
changeset
|
230 |
|
34785
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
231 def format_metadata(self, dist): |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
232 sio = StringIO.StringIO() |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
233 dist.metadata.write_pkg_file(sio) |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
234 return sio.getvalue() |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
235 |
|
46881
0df616193b98
#1858: re-apply patch for this, adding the missing files
Andrew M. Kuchling <amk@amk.ca>
parents:
46836
diff
changeset
|
236 def test_custom_pydistutils(self): |
|
0df616193b98
#1858: re-apply patch for this, adding the missing files
Andrew M. Kuchling <amk@amk.ca>
parents:
46836
diff
changeset
|
237 # fixes #2166 |
|
0df616193b98
#1858: re-apply patch for this, adding the missing files
Andrew M. Kuchling <amk@amk.ca>
parents:
46836
diff
changeset
|
238 # make sure pydistutils.cfg is found |
|
0df616193b98
#1858: re-apply patch for this, adding the missing files
Andrew M. Kuchling <amk@amk.ca>
parents:
46836
diff
changeset
|
239 if os.name == 'posix': |
|
0df616193b98
#1858: re-apply patch for this, adding the missing files
Andrew M. Kuchling <amk@amk.ca>
parents:
46836
diff
changeset
|
240 user_filename = ".pydistutils.cfg" |
|
0df616193b98
#1858: re-apply patch for this, adding the missing files
Andrew M. Kuchling <amk@amk.ca>
parents:
46836
diff
changeset
|
241 else: |
|
0df616193b98
#1858: re-apply patch for this, adding the missing files
Andrew M. Kuchling <amk@amk.ca>
parents:
46836
diff
changeset
|
242 user_filename = "pydistutils.cfg" |
|
0df616193b98
#1858: re-apply patch for this, adding the missing files
Andrew M. Kuchling <amk@amk.ca>
parents:
46836
diff
changeset
|
243 |
|
51626
e5522875b98c
Fix for #5257: refactored all tests in distutils, so they use a temporary directory.
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
50366
diff
changeset
|
244 temp_dir = self.mkdtemp() |
|
e5522875b98c
Fix for #5257: refactored all tests in distutils, so they use a temporary directory.
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
50366
diff
changeset
|
245 user_filename = os.path.join(temp_dir, user_filename) |
|
46881
0df616193b98
#1858: re-apply patch for this, adding the missing files
Andrew M. Kuchling <amk@amk.ca>
parents:
46836
diff
changeset
|
246 f = open(user_filename, 'w') |
|
0df616193b98
#1858: re-apply patch for this, adding the missing files
Andrew M. Kuchling <amk@amk.ca>
parents:
46836
diff
changeset
|
247 f.write('.') |
|
0df616193b98
#1858: re-apply patch for this, adding the missing files
Andrew M. Kuchling <amk@amk.ca>
parents:
46836
diff
changeset
|
248 f.close() |
|
0df616193b98
#1858: re-apply patch for this, adding the missing files
Andrew M. Kuchling <amk@amk.ca>
parents:
46836
diff
changeset
|
249 |
|
0df616193b98
#1858: re-apply patch for this, adding the missing files
Andrew M. Kuchling <amk@amk.ca>
parents:
46836
diff
changeset
|
250 try: |
|
54149
f2538183d262
removed sys.platform == 'mac' support in distutils.dist.parse_command_line and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53980
diff
changeset
|
251 dist = Distribution() |
|
46881
0df616193b98
#1858: re-apply patch for this, adding the missing files
Andrew M. Kuchling <amk@amk.ca>
parents:
46836
diff
changeset
|
252 |
|
0df616193b98
#1858: re-apply patch for this, adding the missing files
Andrew M. Kuchling <amk@amk.ca>
parents:
46836
diff
changeset
|
253 # linux-style |
|
0df616193b98
#1858: re-apply patch for this, adding the missing files
Andrew M. Kuchling <amk@amk.ca>
parents:
46836
diff
changeset
|
254 if sys.platform in ('linux', 'darwin'): |
|
53980
17c53fa37890
now using EnvironGuard everywhere
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51627
diff
changeset
|
255 self.environ['HOME'] = temp_dir |
|
46881
0df616193b98
#1858: re-apply patch for this, adding the missing files
Andrew M. Kuchling <amk@amk.ca>
parents:
46836
diff
changeset
|
256 files = dist.find_config_files() |
|
0df616193b98
#1858: re-apply patch for this, adding the missing files
Andrew M. Kuchling <amk@amk.ca>
parents:
46836
diff
changeset
|
257 self.assert_(user_filename in files) |
|
0df616193b98
#1858: re-apply patch for this, adding the missing files
Andrew M. Kuchling <amk@amk.ca>
parents:
46836
diff
changeset
|
258 |
|
0df616193b98
#1858: re-apply patch for this, adding the missing files
Andrew M. Kuchling <amk@amk.ca>
parents:
46836
diff
changeset
|
259 # win32-style |
|
0df616193b98
#1858: re-apply patch for this, adding the missing files
Andrew M. Kuchling <amk@amk.ca>
parents:
46836
diff
changeset
|
260 if sys.platform == 'win32': |
|
0df616193b98
#1858: re-apply patch for this, adding the missing files
Andrew M. Kuchling <amk@amk.ca>
parents:
46836
diff
changeset
|
261 # home drive should be found |
|
53980
17c53fa37890
now using EnvironGuard everywhere
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51627
diff
changeset
|
262 self.environ['HOME'] = temp_dir |
|
46881
0df616193b98
#1858: re-apply patch for this, adding the missing files
Andrew M. Kuchling <amk@amk.ca>
parents:
46836
diff
changeset
|
263 files = dist.find_config_files() |
|
46896
21ae2b65bbbb
Add message to test assertion
Andrew M. Kuchling <amk@amk.ca>
parents:
46881
diff
changeset
|
264 self.assert_(user_filename in files, |
|
21ae2b65bbbb
Add message to test assertion
Andrew M. Kuchling <amk@amk.ca>
parents:
46881
diff
changeset
|
265 '%r not found in %r' % (user_filename, files)) |
|
46881
0df616193b98
#1858: re-apply patch for this, adding the missing files
Andrew M. Kuchling <amk@amk.ca>
parents:
46836
diff
changeset
|
266 finally: |
|
0df616193b98
#1858: re-apply patch for this, adding the missing files
Andrew M. Kuchling <amk@amk.ca>
parents:
46836
diff
changeset
|
267 os.remove(user_filename) |
|
34785
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
268 |
|
54149
f2538183d262
removed sys.platform == 'mac' support in distutils.dist.parse_command_line and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53980
diff
changeset
|
269 def test_fix_help_options(self): |
|
f2538183d262
removed sys.platform == 'mac' support in distutils.dist.parse_command_line and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53980
diff
changeset
|
270 help_tuples = [('a', 'b', 'c', 'd'), (1, 2, 3, 4)] |
|
f2538183d262
removed sys.platform == 'mac' support in distutils.dist.parse_command_line and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53980
diff
changeset
|
271 fancy_options = fix_help_options(help_tuples) |
|
f2538183d262
removed sys.platform == 'mac' support in distutils.dist.parse_command_line and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53980
diff
changeset
|
272 self.assertEquals(fancy_options[0], ('a', 'b', 'c')) |
|
f2538183d262
removed sys.platform == 'mac' support in distutils.dist.parse_command_line and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53980
diff
changeset
|
273 self.assertEquals(fancy_options[1], (1, 2, 3)) |
|
f2538183d262
removed sys.platform == 'mac' support in distutils.dist.parse_command_line and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53980
diff
changeset
|
274 |
|
f2538183d262
removed sys.platform == 'mac' support in distutils.dist.parse_command_line and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53980
diff
changeset
|
275 def test_show_help(self): |
|
f2538183d262
removed sys.platform == 'mac' support in distutils.dist.parse_command_line and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53980
diff
changeset
|
276 # smoke test, just makes sure some help is displayed |
|
f2538183d262
removed sys.platform == 'mac' support in distutils.dist.parse_command_line and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53980
diff
changeset
|
277 dist = Distribution() |
|
f2538183d262
removed sys.platform == 'mac' support in distutils.dist.parse_command_line and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53980
diff
changeset
|
278 old_argv = sys.argv |
|
f2538183d262
removed sys.platform == 'mac' support in distutils.dist.parse_command_line and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53980
diff
changeset
|
279 sys.argv = [] |
|
f2538183d262
removed sys.platform == 'mac' support in distutils.dist.parse_command_line and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53980
diff
changeset
|
280 try: |
|
f2538183d262
removed sys.platform == 'mac' support in distutils.dist.parse_command_line and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53980
diff
changeset
|
281 dist.help = 1 |
|
f2538183d262
removed sys.platform == 'mac' support in distutils.dist.parse_command_line and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53980
diff
changeset
|
282 dist.script_name = 'setup.py' |
|
f2538183d262
removed sys.platform == 'mac' support in distutils.dist.parse_command_line and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53980
diff
changeset
|
283 with captured_stdout() as s: |
|
f2538183d262
removed sys.platform == 'mac' support in distutils.dist.parse_command_line and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53980
diff
changeset
|
284 dist.parse_command_line() |
|
f2538183d262
removed sys.platform == 'mac' support in distutils.dist.parse_command_line and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53980
diff
changeset
|
285 finally: |
|
f2538183d262
removed sys.platform == 'mac' support in distutils.dist.parse_command_line and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53980
diff
changeset
|
286 sys.argv = old_argv |
|
f2538183d262
removed sys.platform == 'mac' support in distutils.dist.parse_command_line and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53980
diff
changeset
|
287 |
|
f2538183d262
removed sys.platform == 'mac' support in distutils.dist.parse_command_line and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53980
diff
changeset
|
288 output = [line for line in s.getvalue().split('\n') |
|
f2538183d262
removed sys.platform == 'mac' support in distutils.dist.parse_command_line and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53980
diff
changeset
|
289 if line.strip() != ''] |
|
f2538183d262
removed sys.platform == 'mac' support in distutils.dist.parse_command_line and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53980
diff
changeset
|
290 self.assert_(len(output) > 0) |
|
f2538183d262
removed sys.platform == 'mac' support in distutils.dist.parse_command_line and improved test coverage
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
53980
diff
changeset
|
291 |
|
32938
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
292 def test_suite(): |
|
34785
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
293 suite = unittest.TestSuite() |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
294 suite.addTest(unittest.makeSuite(DistributionTestCase)) |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
295 suite.addTest(unittest.makeSuite(MetadataTestCase)) |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
32938
diff
changeset
|
296 return suite |
|
46881
0df616193b98
#1858: re-apply patch for this, adding the missing files
Andrew M. Kuchling <amk@amk.ca>
parents:
46836
diff
changeset
|
297 |
|
0df616193b98
#1858: re-apply patch for this, adding the missing files
Andrew M. Kuchling <amk@amk.ca>
parents:
46836
diff
changeset
|
298 if __name__ == "__main__": |
|
0df616193b98
#1858: re-apply patch for this, adding the missing files
Andrew M. Kuchling <amk@amk.ca>
parents:
46836
diff
changeset
|
299 unittest.main(defaultTest="test_suite") |
