本文整理汇总了Python中txtorcon.TorConfig.foo方法的典型用法代码示例。如果您正苦于以下问题:Python TorConfig.foo方法的具体用法?Python TorConfig.foo怎么用?Python TorConfig.foo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类txtorcon.TorConfig
的用法示例。
在下文中一共展示了TorConfig.foo方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_save_boolean_with_strange_values
# 需要导入模块: from txtorcon import TorConfig [as 别名]
# 或者: from txtorcon.TorConfig import foo [as 别名]
def test_save_boolean_with_strange_values(self):
self.protocol.answers.append('config/names=\nfoo Boolean\nbar Boolean')
self.protocol.answers.append({'foo': '0'})
self.protocol.answers.append({'bar': '1'})
conf = TorConfig(self.protocol)
# save some non-boolean value
conf.foo = "Something True"
conf.bar = 0
conf.save()
self.assertEqual(set(self.protocol.sets),
set([('foo', 1), ('bar', 0)]))
示例2: test_int_validator
# 需要导入模块: from txtorcon import TorConfig [as 别名]
# 或者: from txtorcon.TorConfig import foo [as 别名]
def test_int_validator(self):
self.protocol.answers.append('config/names=\nfoo Integer')
self.protocol.answers.append({'foo': '123'})
conf = TorConfig(self.protocol)
conf.foo = 2.33
conf.save()
self.assertEqual(conf.foo, 2)
conf.foo = '1'
conf.save()
self.assertEqual(conf.foo, 1)
conf.foo = '-100'
conf.save()
self.assertEqual(conf.foo, -100)
conf.foo = 0
conf.save()
self.assertEqual(conf.foo, 0)
conf.foo = '0'
conf.save()
self.assertEqual(conf.foo, 0)
for value in ('no', 'Not a value', None):
try:
conf.foo = value
except (ValueError, TypeError):
pass
else:
self.fail("No excpetion thrown")
示例3: test_read_boolean_after_save
# 需要导入模块: from txtorcon import TorConfig [as 别名]
# 或者: from txtorcon.TorConfig import foo [as 别名]
def test_read_boolean_after_save(self):
self.protocol.answers.append('config/names=\nfoo Boolean\nbar Boolean')
self.protocol.answers.append({'foo': '0'})
self.protocol.answers.append({'bar': '1'})
conf = TorConfig(self.protocol)
# save some boolean value
conf.foo = True
conf.bar = False
conf.save()
self.assertTrue(conf.foo is True, msg="foo not True: %s" % conf.foo)
self.assertTrue(conf.bar is False, msg="bar not False: %s" % conf.bar)
示例4: test_save_boolean
# 需要导入模块: from txtorcon import TorConfig [as 别名]
# 或者: from txtorcon.TorConfig import foo [as 别名]
def test_save_boolean(self):
self.protocol.answers.append('config/names=\nfoo Boolean\nbar Boolean')
self.protocol.answers.append({'foo': '0'})
self.protocol.answers.append({'bar': '1'})
conf = TorConfig(self.protocol)
# save some boolean value
conf.foo = True
conf.bar = False
conf.save()
self.assertEqual(set(self.protocol.sets),
set([('foo', 1), ('bar', 0)]))
示例5: test_log_double_save
# 需要导入模块: from txtorcon import TorConfig [as 别名]
# 或者: from txtorcon.TorConfig import foo [as 别名]
def test_log_double_save(self):
self.protocol.answers.append('config/names=\nLog LineList\nFoo String''')
self.protocol.answers.append({'Log': 'notice file /var/log/tor/notices.log'})
self.protocol.answers.append({'Foo': 'foo'})
conf = TorConfig(self.protocol)
conf.log.append('info file /tmp/foo.log')
conf.foo = 'bar'
self.assertTrue(conf.needs_save())
conf.save()
conf.save() # just for the code coverage...
self.assertTrue(not conf.needs_save())
self.protocol.sets = []
conf.save()
self.assertEqual(self.protocol.sets, [])
示例6: test_save_invalid_boolean_auto
# 需要导入模块: from txtorcon import TorConfig [as 别名]
# 或者: from txtorcon.TorConfig import foo [as 别名]
def test_save_invalid_boolean_auto(self):
self.protocol.answers.append(
'config/names=\nfoo Boolean+Auto'
)
self.protocol.answers.append({'foo': '1'})
conf = TorConfig(self.protocol)
for value in ('auto', 'True', 'False', None):
try:
conf.foo = value
except (ValueError, TypeError):
pass
else:
self.fail("Invalid value '%s' allowed" % value)
conf.save()
self.assertEqual(self.protocol.sets, [])
示例7: test_save_boolean_auto
# 需要导入模块: from txtorcon import TorConfig [as 别名]
# 或者: from txtorcon.TorConfig import foo [as 别名]
def test_save_boolean_auto(self):
self.protocol.answers.append(
'config/names=\nfoo Boolean+Auto\nbar Boolean+Auto\nbaz Boolean+Auto\nqux Boolean+Auto'
)
self.protocol.answers.append({'foo': '1'})
self.protocol.answers.append({'bar': '1'})
self.protocol.answers.append({'baz': '1'})
self.protocol.answers.append({'qux': '1'})
conf = TorConfig(self.protocol)
conf.foo = 1
conf.bar = 0
conf.baz = True
conf.qux = -1
conf.save()
self.assertEqual(set(self.protocol.sets),
set([('foo', 1),
('bar', 0),
('baz', 1),
('qux', 'auto')]))
self.assertTrue(conf.foo is 1)
self.assertTrue(conf.bar is 0)
self.assertTrue(conf.baz is 1)
self.assertTrue(conf.qux is -1)