summaryrefslogtreecommitdiffstats
path: root/testsuite/TestOptions.py
diff options
context:
space:
mode:
authorSol Jerome <sol.jerome@gmail.com>2011-04-07 14:04:17 -0500
committerSol Jerome <sol.jerome@gmail.com>2011-04-07 14:04:17 -0500
commit6f27f7f30ee0bcfcb3f6a4c48c153ea39a2accce (patch)
tree5f7f2c116c12d834f5197cf09d5f15ee10d05b82 /testsuite/TestOptions.py
parent1d2b0215f5957d4ec0d320984c93328a39d3b08c (diff)
downloadbcfg2-6f27f7f30ee0bcfcb3f6a4c48c153ea39a2accce.tar.gz
bcfg2-6f27f7f30ee0bcfcb3f6a4c48c153ea39a2accce.tar.bz2
bcfg2-6f27f7f30ee0bcfcb3f6a4c48c153ea39a2accce.zip
testsuite: PY3K + PEP8 fixes
Signed-off-by: Sol Jerome <sol.jerome@gmail.com>
Diffstat (limited to 'testsuite/TestOptions.py')
-rw-r--r--testsuite/TestOptions.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/testsuite/TestOptions.py b/testsuite/TestOptions.py
index e7d2aeff0..735455d45 100644
--- a/testsuite/TestOptions.py
+++ b/testsuite/TestOptions.py
@@ -1,6 +1,9 @@
-import os, sys
+import os
+import sys
+
import Bcfg2.Options
+
class TestOption(object):
def test__init(self):
o = Bcfg2.Options.Option('foo', False, cmd='-F')
@@ -22,11 +25,11 @@ class TestOption(object):
assert o.value == 'test3'
del os.environ['TEST2']
o.parse([], [])
- print o.value
+ print(o.value)
assert o.value == 'foobat'
o.cf = ('communication', 'pwd')
o.parse([], [])
- print o.value
+ print(o.value)
assert o.value == 'test4'
o.cf = False
o.parse([], [])
@@ -41,11 +44,13 @@ class TestOption(object):
o2.parse([('-F', '')], [])
assert o2.value == True
+
class TestOptionSet(object):
def test_buildGetopt(self):
opts = [('foo', Bcfg2.Options.Option('foo', 'test1', cmd='-G')),
('bar', Bcfg2.Options.Option('foo', 'test2')),
- ('baz', Bcfg2.Options.Option('foo', 'test1', cmd='-H', odesc='1'))]
+ ('baz', Bcfg2.Options.Option('foo', 'test1', cmd='-H',
+ odesc='1'))]
os = Bcfg2.Options.OptionSet(opts)
res = os.buildGetopt()
assert 'H:' in res and 'G' in res and len(res) == 3
@@ -57,13 +62,14 @@ class TestOptionSet(object):
odesc='1', long_arg=True))]
os = Bcfg2.Options.OptionSet(opts)
res = os.buildLongGetopt()
- print res
+ print(res)
assert 'H=' in res and len(res) == 1
def test_parse(self):
opts = [('foo', Bcfg2.Options.Option('foo', 'test1', cmd='-G')),
('bar', Bcfg2.Options.Option('foo', 'test2')),
- ('baz', Bcfg2.Options.Option('foo', 'test1', cmd='-H', odesc='1'))]
+ ('baz', Bcfg2.Options.Option('foo', 'test1', cmd='-H',
+ odesc='1'))]
os = Bcfg2.Options.OptionSet(opts)
try:
os.parse(['-G', '-H'])
@@ -80,11 +86,13 @@ class TestOptionSet(object):
os3.parse(['-G'])
assert os3['foo'] == True
+
class TestOptionParser(object):
def test__init(self):
opts = [('foo', Bcfg2.Options.Option('foo', 'test1', cmd='-h')),
('bar', Bcfg2.Options.Option('foo', 'test2')),
- ('baz', Bcfg2.Options.Option('foo', 'test1', cmd='-H', odesc='1'))]
+ ('baz', Bcfg2.Options.Option('foo', 'test1', cmd='-H',
+ odesc='1'))]
os1 = Bcfg2.Options.OptionParser(opts)
assert Bcfg2.Options.Option.cfpath == '/etc/bcfg2.conf'
sys.argv = ['foo', '-C', '/usr/local/etc/bcfg2.conf']