2014-12-20 20:37:25 +01:00
|
|
|
import sys
|
|
|
|
|
|
|
|
from nose.tools import assert_raises
|
|
|
|
|
|
|
|
from atticmatic import command as module
|
|
|
|
|
|
|
|
|
|
|
|
def test_parse_arguments_with_no_arguments_uses_defaults():
|
|
|
|
parser = module.parse_arguments()
|
|
|
|
|
|
|
|
assert parser.config_filename == module.DEFAULT_CONFIG_FILENAME
|
|
|
|
assert parser.excludes_filename == module.DEFAULT_EXCLUDES_FILENAME
|
2015-07-18 06:58:50 +02:00
|
|
|
assert parser.verbosity == None
|
2014-12-20 20:37:25 +01:00
|
|
|
|
|
|
|
|
|
|
|
def test_parse_arguments_with_filename_arguments_overrides_defaults():
|
|
|
|
parser = module.parse_arguments('--config', 'myconfig', '--excludes', 'myexcludes')
|
|
|
|
|
|
|
|
assert parser.config_filename == 'myconfig'
|
|
|
|
assert parser.excludes_filename == 'myexcludes'
|
2015-07-18 06:58:50 +02:00
|
|
|
assert parser.verbosity == None
|
2014-12-20 20:37:25 +01:00
|
|
|
|
|
|
|
|
2015-07-18 06:58:50 +02:00
|
|
|
def test_parse_arguments_with_verbosity_flag_overrides_default():
|
|
|
|
parser = module.parse_arguments('--verbosity', '1')
|
2014-12-20 20:37:25 +01:00
|
|
|
|
|
|
|
assert parser.config_filename == module.DEFAULT_CONFIG_FILENAME
|
|
|
|
assert parser.excludes_filename == module.DEFAULT_EXCLUDES_FILENAME
|
2015-07-18 06:58:50 +02:00
|
|
|
assert parser.verbosity == 1
|
2014-12-20 20:37:25 +01:00
|
|
|
|
|
|
|
|
|
|
|
def test_parse_arguments_with_invalid_arguments_exits():
|
|
|
|
original_stderr = sys.stderr
|
|
|
|
sys.stderr = sys.stdout
|
|
|
|
|
|
|
|
try:
|
|
|
|
with assert_raises(SystemExit):
|
|
|
|
module.parse_arguments('--posix-me-harder')
|
|
|
|
finally:
|
|
|
|
sys.stderr = original_stderr
|