Skip to content
Snippets Groups Projects
Commit 6fe18e9b authored by ulif's avatar ulif
Browse files

Use opts in main().

parent e20181f0
No related branches found
No related tags found
No related merge requests found
import argparse
import os
import re
import sys
from random import SystemRandom
......@@ -69,5 +70,7 @@ def get_passphrase(wordnum=6, specials=True, separator='', lang='en',
return result
def main():
pass
def main(args=1):
if args is 1:
args = sys.argv[1:]
options = handle_options(args)
......@@ -3,6 +3,7 @@ import pytest
import sys
from diceware.diceware import (
SRC_DIR, get_wordlist, get_wordlist_path, get_passphrase, handle_options,
main,
)
......@@ -55,11 +56,17 @@ class TestDicewareModule(object):
r2 = get_passphrase()
assert r1 != r2
def test_handle_options(self, capsys):
def test_handle_options(self):
# we can get help
with pytest.raises(SystemExit) as exc_info:
handle_options(['--help'])
assert exc_info.value.code == 0
def test_main(self, capsys):
# we can get help
with pytest.raises(SystemExit) as exc_info:
main(['diceware', '--help'])
assert exc_info.value.code == 0
out, err = capsys.readouterr()
out = out.replace(
os.path.basename(sys.argv[0]), 'diceware')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment