-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from graingert/fix-long-form-args
make args testable, and test them with tox
- Loading branch information
Showing
3 changed files
with
87 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
.eggs/ | ||
hashin.egg-info/ | ||
.tox/ | ||
|
||
### Python ### | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import argparse | ||
|
||
from nose.tools import eq_ | ||
|
||
from hashin import parser | ||
|
||
|
||
def test_everything(): | ||
args = parser.parse_known_args([ | ||
'example', 'another-example', | ||
'-r', 'reqs.txt', | ||
'-a', 'sha512', | ||
'-p', '3.5', | ||
'-v', | ||
]) | ||
expected = argparse.Namespace( | ||
algorithm='sha512', | ||
packages=['example', 'another-example'], | ||
python_version=['3.5'], | ||
requirements_file='reqs.txt', | ||
verbose=True, | ||
) | ||
eq_(args, (expected, [])) | ||
|
||
|
||
def test_everything_long(): | ||
args = parser.parse_known_args([ | ||
'example', 'another-example', | ||
'--requirements-file', 'reqs.txt', | ||
'--algorithm', 'sha512', | ||
'--python-version', '3.5', | ||
'--verbose', | ||
]) | ||
expected = argparse.Namespace( | ||
algorithm='sha512', | ||
packages=['example', 'another-example'], | ||
python_version=['3.5'], | ||
requirements_file='reqs.txt', | ||
verbose=True, | ||
) | ||
eq_(args, (expected, [])) | ||
|
||
|
||
def test_minimal(): | ||
args = parser.parse_known_args(['example']) | ||
expected = argparse.Namespace( | ||
algorithm='sha256', | ||
packages=['example'], | ||
python_version=[], | ||
requirements_file='requirements.txt', | ||
verbose=False, | ||
) | ||
eq_(args, (expected, [])) |