Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
7f41b88b
Kaydet (Commit)
7f41b88b
authored
Ock 30, 2011
tarafından
Steven Bethard
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#10680: fix mutually exclusive arguments in argument groups.
üst
53c460d5
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
0 deletions
+41
-0
argparse.py
Lib/argparse.py
+1
-0
test_argparse.py
Lib/test/test_argparse.py
+40
-0
No files found.
Lib/argparse.py
Dosyayı görüntüle @
7f41b88b
...
@@ -1482,6 +1482,7 @@ class _ArgumentGroup(_ActionsContainer):
...
@@ -1482,6 +1482,7 @@ class _ArgumentGroup(_ActionsContainer):
self
.
_defaults
=
container
.
_defaults
self
.
_defaults
=
container
.
_defaults
self
.
_has_negative_number_optionals
=
\
self
.
_has_negative_number_optionals
=
\
container
.
_has_negative_number_optionals
container
.
_has_negative_number_optionals
self
.
_mutually_exclusive_groups
=
container
.
_mutually_exclusive_groups
def
_add_action
(
self
,
action
):
def
_add_action
(
self
,
action
):
action
=
super
(
_ArgumentGroup
,
self
)
.
_add_action
(
action
)
action
=
super
(
_ArgumentGroup
,
self
)
.
_add_action
(
action
)
...
...
Lib/test/test_argparse.py
Dosyayı görüntüle @
7f41b88b
...
@@ -2505,6 +2505,46 @@ class TestMutuallyExclusiveOptionalsMixed(MEMixin, TestCase):
...
@@ -2505,6 +2505,46 @@ class TestMutuallyExclusiveOptionalsMixed(MEMixin, TestCase):
'''
'''
class
TestMutuallyExclusiveInGroup
(
MEMixin
,
TestCase
):
def
get_parser
(
self
,
required
=
None
):
parser
=
ErrorRaisingArgumentParser
(
prog
=
'PROG'
)
titled_group
=
parser
.
add_argument_group
(
title
=
'Titled group'
,
description
=
'Group description'
)
mutex_group
=
\
titled_group
.
add_mutually_exclusive_group
(
required
=
required
)
mutex_group
.
add_argument
(
'--bar'
,
help
=
'bar help'
)
mutex_group
.
add_argument
(
'--baz'
,
help
=
'baz help'
)
return
parser
failures
=
[
'--bar X --baz Y'
,
'--baz X --bar Y'
]
successes
=
[
(
'--bar X'
,
NS
(
bar
=
'X'
,
baz
=
None
)),
(
'--baz Y'
,
NS
(
bar
=
None
,
baz
=
'Y'
)),
]
successes_when_not_required
=
[
(
''
,
NS
(
bar
=
None
,
baz
=
None
)),
]
usage_when_not_required
=
'''
\
usage: PROG [-h] [--bar BAR | --baz BAZ]
'''
usage_when_required
=
'''
\
usage: PROG [-h] (--bar BAR | --baz BAZ)
'''
help
=
'''
\
optional arguments:
-h, --help show this help message and exit
Titled group:
Group description
--bar BAR bar help
--baz BAZ baz help
'''
class
TestMutuallyExclusiveOptionalsAndPositionalsMixed
(
MEMixin
,
TestCase
):
class
TestMutuallyExclusiveOptionalsAndPositionalsMixed
(
MEMixin
,
TestCase
):
def
get_parser
(
self
,
required
):
def
get_parser
(
self
,
required
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment