587
|
1 |
#============================================================================
|
|
2 |
#Name : test_misc.py
|
|
3 |
#Part of : Helium
|
|
4 |
|
|
5 |
#Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
6 |
#All rights reserved.
|
|
7 |
#This component and the accompanying materials are made available
|
|
8 |
#under the terms of the License "Eclipse Public License v1.0"
|
|
9 |
#which accompanies this distribution, and is available
|
|
10 |
#at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
11 |
#
|
|
12 |
#Initial Contributors:
|
|
13 |
#Nokia Corporation - initial contribution.
|
|
14 |
#
|
|
15 |
#Contributors:
|
|
16 |
#
|
|
17 |
#Description:
|
|
18 |
#===============================================================================
|
|
19 |
|
|
20 |
""" Miscellaneous tests.
|
|
21 |
|
|
22 |
"""
|
|
23 |
|
|
24 |
|
|
25 |
def test_optparse_import():
|
|
26 |
"""Ensure 'optparse' module is not imported from within docutils.
|
|
27 |
|
|
28 |
Docutils, as of docutils-0.5 at least, comes bundled with a version of the
|
|
29 |
`optparse` module that is older than what comes with Python 2.4 standard
|
|
30 |
library.
|
|
31 |
|
|
32 |
This test, although implemented in a slightly unpythonic manner (thinking
|
|
33 |
pythonically, we should only care about a module's behaviour, not its
|
|
34 |
version), checks that the `optparse` module acquired without any import
|
|
35 |
magic is not the old buggy one from within docutils.
|
|
36 |
|
|
37 |
"""
|
|
38 |
import optparse
|
|
39 |
assert "docutils" not in optparse.__file__
|
|
40 |
|
|
41 |
def test_optparse_help():
|
|
42 |
"""Test for this issue:
|
|
43 |
SF #960515: don't crash when generating help for callback
|
|
44 |
options that specify 'type', but not 'dest' or 'metavar'.from
|
|
45 |
http://sourceforge.net/project/shownotes.php?release_id=278548&group_id=38019
|
|
46 |
"""
|
|
47 |
|
|
48 |
import optparse
|
|
49 |
|
628
|
50 |
# pylint: disable=W0613
|
588
|
51 |
|
587
|
52 |
def testCallback(option, opt, value, parser):
|
588
|
53 |
"""test Call back"""
|
587
|
54 |
pass
|
|
55 |
|
|
56 |
parser = optparse.OptionParser()
|
|
57 |
parser.add_option("--x", help="x", callback=testCallback, action="callback", type="string", default=True)
|
|
58 |
parser.print_help()
|