SeattleTestbed / seattlelib_v2

RepyV2 libraries to use with SeattleTestbed
MIT License
1 stars 20 forks source link

Fix #170, rectify `argparse.r2py` #171

Closed aaaaalbert closed 8 years ago

aaaaalbert commented 9 years ago

Also, add unit tests.

aaaaalbert commented 9 years ago

@yyzhuang, feel free to test this version of argparse for your project.


Unit test results from my humble machine:

albert$ for FILE in *_argparse_* ; do python utf.py -f $FILE ; done
Testing module: seattlelib
    Running: ut_seattlelib_argparse_scan_bool.r2py              [ PASS ]
Testing module: seattlelib
    Running: ut_seattlelib_argparse_scan_bool_default.r2py      [ PASS ]
Testing module: seattlelib
    Running: ut_seattlelib_argparse_scan_bool_missing.r2py      [ PASS ]
Testing module: seattlelib
    Running: ut_seattlelib_argparse_scan_int.r2py               [ PASS ]
Testing module: seattlelib
    Running: ut_seattlelib_argparse_scan_int_default.r2py       [ PASS ]
Testing module: seattlelib
    Running: ut_seattlelib_argparse_scan_int_missing.r2py       [ PASS ]
Testing module: seattlelib
    Running: ut_seattlelib_argparse_scan_int_missing_value.r2py [ PASS ]
Testing module: seattlelib
    Running: ut_seattlelib_argparse_scan_int_nonint.r2py        [ PASS ]
Testing module: seattlelib
    Running: ut_seattlelib_argparse_scan_int_uses_first.r2py    [ PASS ]
Testing module: seattlelib
    Running: ut_seattlelib_argparse_scan_str.r2py               [ PASS ]
Testing module: seattlelib
    Running: ut_seattlelib_argparse_scan_str_default.r2py       [ PASS ]
Testing module: seattlelib
    Running: ut_seattlelib_argparse_scan_str_missing.r2py       [ PASS ]
Testing module: seattlelib
    Running: ut_seattlelib_argparse_scan_str_missing_value.r2py [ PASS ]
Testing module: seattlelib
    Running: ut_seattlelib_argparse_scan_str_uses_first.r2py    [ PASS ]
XuefengHuang commented 9 years ago

I think we also need a unit test to check whether argparse_scan_str can parse non-str value of str argument, just like ut_seattlelib_argparse_scan_int_nonint.r2py

aaaaalbert commented 9 years ago

Hmmm, the point is that all callargs are strs in the first place (and are not parsed into str). Parsing from str is only done for int args.

Example: 123 is a string that can be parsed as an integer. xyz is a string that cannot be parsed as an integer. (Both are strings, still).

XuefengHuang commented 9 years ago

OK, that makes sense to me!