How to use do_test method in gabbi

Best Python code snippet using gabbi_python

encoding_test.py

Source:encoding_test.py Github

copy

Full Screen

...3from pycoin import encoding4from pycoin.serialize import h2b5class EncodingTestCase(unittest.TestCase):6 def test_to_from_long(self):7 def do_test(as_int, prefix, as_rep, base):8 self.assertEqual((as_int, prefix), encoding.to_long(base, encoding.byte_to_int, as_rep))9 self.assertEqual(as_rep, encoding.from_long(as_int, prefix, base, lambda v:v))10 do_test(10000101, 2, h2b("00009896e5"), 256)11 do_test(10000101, 3, h2b("0000009896e5"), 256)12 do_test(1460765565493402645157733592332121663123460211377, 1, b'\0\xff\xde\xfeOHu\xcf\x11\x9f\xc3\xd8\xf4\xa0\x9a\xe3~\xc4\xccB\xb1', 256)13 def test_to_bytes_32(self):14 for i in range(256):15 v = encoding.to_bytes_32(i)16 self.assertEqual(v, b'\0' * 31 + bytes(bytearray([i])))17 for i in range(256,512):18 v = encoding.to_bytes_32(i)19 self.assertEqual(v, b'\0' * 30 + bytes(bytearray([1, i&0xff])))20 def test_to_from_base58(self):21 def do_test(as_text, as_bin):22 self.assertEqual(as_bin, encoding.a2b_base58(as_text))23 self.assertEqual(as_text, encoding.b2a_base58(as_bin))24 do_test("1abcdefghijkmnpqrst", b'\x00\x01\x93\\|\xf2*\xb9\xbe\x19b\xae\xe4\x8c{')25 do_test("1CASrvcpMMTa4dz4DmYtAqcegCtdkhjvdn", b'\x00zr\xb6\xfac\xde6\xc4\xab\xc6\nh\xb5-\x7f3\xe3\xd7\xcd>\xc4\xba\xbd9')26 do_test("1111111111111111aaaa11aa",27 b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00CnzQ)\x0b')28 do_test("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",29 b'\x00\x01\x11\xd3\x8e_\xc9\x07\x1f\xfc\xd2\x0bJv<\xc9\xaeO%+\xb4\xe4\x8f\xd6j\x83^%*\xda\x93\xffH\rm\xd4=\xc6*d\x11U\xa5')30 def test_to_from_hashed_base58(self):31 def do_test(as_text, as_bin):32 self.assertEqual(as_text, encoding.b2a_hashed_base58(as_bin))33 self.assertEqual(as_bin, encoding.a2b_hashed_base58(as_text))34 self.assertTrue(encoding.is_hashed_base58_valid(as_text))35 bogus_text = as_text[:-1] + chr(1+ord(as_text[-1]))36 self.assertFalse(encoding.is_hashed_base58_valid(bogus_text))37 do_test("14nr3dMd4VwNpFhFECU1A6imi", b'\x00\x01\x93\\|\xf2*\xb9\xbe\x19b\xae\xe4\x8c{')38 do_test("1CASrvcpMMTa4dz4DmYtAqcegCtdkhjvdn", b'\x00zr\xb6\xfac\xde6\xc4\xab\xc6\nh\xb5-\x7f3\xe3\xd7\xcd>')39 do_test("11111111111111114njGbaozZJui9o",40 b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00CnzQ)\x0b')41 do_test("1mLRia5CbfDB9752zxvtrpnkigecaYWUSQNLJGECA8641ywusqomjhfdb6EM7bXGj1Gb",42 b'\x00\x01\x11\xd3\x8e_\xc9\x07\x1f\xfc\xd2\x0bJv<\xc9\xaeO%+\xb4\xe4\x8f\xd6j\x83^%*\xda\x93\xffH\rm\xd4=\xc6*d\x11U\xa5aaaa')43 def test_double_sha256(self):44 def do_test(blob, expected_hash):45 self.assertEqual(encoding.double_sha256(blob), expected_hash)46 do_test(b"This is a test",47 b'\xea\xc6I\xd41\xaa?\xc2\xd5t\x9d\x1aP!\xbb\xa7\x81.\xc8;\x8aY\xfa\x84\x0b\xffu\xc1\x7f\x8af\\')48 do_test(b"The quick brown fox jumps over the lazy dogs",49 b'\x8a5e\x88yz\x90\x1a\x11\x03\x17y\xd4xz\xd0E~\xb0\x82\xc5k\xd9\xb6W\x15z\xcf1\xba\xe6\xc4')50 do_test(b'\x74' * 10000,51 b'nMw6\xaa7<G\x18\xee\xf2\xb9E(\xfe\xd5u\x19\xa0\xbd\xc3\xa8\xf40\n\xee7,\xbe\xde\xa9\xa0')52 def test_hash160(self):53 def do_test(blob, expected_hash):54 self.assertEqual(encoding.hash160(blob), expected_hash)55 do_test(b"This is a test",56 b'\x18\xac\x98\xfa*$\x12\xdd\xb7]\xe6\x04Y\xb5*\xcd\x98\xf2\xd9r')57 do_test(b"The quick brown fox jumps over the lazy dogs",58 b'v\xc9\xd1\xf3\xaaR&UN G_\x91\x9a\xad\xd1t\xf7\xe9\xb7')59 do_test(b'\x74' * 10000,60 b'\xa9a\x07\x02\x96gt\x01\xa5~\xae\r\x96\xd1MZ\x88\n,A')61 def test_wif_to_from_secret_exponent(self):62 def do_test(as_secret_exponent, as_wif, is_compressed):63 self.assertEqual(as_wif, encoding.secret_exponent_to_wif(as_secret_exponent, compressed=is_compressed))64 se, comp = encoding.wif_to_tuple_of_secret_exponent_compressed(as_wif)65 self.assertEqual(se, as_secret_exponent)66 self.assertEqual(comp, is_compressed)67 self.assertTrue(encoding.is_valid_wif(as_wif))68 WIF_LIST = [69 "5HwoXVkHoRM8sL2KmNRS217n1g8mPPBomrY7yehCuXC1115WWsh",70 "5J5KUK3VXP8HUefNVYPxwxVRokScZdWXpu1Tj8LfaAXMqHzMmbk",71 "5JCqR8LhFLuS5yJRDiNVsus5bpkTjsqFswUoUbz8EorifYA4TwJ",72 "5JLMMwdtyJgahHwTwtM2osEjPu4Jv89yvyx9E5dauTC5Vs6EjBA",73 "5JTsJkw6hGTjJcaWg4KZjpcPByNA6NUhz2RUyZH3a6XSL7vAYmy",74 "5JbPFaEJREEsuwDZQEJ6fmz2z3g1GcoS34tpj2vWEjroARtCMBF",75 "5JiuCPXW9C22XFrc8QGdbjMgn7yrSs8A67NAUWZxuPC9ziUizQP",76 "5JrR9Cphs9oB8aVeraFAXgjLaCHhd7St99qWDzDRa2XWq3RVw7d",77 "5Jyw627ub7aKju8hakDhTe6zNGbYoMmcCCJqyTrtEfrsfLDreVt",78 "5K7T2qR7K5MUMDmkJvCEPbUeALuPyc6LFEnBiwWLuKCEVdBp8qV",79 "5KExyeiK338cxYQo36AmKYrHxRDF9rR4JHFXUR9oZxXbKue7gdL",80 "5KNUvU1WkzumZs3qmG9JFWDwkVX6L6jnMKisDtoGEbrxACzxk6T",81 "5KVzsHJiUxgvBBgtVS7qBTbbYZpwWM4WQNCCyNSiuFCJzYMxg8H",82 "5KdWp6bvCvU4nWKwDc6N7QyFLe8ngbPETQfYir6BZtXfpsnSrGS",83 ]84 SE_LIST = [int(c * 64, 16) for c in "123456789abcde"]85 for se, wif in zip(SE_LIST, WIF_LIST):86 do_test(se, wif, is_compressed=False)87 def test_public_pair_to_sec(self):88 def do_test(as_public_pair, as_sec, is_compressed, as_hash160_sec, as_bitcoin_address):89 self.assertEqual(encoding.sec_to_public_pair(as_sec), as_public_pair)90 self.assertEqual(encoding.public_pair_to_sec(as_public_pair, compressed=is_compressed), as_sec)91 self.assertEqual(encoding.is_sec_compressed(as_sec), is_compressed)92 self.assertEqual(encoding.public_pair_to_hash160_sec(as_public_pair, compressed=is_compressed),93 as_hash160_sec)94 self.assertEqual(encoding.hash160_sec_to_bitcoin_address(as_hash160_sec), as_bitcoin_address)95 self.assertEqual(encoding.public_pair_to_bitcoin_address(as_public_pair, compressed=is_compressed), as_bitcoin_address)96 self.assertTrue(encoding.is_valid_bitcoin_address(as_bitcoin_address))97 bad_address = as_bitcoin_address[:17] + chr(ord(as_bitcoin_address[17]) + 1) + as_bitcoin_address[18:]98 self.assertFalse(encoding.is_valid_bitcoin_address(bad_address))99 SEC_TEST_DATA = [100 ((35826991941973211494003564265461426073026284918572421206325859877044495085994,101 25491041833361137486709012056693088297620945779048998614056404517283089805761),102 "034f355bdcb7cc0af728ef3cceb9615d90684bb5b2ca5f859ab0f0b704075871aa",103 True,104 "fc7250a211deddc70ee5a2738de5f07817351cef",105 "1Q1pE5vPGEEMqRcVRMbtBK842Y6Pzo6nK9"106 ),107 ((31855367722742370537280679280108010854876607759940877706949385967087672770343,108 46659058944867745027460438812818578793297503278458148978085384795486842595210),109 "02466d7fcae563e5cb09a0d1870bb580344804617879a14949cf22285f1bae3f27",110 True,111 "531260aa2a199e228c537dfa42c82bea2c7c1f4d",112 "18aF6pYXKDSXjXHpidt2G6okdVdBr8zA7z"113 ),114 ((27341391395138457474971175971081207666803680341783085051101294443585438462385,115 26772005640425216814694594224987412261034377630410179754457174380653265224672),116 "023c72addb4fdf09af94f0c94d7fe92a386a7e70cf8a1d85916386bb2535c7b1b1",117 True,118 "3bc28d6d92d9073fb5e3adf481795eaf446bceed",119 "16Syw4SugWs4siKbK8cuxJXM2ukh2GKpRi"120 ),121 ((35826991941973211494003564265461426073026284918572421206325859877044495085994,122 25491041833361137486709012056693088297620945779048998614056404517283089805761),123 "044f355bdcb7cc0af728ef3cceb9615d90684bb5b2ca5f859ab0f0b704075871aa"\124 "385b6b1b8ead809ca67454d9683fcf2ba03456d6fe2c4abe2b07f0fbdbb2f1c1",125 False,126 "e4e517ee07984a4000cd7b00cbcb545911c541c4",127 "1MsHWS1BnwMc3tLE8G35UXsS58fKipzB7a"128 ),129 ((31855367722742370537280679280108010854876607759940877706949385967087672770343,130 46659058944867745027460438812818578793297503278458148978085384795486842595210),131 "04466d7fcae563e5cb09a0d1870bb580344804617879a14949cf22285f1bae3f27"\132 "6728176c3c6431f8eeda4538dc37c865e2784f3a9e77d044f33e407797e1278a",133 False,134 "b256082b934fe782adbacaafeadfca64c52a5384",135 "1HFxLkPTtMZeo5mDpZn6CF9sh4h2ycknwr"136 ),137 ((27341391395138457474971175971081207666803680341783085051101294443585438462385,138 26772005640425216814694594224987412261034377630410179754457174380653265224672),139 "043c72addb4fdf09af94f0c94d7fe92a386a7e70cf8a1d85916386bb2535c7b1b1"\140 "3b306b0fe085665d8fc1b28ae1676cd3ad6e08eaeda225fe38d0da4de55703e0",141 False,142 "edf6bbd7ba7aad222c2b28e6d8d5001178e3680c",143 "1NhEipumt9Pug6pwTqMNRXhBG84K39Ebbi"144 ),145 ]146 for public_pair, sec, compressed, hash160_sec, bitcoin_address in SEC_TEST_DATA:147 do_test(public_pair, h2b(sec), compressed, h2b(hash160_sec), bitcoin_address)148if __name__ == '__main__':...

Full Screen

Full Screen

01-connect-zero-length-id.py

Source:01-connect-zero-length-id.py Github

copy

Full Screen

...13 f.write("listener %d\n" % (port1))14 f.write("allow_anonymous true\n")15 if allow_zero != "":16 f.write("allow_zero_length_clientid %s\n" % (allow_zero))17def do_test(per_listener, proto_ver, clean_start, allow_zero, client_port, expect_fail):18 conf_file = os.path.basename(__file__).replace('.py', '.conf')19 write_config(conf_file, port1, port2, per_listener, allow_zero)20 rc = 121 keepalive = 1022 connect_packet = mosq_test.gen_connect("", keepalive=keepalive, proto_ver=proto_ver, clean_session=clean_start)23 if proto_ver == 4:24 if expect_fail == True:25 connack_packet = mosq_test.gen_connack(rc=2, proto_ver=proto_ver)26 else:27 connack_packet = mosq_test.gen_connack(rc=0, proto_ver=proto_ver)28 else:29 if expect_fail == True:30 connack_packet = mosq_test.gen_connack(rc=128, proto_ver=proto_ver, properties=None)31 else:32 props = mqtt5_props.gen_string_prop(mqtt5_props.PROP_ASSIGNED_CLIENT_IDENTIFIER, "auto-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")33 connack_packet = mosq_test.gen_connack(rc=0, proto_ver=proto_ver, properties=props)34 # Remove the "xxxx" part - this means the front part of the packet35 # is correct (so remaining length etc. is correct), but we don't36 # need to match against the random id.37 connack_packet = connack_packet[:-39]38 broker = mosq_test.start_broker(filename=os.path.basename(__file__), port=port1, use_conf=True)39 try:40 sock = mosq_test.do_client_connect(connect_packet, connack_packet, port=client_port)41 sock.close()42 rc = 043 except mosq_test.TestError:44 pass45 finally:46 broker.terminate()47 broker.wait()48 (stdo, stde) = broker.communicate()49 os.remove(conf_file)50 if rc:51 print(stde.decode('utf-8'))52 print("per_listener:%s proto_ver:%d client_port:%d clean_start:%d allow_zero:%s" % (per_listener, proto_ver, client_port, clean_start, allow_zero))53 print("port1:%d port2:%d" % (port1, port2))54 exit(rc)55(port1, port2) = mosq_test.get_port(2)56test_v4 = True57test_v5 = True58if test_v4 == True:59 do_test(per_listener="false", proto_ver=4, client_port=port1, clean_start=True, allow_zero="true", expect_fail=False)60 do_test(per_listener="false", proto_ver=4, client_port=port1, clean_start=True, allow_zero="false", expect_fail=True)61 do_test(per_listener="false", proto_ver=4, client_port=port1, clean_start=False, allow_zero="true", expect_fail=True)62 do_test(per_listener="false", proto_ver=4, client_port=port1, clean_start=False, allow_zero="false", expect_fail=True)63 do_test(per_listener="true", proto_ver=4, client_port=port1, clean_start=True, allow_zero="true", expect_fail=False)64 do_test(per_listener="true", proto_ver=4, client_port=port1, clean_start=True, allow_zero="false", expect_fail=True)65 do_test(per_listener="true", proto_ver=4, client_port=port1, clean_start=False, allow_zero="true", expect_fail=True)66 do_test(per_listener="true", proto_ver=4, client_port=port1, clean_start=False, allow_zero="false", expect_fail=True)67 do_test(per_listener="false", proto_ver=4, client_port=port2, clean_start=True, allow_zero="true", expect_fail=False)68 do_test(per_listener="false", proto_ver=4, client_port=port2, clean_start=True, allow_zero="false", expect_fail=True)69 do_test(per_listener="false", proto_ver=4, client_port=port2, clean_start=False, allow_zero="true", expect_fail=True)70 do_test(per_listener="false", proto_ver=4, client_port=port2, clean_start=False, allow_zero="false", expect_fail=True)71 do_test(per_listener="true", proto_ver=4, client_port=port2, clean_start=True, allow_zero="true", expect_fail=False)72 do_test(per_listener="true", proto_ver=4, client_port=port2, clean_start=True, allow_zero="false", expect_fail=True)73 do_test(per_listener="true", proto_ver=4, client_port=port2, clean_start=False, allow_zero="true", expect_fail=True)74 do_test(per_listener="true", proto_ver=4, client_port=port2, clean_start=False, allow_zero="false", expect_fail=True)75 do_test(per_listener="false", proto_ver=4, client_port=port1, clean_start=True, allow_zero="", expect_fail=False)76 do_test(per_listener="false", proto_ver=4, client_port=port1, clean_start=False, allow_zero="", expect_fail=True)77 do_test(per_listener="true", proto_ver=4, client_port=port1, clean_start=True, allow_zero="", expect_fail=False)78 do_test(per_listener="true", proto_ver=4, client_port=port1, clean_start=False, allow_zero="", expect_fail=True)79 do_test(per_listener="false", proto_ver=4, client_port=port2, clean_start=True, allow_zero="", expect_fail=False)80 do_test(per_listener="false", proto_ver=4, client_port=port2, clean_start=False, allow_zero="", expect_fail=True)81 do_test(per_listener="true", proto_ver=4, client_port=port2, clean_start=True, allow_zero="", expect_fail=False)82 do_test(per_listener="true", proto_ver=4, client_port=port2, clean_start=False, allow_zero="", expect_fail=True)83if test_v5 == True:84 do_test(per_listener="false", proto_ver=5, client_port=port1, clean_start=True, allow_zero="true", expect_fail=False)85 do_test(per_listener="false", proto_ver=5, client_port=port1, clean_start=True, allow_zero="false", expect_fail=True)86 do_test(per_listener="false", proto_ver=5, client_port=port1, clean_start=False, allow_zero="true", expect_fail=False)87 do_test(per_listener="false", proto_ver=5, client_port=port1, clean_start=False, allow_zero="false", expect_fail=True)88 do_test(per_listener="true", proto_ver=5, client_port=port1, clean_start=True, allow_zero="true", expect_fail=False)89 do_test(per_listener="true", proto_ver=5, client_port=port1, clean_start=True, allow_zero="false", expect_fail=True)90 do_test(per_listener="true", proto_ver=5, client_port=port1, clean_start=False, allow_zero="true", expect_fail=False)91 do_test(per_listener="true", proto_ver=5, client_port=port1, clean_start=False, allow_zero="false", expect_fail=True)92 do_test(per_listener="false", proto_ver=5, client_port=port2, clean_start=True, allow_zero="true", expect_fail=False)93 do_test(per_listener="false", proto_ver=5, client_port=port2, clean_start=True, allow_zero="false", expect_fail=True)94 do_test(per_listener="false", proto_ver=5, client_port=port2, clean_start=False, allow_zero="true", expect_fail=False)95 do_test(per_listener="false", proto_ver=5, client_port=port2, clean_start=False, allow_zero="false", expect_fail=True)96 do_test(per_listener="true", proto_ver=5, client_port=port2, clean_start=True, allow_zero="true", expect_fail=False)97 do_test(per_listener="true", proto_ver=5, client_port=port2, clean_start=True, allow_zero="false", expect_fail=True)98 do_test(per_listener="true", proto_ver=5, client_port=port2, clean_start=False, allow_zero="true", expect_fail=False)99 do_test(per_listener="true", proto_ver=5, client_port=port2, clean_start=False, allow_zero="false", expect_fail=True)100 do_test(per_listener="false", proto_ver=5, client_port=port1, clean_start=True, allow_zero="", expect_fail=False)101 do_test(per_listener="false", proto_ver=5, client_port=port1, clean_start=False, allow_zero="", expect_fail=False)102 do_test(per_listener="true", proto_ver=5, client_port=port1, clean_start=True, allow_zero="", expect_fail=False)103 do_test(per_listener="true", proto_ver=5, client_port=port1, clean_start=False, allow_zero="", expect_fail=False)104 do_test(per_listener="false", proto_ver=5, client_port=port2, clean_start=True, allow_zero="", expect_fail=False)105 do_test(per_listener="false", proto_ver=5, client_port=port2, clean_start=False, allow_zero="", expect_fail=False)106 do_test(per_listener="true", proto_ver=5, client_port=port2, clean_start=True, allow_zero="", expect_fail=False)107 do_test(per_listener="true", proto_ver=5, client_port=port2, clean_start=False, allow_zero="", expect_fail=False)...

Full Screen

Full Screen

text.inline.js

Source:text.inline.js Github

copy

Full Screen

...10 this._note.push(str);11 return '.' + this._note.length;12 }13}14function do_test(inline, test_case, parser) {15 for (let t of test_case) {16 let rv = inline(t[0]);17 test(`${t[0]} → ${t[1]}`, ()=>assert.equal(rv, t[1]));18 if (! t[2]) continue;19 let fn = parser._note[parser._note.length - 1];20 test(`${t[0]} → ${fn}`, ()=>assert.equal(fn, t[2]));21 }22}23suite('text/inline', ()=>{24suite('inline()', ()=>{25 const inline = require('../lib/text/inline')();26 test('require', ()=>assert.ok(inline));27 test('undefined → \'\'', ()=>assert.equal(inline(), ''));28 suite('markup', ()=>{29 suite('module', ()=>{30 const test_case = [31 [ '&_(tag param="1"){value};','<tag param="1">value</tag>' ],32 [ '&_(tag param="1"){};', '<tag param="1"></tag>' ],33 [ '&_(tag param="1");', '<tag param="1">' ],34 [ '&_(tag);', '<tag>' ],35 [ '&_(tag param="1" param);', '<tag param="1" param>' ],36 [ '&_(tag param=">");', '&amp;_(tag param=&quot;&gt;&quot;);' ],37 [ '&tag;', '&tag;' ],38 [ '&tag();', '&amp;tag();' ],39 [ '&_(tag){}};', '<tag>}</tag>' ],40 [ '&_(tag1){&_(tag2){}};};' , '<tag1><tag2>}</tag2></tag1>' ],41 ];42 do_test(inline, test_case);43 });44 suite('strong', ()=>{45 const test_case = [46 [ '**&strong**', '<strong>&amp;strong</strong>' ],47 [ '**\'\'strong\'\'**', '<strong><em>strong</em></strong>' ],48 ];49 do_test(inline, test_case);50 });51 suite('em', ()=>{52 const test_case = [53 [ '\'\'&em\'\'', '<em>&amp;em</em>' ],54 [ '\'\'%%em%%\'\'', '<em><del>em</del></em>' ],55 ];56 do_test(inline, test_case);57 });58 suite('del', ()=>{59 const test_case = [60 [ '%%&del%%', '<del>&amp;del</del>' ],61 [ '%%``em``%%', '<del><code>em</code></del>' ],62 ];63 do_test(inline, test_case);64 });65 suite('code', ()=>{66 const test_case = [67 [ '``&code``', '<code>&amp;code</code>' ],68 [ '``**code**``', '<code><strong>code</strong></code>' ],69 ];70 });71 suite('kbd', ()=>{72 const test_case = [73 [ '```&kbd```', '<kbd>&amp;kbd</kbd>' ],74 [ '```**kbd**```', '<kbd><strong>kbd</strong></kbd>' ],75 ];76 do_test(inline, test_case);77 });78 suite('as-is', ()=>{79 const test_case = [80 [ '{{&as-is}}', '&amp;as-is' ],81 [ '{{%%as-is%%}}', '%%as-is%%' ],82 [ '{{&#1234;}}', '&amp;#1234;' ],83 ];84 do_test(inline, test_case);85 });86 suite('bracket', ()=>{87 const test_case = [88 [ '[[&bracket]]', '<a href="&amp;bracket">&amp;bracket</a>' ],89 [ '[[A & B]]', '<a href="A%20&amp;%20B">A &amp; B</a>' ],90 [ '[[[bracket]]]', '[<a href="bracket">bracket</a>]' ],91 [ '[[bracket|./]]', '<a href="./">bracket</a>' ],92 [ '[[|bracket||./]]', '<a href="./">|bracket|</a>' ],93 [ '[[``bracket``]]', '<a href="%60%60bracket%60%60">``bracket``</a>'],94 [ '[[``bracket``|./]]', '<a href="./"><code>bracket</code></a>' ],95 [ '[[Home|/]]', '<a href="/">Home</a>' ],96 [ '[[テスト]]', '<a href="%E3%83%86%E3%82%B9%E3%83%88">テスト</a>' ],97 [ '[[100%|100%]]', '<a href="100%25">100%</a>' ],98 ];99 do_test(inline, test_case);100 });101 suite('footnote', ()=>{102 const test_case = [103 [ '((&footnote))', '(&amp;footnote)' ],104 [ '(([[note]]))', '(<a href="note">note</a>)' ],105 ];106 do_test(inline, test_case);107 });108 });109 suite('text', ()=>{110 suite('link', ()=>{111 const test_case = [112 [ 'http://kobalab.net/',113 '<a href="http://kobalab.net/">http://kobalab.net/</a>' ],114 [ 'mailto:koba@kobalab.net',115 '<a href="mailto:koba@kobalab.net">mailto:koba@kobalab.net</a>' ],116 [ 'koba@kobalab.net',117 '<a href="mailto:koba@kobalab.net">koba@kobalab.net</a>' ],118 [ 'http://kobalab.net/?a=1&b=2',119 '<a href="http://kobalab.net/?a=1&amp;b=2">'120 + 'http://kobalab.net/?a=1&amp;b=2</a>' ],121 [ '<koba@kobalab.net>',122 '&lt;<a href="mailto:koba@kobalab.net">koba@kobalab.net</a>&gt;' ],123 ];124 do_test(inline, test_case);125 });126 });127});128suite('inline(parser)', ()=>{129 const inline = require('../lib/text/inline')(parser);130 test('require', ()=>assert.ok(inline));131 suite('module', ()=>{132 const test_case = [133 [ '&name(param){value};', '&name(param){value};' ],134 [ '&name;', '&name;' ],135 ];136 do_test(inline, test_case, parser);137 });138 suite('noteref', ()=>{139 const test_case = [140 [ '((&noteref))',141 '<sup class="l-footnote"><a id="l-noteref.1" href="#l-footnote.1" '142 + 'title="&amp;noteref">*1</a></sup>',143 '&amp;noteref' ],144 [ '(([[&note]]))',145 '<sup class="l-footnote"><a id="l-noteref.2" href="#l-footnote.2" '146 + 'title="&amp;note">*2</a></sup>',147 '<a href="&amp;note">&amp;note</a>' ],148 ];149 do_test(inline, test_case, parser);150 });151 suite('bracket', ()=>{152 const test_case = [153 [ '[[Home|/]]', '<a href="/base/">Home</a>' ],154 ];155 do_test(inline, test_case);156 });157});...

Full Screen

Full Screen

run_tests.py

Source:run_tests.py Github

copy

Full Screen

...5from argparse import ArgumentParser6import re7import unittest8import os9def do_test(port, baudrate, test_name):10 databits = serial.EIGHTBITS11 stopbits = serial.STOPBITS_ONE12 parity = serial.PARITY_NONE13 ser = serial.Serial(port, baudrate, databits, parity, stopbits, timeout=10)14 ser.write('\n')15 finished = 016 success = False17 timeout = 10 # 10 seconds18 timeout_start = time.time()19 while True:20 serial_line = ser.readline()21 print(serial_line.replace('\n',''))22 if "nsh>" in serial_line:23 break24 elif "NuttShell (NSH)" in serial_line:25 break26 if time.time() > timeout_start + timeout:27 print("Error, timeout")28 break29 ser.write('\n')30 time.sleep(0.01)31 # run test cmd32 cmd = 'tests ' + test_name33 ser.write(cmd + '\n')34 timeout = 180 # 3 minutes35 timeout_start = time.time()36 timeout_newline = timeout_start37 while True:38 serial_line = ser.readline()39 print(serial_line.replace('\n',''))40 if cmd in serial_line:41 continue42 elif test_name + " PASSED" in serial_line:43 success = True44 break45 elif test_name + " FAILED" in serial_line:46 success = False47 break48 elif "nsh>" in serial_line:49 success = False50 break51 elif "NuttShell (NSH)" in serial_line:52 success = False53 break54 if time.time() > timeout_start + timeout:55 print("Error, timeout")56 print(test_name + " FAILED")57 success = False58 break59 # newline every 30 seconds if still running60 if time.time() - timeout_newline > 30:61 ser.write('\n')62 timeout_newline = time.time()63 ser.close()64 return success65class TestHadrwareMethods(unittest.TestCase):66 TEST_DEVICE = 067 TEST_BAUDRATE = 068 def test_bezier(self):69 self.assertTrue(do_test(self.TEST_DEVICE, self.TEST_BAUDRATE, "bezier"))70 def test_bson(self):71 self.assertTrue(do_test(self.TEST_DEVICE, self.TEST_BAUDRATE, "bson"))72 def test_commander(self):73 self.assertTrue(do_test(self.TEST_DEVICE, self.TEST_BAUDRATE, "commander"))74 def test_controllib(self):75 self.assertTrue(do_test(self.TEST_DEVICE, self.TEST_BAUDRATE, "controllib"))76# def test_dataman(self):77# self.assertTrue(do_test(self.TEST_DEVICE, self.TEST_BAUDRATE, "dataman"))78 def floattest_float(self):79 self.assertTrue(do_test(self.TEST_DEVICE, self.TEST_BAUDRATE, "float"))80 def test_hrt(self):81 self.assertTrue(do_test(self.TEST_DEVICE, self.TEST_BAUDRATE, "hrt"))82 def test_IntrusiveQueue(self):83 self.assertTrue(do_test(self.TEST_DEVICE, self.TEST_BAUDRATE, "IntrusiveQueue"))84 def test_List(self):85 self.assertTrue(do_test(self.TEST_DEVICE, self.TEST_BAUDRATE, "List"))86 def test_mathlib(self):87 self.assertTrue(do_test(self.TEST_DEVICE, self.TEST_BAUDRATE, "mathlib"))88 def test_matrix(self):89 self.assertTrue(do_test(self.TEST_DEVICE, self.TEST_BAUDRATE, "matrix"))90 def test_microbench_atomic(self):91 self.assertTrue(do_test(self.TEST_DEVICE, self.TEST_BAUDRATE, "microbench_atomic"))92 def test_microbench_hrt(self):93 self.assertTrue(do_test(self.TEST_DEVICE, self.TEST_BAUDRATE, "microbench_hrt"))94 def test_microbench_math(self):95 self.assertTrue(do_test(self.TEST_DEVICE, self.TEST_BAUDRATE, "microbench_math"))96 def test_microbench_matrix(self):97 self.assertTrue(do_test(self.TEST_DEVICE, self.TEST_BAUDRATE, "microbench_matrix"))98 def test_microbench_uorb(self):99 self.assertTrue(do_test(self.TEST_DEVICE, self.TEST_BAUDRATE, "microbench_uorb"))100# def test_mixer(self):101# self.assertTrue(do_test(self.TEST_DEVICE, self.TEST_BAUDRATE, "mixer"))102 def test_param(self):103 self.assertTrue(do_test(self.TEST_DEVICE, self.TEST_BAUDRATE, "param"))104 def test_parameters(self):105 self.assertTrue(do_test(self.TEST_DEVICE, self.TEST_BAUDRATE, "parameters"))106 def test_perf(self):107 self.assertTrue(do_test(self.TEST_DEVICE, self.TEST_BAUDRATE, "perf"))108 def search_mintest_xxx(self):109 self.assertTrue(do_test(self.TEST_DEVICE, self.TEST_BAUDRATE, "search_min"))110 def test_sleep(self):111 self.assertTrue(do_test(self.TEST_DEVICE, self.TEST_BAUDRATE, "sleep"))112 def test_smoothz(self):113 self.assertTrue(do_test(self.TEST_DEVICE, self.TEST_BAUDRATE, "smoothz"))114 def test_time(self):115 self.assertTrue(do_test(self.TEST_DEVICE, self.TEST_BAUDRATE, "time"))116 #def test_uorb(self):117 # self.assertTrue(do_test(self.TEST_DEVICE, self.TEST_BAUDRATE, "uorb"))118 def test_versioning(self):119 self.assertTrue(do_test(self.TEST_DEVICE, self.TEST_BAUDRATE, "versioning"))120def main():121 parser = ArgumentParser(description=__doc__)122 parser.add_argument('--device', "-d", nargs='?', default = None, help='')123 parser.add_argument("--baudrate", "-b", dest="baudrate", type=int, help="Mavlink port baud rate (default=57600)", default=57600)124 args = parser.parse_args()125 TestHadrwareMethods.TEST_DEVICE = args.device126 TestHadrwareMethods.TEST_BAUDRATE = args.baudrate127 unittest.main(__name__, argv=['main'])128if __name__ == "__main__":...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run gabbi automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful