-
-
Save larsks/a559e121a818290b36872cbc4151e411 to your computer and use it in GitHub Desktop.
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
import os | |
import subprocess | |
import sys | |
from oslo_log import log | |
from oslo_config import cfg | |
LOG = log.getLogger(__name__) | |
CONF = cfg.CONF | |
options = [ | |
cfg.BoolOpt('test-option', default=False) | |
] | |
def main(): | |
CONF.register_cli_opts(options, group='test') | |
CONF(sys.argv[1:]) | |
if CONF.test.test_option: | |
print('test-option was set') | |
else: | |
print('test-option was not set') | |
if __name__ == '__main__': | |
sys.exit(main()) |
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
#!/bin/sh | |
assert_equals() { | |
if [[ $1 != $2 ]]; then | |
echo "FAILED: \"$1\" != \"$2\"" | |
exit 1 | |
fi | |
} | |
cat > test.conf <<EOF | |
[test] | |
test_option = true | |
EOF | |
assert_equals "$(python cftest.py)" "test-option was not set" | |
assert_equals "$(python cftest.py --test-test-option)" "test-option was set" | |
assert_equals "$(python cftest.py --config-file test.conf)" "test-option was set" | |
assert_equals "$(python cftest.py --config-file test.conf --test-notest-option)" "test-option was not set" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment