本文整理汇总了Python中TestHelper.TestHelper类的典型用法代码示例。如果您正苦于以下问题:Python TestHelper类的具体用法?Python TestHelper怎么用?Python TestHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TestHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestLinksysParser
class TestLinksysParser(unittest.TestCase):
def setUp(self):
self.parser = LinksysParser()
self.helper = TestHelper()
def test_parse_time(self):
now = datetime.now()
dt = self.parser.parse_time("12:10:42")
self.assertEqual(now.year, dt.year)
self.assertEqual(now.month, dt.month)
self.assertEqual(now.day, dt.day)
self.assertEqual(12, dt.hour)
self.assertEqual(10, dt.minute)
self.assertEqual(42, dt.second)
def test_parse_dhcp_clients(self):
clients = self.parser.parse_dhcp_clients(self.helper.dhcp_response())
# Make sure we got all the records
self.assertEqual(10, len(clients))
# Spot check a single record to ensure all the fields are correct
client = clients[0]
self.assertEqual('LAN', client['interface'])
self.assertEqual('zelda', client['hostname'])
self.assertEqual('192.168.1.107', client['ip_address'])
self.assertEqual('01:35:10', client['lease_expires'])
self.assertEqual('00:15:af:e6:6b:da', client['mac_address'])
def test_parse_mac_blacklist(self):
mac_addrs = self.parser.parse_mac_blacklist(self.helper.mac_response())
self.assertEqual(3, len(mac_addrs))
self.assertEqual('22:22:22:22:22:22', mac_addrs[0])
self.assertEqual('00:33:33:33:33:33', mac_addrs[1])
self.assertEqual('00:44:44:44:44:44', mac_addrs[2])
示例2: Copyright
#!/usr/bin/env python
#
# Copyright (c) ZeroC, Inc. All rights reserved.
#
from TestHelper import TestHelper
TestHelper.loadSlice("Key.ice Clash.ice")
import sys
import Ice
import _and
class delI(_and._del):
def _elifAsync(self, _else, current=None):
pass
class execI(_and._exec):
def _finally(self, current=None):
assert current.operation == "finally"
class ifI(_and._if):
def _elifAsync(self, _else, current=None):
pass
def _finally(self, current=None):
pass
def foo(self, _from, current=None):
pass
示例3: errorExit
import random
import subprocess
import signal
###############################################################
# Test for validating the dirty db flag sticks repeated nodeos restart attempts
###############################################################
Print=Utils.Print
def errorExit(msg="", errorCode=1):
Print("ERROR:", msg)
exit(errorCode)
args = TestHelper.parse_args({"--keep-logs","--dump-error-details","-v","--leave-running","--clean-run"})
debug=args.v
pnodes=1
topo="mesh"
delay=1
chainSyncStrategyStr=Utils.SyncResyncTag
total_nodes = pnodes
killCount=1
killSignal=Utils.SigKillTag
killEosInstances= not args.leave_running
dumpErrorDetails=args.dump_error_details
keepLogs=args.keep_logs
killAll=args.clean_run
seed=1
示例4: errorExit
#!/usr/bin/env python3
from testUtils import Utils
from Cluster import Cluster
from WalletMgr import WalletMgr
from TestHelper import TestHelper
import random
Print=Utils.Print
def errorExit(msg="", errorCode=1):
Print("ERROR:", msg)
exit(errorCode)
args=TestHelper.parse_args({"-p","-n","-d","-s","--nodes-file","--seed"
,"--dump-error-details","-v","--leave-running","--clean-run"})
pnodes=args.p
topo=args.s
delay=args.d
total_nodes = pnodes if args.n == 0 else args.n
debug=args.v
nodesFile=args.nodes_file
seed=args.seed
dontKill=args.leave_running
dumpErrorDetails=args.dump_error_details
killAll=args.clean_run
killWallet=not dontKill
killEosInstances=not dontKill
if nodesFile is not None:
示例5: Copyright
#!/usr/bin/env python
#
# Copyright (c) ZeroC, Inc. All rights reserved.
#
from TestHelper import TestHelper
TestHelper.loadSlice('Test.ice')
import Ice
import TestAMDI
import TestActivationAMDI
class ServerAMD(TestHelper):
def run(self, args):
with self.initialize(args=args) as communicator:
communicator.getProperties().setProperty("TestAdapter.Endpoints", self.getTestEndpoint())
communicator.getProperties().setProperty("Ice.Warn.Dispatch", "0")
adapter = communicator.createObjectAdapter("TestAdapter")
adapter.addServantLocator(TestAMDI.ServantLocatorI("category"), "category")
adapter.addServantLocator(TestAMDI.ServantLocatorI(""), "")
adapter.add(TestAMDI.TestI(), Ice.stringToIdentity("asm"))
adapter.add(TestActivationAMDI.TestActivationAMDI(), Ice.stringToIdentity("test/activation"))
adapter.activate()
adapter.waitForDeactivate()
示例6: Copyright
#!/usr/bin/env python
#
# Copyright (c) ZeroC, Inc. All rights reserved.
#
import sys
import threading
import Ice
import Glacier2
from TestHelper import TestHelper
TestHelper.loadSlice("Callback.ice")
import Test
def test(b):
if not b:
raise RuntimeError('test assertion failed')
class CallbackReceiverI(Test.CallbackReceiver):
def __init__(self):
self._received = False
self._cond = threading.Condition()
def callback(self, current):
with self._cond:
self._received = True
self._cond.notify()
示例7: Copyright
#!/usr/bin/env python
#
# Copyright (c) ZeroC, Inc. All rights reserved.
#
from TestHelper import TestHelper
TestHelper.loadSlice('--all -I. Test.ice')
import Test
import Test1
import testpkg
import modpkg
import Ice
class InitialI(Test.Initial):
def getTest1C2AsObject(self, current):
return Test1.C2()
def getTest1C2AsC1(self, current):
return Test1.C2()
def getTest1C2AsC2(self, current):
return Test1.C2()
def throwTest1E2AsE1(self, current):
raise Test1.E2()
def throwTest1E2AsE2(self, current):
raise Test1.E2()
示例8: setUp
def setUp(self):
self.parser = LinksysParser()
self.helper = TestHelper()
示例9: can_build_record
# Id,ActionTypeId,MemberId,Created,CampaignId,TrademarkId,ProductTypeId,InventoryId,CategoryId,CustomListId,Identifier,UserIp,Url,RefererUrl,UserAgentString,ExtraData
line = "1,2,3,1/20/2012 13:53,,,,,,,,1.2.3.4,,,,"
res = walp.parse_line(line)
th.should_be(res[walp.ID], 1)
th.should_be(res[walp.ACTION_TYPE_ID], 2)
th.should_be(res[walp.MEMBER_ID], 3)
th.should_be(res[walp.ACTIVITY_DATE], "1/20/2012 13:53")
th.should_be(res[walp.CAMPAIGN_ID], None)
th.should_be(res[walp.TRADEMARK_ID], None)
th.should_be(res[walp.PRODUCT_TYPE_ID], None)
th.should_be(res[walp.INVENTORY_ID], None)
th.should_be(res[walp.CATEGORY_ID], None)
th.should_be(res[walp.CUSTOM_LIST_ID], None)
th.should_be(res[walp.IDENTIFIER], None)
th.should_be(res[walp.USER_IP], "1.2.3.4")
th.should_be(res[walp.REQUESTED_URL], "")
th.should_be(res[walp.USER_AGENT], "")
th.should_be(res[walp.EXTRA_DATA], "")
def can_build_record(th):
line = "1,2,3,1/20/2012 13:53,4,5,6,7,8,9,10,212.156.132.66,http://localhost:8080/markalar/4/,REF,Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0.1) Gecko/20100101 Firefox/9.0.1,EXD"
record = WebActivityRecord(line)
th.should_be(record.day_of_week, 4)
th.should_be(record.category_id, 8)
if __name__ == "__main__":
th = TestHelper()
th.run_test(test_line_parser_all_fields)
th.run_test(test_line_parser_missing_fields)
th.run_test(can_build_record)
示例10: cmdError
###############################################################
Print=Utils.Print
errorExit=Utils.errorExit
from core_symbol import CORE_SYMBOL
def cmdError(name, cmdCode=0, exitNow=False):
msg="FAILURE - %s%s" % (name, ("" if cmdCode == 0 else (" returned error code %d" % cmdCode)))
if exitNow:
errorExit(msg, True)
else:
Print(msg)
args = TestHelper.parse_args({"--host","--port","--prod-count","--defproducera_prvt_key","--defproducerb_prvt_key","--mongodb"
,"--dump-error-details","--dont-launch","--keep-logs","-v","--leave-running","--only-bios","--clean-run"
,"--sanity-test"})
server=args.host
port=args.port
debug=args.v
enableMongo=args.mongodb
defproduceraPrvtKey=args.defproducera_prvt_key
defproducerbPrvtKey=args.defproducerb_prvt_key
dumpErrorDetails=args.dump_error_details
keepLogs=args.keep_logs
dontLaunch=args.dont_launch
dontKill=args.leave_running
prodCount=args.prod_count
onlyBios=args.only_bios
killAll=args.clean_run
sanityTest=args.sanity_test
示例11: Copyright
#!/usr/bin/env python
#
# Copyright (c) ZeroC, Inc. All rights reserved.
#
from TestHelper import TestHelper
TestHelper.loadSlice('Callback.ice')
import Ice
import Test
class CallbackI(Test.Callback):
def initiateCallback(self, proxy, current):
proxy.callback(current.ctx)
def shutdown(self, current):
current.adapter.getCommunicator().shutdown()
class Server(TestHelper):
def run(self, args):
with self.initialize(args=args) as communicator:
communicator.getProperties().setProperty("DeactivatedAdapter.Endpoints", self.getTestEndpoint(num=1))
communicator.createObjectAdapter("DeactivatedAdapter")
communicator.getProperties().setProperty("CallbackAdapter.Endpoints", self.getTestEndpoint())
adapter = communicator.createObjectAdapter("CallbackAdapter")
adapter.add(CallbackI(), Ice.stringToIdentity("callback"))
adapter.activate()
示例12: Copyright
#!/usr/bin/env python
#
# Copyright (c) ZeroC, Inc. All rights reserved.
#
from TestHelper import TestHelper
TestHelper.loadSlice("Test.ice ClientPrivate.ice")
import AllTests
class Client(TestHelper):
def run(self, args):
with self.initialize(args=args) as communicator:
initial = AllTests.allTests(self, communicator)
initial.shutdown()
示例13: errorExit
# --kill-sig <kill signal [term|kill]>
# --kill-count <nodeos instances to kill>
# --dont-kill <Leave cluster running after test finishes>
# --dump-error-details <Upon error print etc/eosio/node_*/config.ini and var/lib/node_*/stderr.log to stdout>
# --keep-logs <Don't delete var/lib/node_* folders upon test completion>
###############################################################
Print=testUtils.Utils.Print
def errorExit(msg="", errorCode=1):
Print("ERROR:", msg)
traceback.print_stack(limit=-1)
exit(errorCode)
args=TestHelper.parse_args({"-p","-d","-s","-c","--kill-sig","--kill-count","--keep-logs","--p2p-plugin"
,"--dump-error-details","-v","--leave-running","--clean-run"})
pnodes=args.p
topo=args.s
delay=args.d
chainSyncStrategyStr=args.c
debug=args.v
total_nodes = pnodes
killCount=args.kill_count if args.kill_count > 0 else 1
killSignal=args.kill_sig
killEosInstances= not args.leave_running
dumpErrorDetails=args.dump_error_details
keepLogs=args.keep_logs
killAll=args.clean_run
p2pPlugin=args.p2p_plugin
seed=1
示例14: errorExit
import subprocess
###############################################################
# nodeos_run_remote_test
# Tests remote capability of the nodeos_run_test. Test will setup cluster and pass nodes info to nodeos_run_test. E.g.
# nodeos_run_remote_test.py -v --clean-run --dump-error-detail
###############################################################
Print=Utils.Print
def errorExit(msg="", errorCode=1):
Print("ERROR:", msg)
exit(errorCode)
args = TestHelper.parse_args({"--dump-error-details","-v","--leave-running","--only-bios","--clean-run"})
debug=args.v
dontKill=args.leave_running
dumpErrorDetails=args.dump_error_details
onlyBios=args.only_bios
killAll=args.clean_run
Utils.Debug=debug
killEosInstances=not dontKill
topo="mesh"
delay=1
prodCount=1 # producers per producer node
pnodes=1
total_nodes=pnodes
actualTest="tests/nodeos_run_test.py"
示例15: Copyright
#!/usr/bin/env python
#
# Copyright (c) ZeroC, Inc. All rights reserved.
#
from TestHelper import TestHelper
TestHelper.loadSlice("-I. --all ServerPrivate.ice")
import Ice
import Test
class TestI(Test.TestIntf):
def shutdown(self, current=None):
current.adapter.getCommunicator().shutdown()
def baseAsBase(self, current=None):
b = Test.Base()
b.b = "Base.b"
raise b
def unknownDerivedAsBase(self, current=None):
d = Test.UnknownDerived()
d.b = "UnknownDerived.b"
d.ud = "UnknownDerived.ud"
raise d
def knownDerivedAsBase(self, current=None):
d = Test.KnownDerived()
d.b = "KnownDerived.b"
d.kd = "KnownDerived.kd"
raise d