Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
kamaki
Commits
02987e9c
Commit
02987e9c
authored
Jul 18, 2013
by
Stavros Sachtouris
Browse files
Test IntArgument
Refs: #4058
parent
3a5b1ceb
Changes
3
Hide whitespace changes
Inline
Side-by-side
kamaki/cli/argument/__init__.py
View file @
02987e9c
...
...
@@ -222,9 +222,6 @@ class IntArgument(ValueArgument):
@
value
.
setter
def
value
(
self
,
newvalue
):
if
newvalue
==
self
.
default
:
self
.
_value
=
self
.
default
return
try
:
self
.
_value
=
int
(
newvalue
)
except
ValueError
:
...
...
kamaki/cli/argument/test.py
View file @
02987e9c
...
...
@@ -34,9 +34,9 @@
from
mock
import
patch
,
call
from
unittest
import
TestCase
from
StringIO
import
StringIO
from
itertools
import
product
#
from itertools import product
from
kamaki.cli
import
argument
from
kamaki.cli
import
argument
,
errors
from
kamaki.cli.config
import
Config
...
...
@@ -212,6 +212,26 @@ class ValueArgument(TestCase):
arg
.
assert_called_once
(
1
,
help
,
pname
,
default
)
class
IntArgument
(
TestCase
):
def
test_value
(
self
):
ia
=
argument
.
IntArgument
(
parsed_name
=
'--ia'
)
self
.
assertEqual
(
ia
.
value
,
None
)
for
v
in
(
1
,
0
,
-
1
,
923455555555555555555555555555555
):
ia
.
value
=
v
self
.
assertEqual
(
ia
.
value
,
v
)
for
v
in
(
'1'
,
'-1'
,
2.8
):
ia
.
value
=
v
self
.
assertEqual
(
ia
.
value
,
int
(
v
))
for
v
,
err
in
(
(
'invalid'
,
errors
.
CLIError
),
(
None
,
TypeError
),
(
False
,
TypeError
),
([
1
,
2
,
3
],
TypeError
)):
try
:
ia
.
value
=
v
except
Exception
as
e
:
self
.
assertTrue
(
isinstance
(
e
,
err
))
if
__name__
==
'__main__'
:
from
sys
import
argv
from
kamaki.cli.test
import
runTestCase
...
...
@@ -220,3 +240,4 @@ if __name__ == '__main__':
runTestCase
(
RuntimeConfigArgument
,
'RuntimeConfigArgument'
,
argv
[
1
:])
runTestCase
(
FlagArgument
,
'FlagArgument'
,
argv
[
1
:])
runTestCase
(
FlagArgument
,
'ValueArgument'
,
argv
[
1
:])
runTestCase
(
IntArgument
,
'IntArgument'
,
argv
[
1
:])
kamaki/cli/test.py
View file @
02987e9c
...
...
@@ -37,7 +37,7 @@ from inspect import getmembers, isclass
from
kamaki.cli.command_tree.test
import
Command
,
CommandTree
from
kamaki.cli.argument.test
import
(
Argument
,
ConfigArgument
,
RuntimeConfigArgument
,
FlagArgument
,
ValueArgument
)
ValueArgument
,
IntArgument
)
# TestCase auxiliary methods
...
...
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