From 8bb6204d50373ad99b769f8cf42850ae30551c08 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Thu, 14 Apr 2016 21:40:04 -0400 Subject: nat/vty: Fix construct not working with python 2.6 Use the simpler approach and just call encode('hex') on the str and then convert it to lower case to keep the tests working. reproduce: Python 2.6.6 (r266:84292, Dec 27 2010, 00:02:40) [GCC 4.4.5] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> d = '\0\0' >>> d '\x00\x00' >>> "".join("{:02x}".format(ord(c)) for c in d) Traceback (most recent call last): File "", line 1, in File "", line 1, in ValueError: zero length field name in format fixes: ====================================================================== ERROR: testBSCreload (__main__.TestVTYNAT) ---------------------------------------------------------------------- Traceback (most recent call last): File "./vty_test_runner.py", line 658, in testBSCreload b0 = nat_bsc_sock_test(0, "lol") File "./vty_test_runner.py", line 1150, in nat_bsc_sock_test ipa_handle_small(bsc, verbose) File "./vty_test_runner.py", line 1116, in ipa_handle_small s = data2str(x.recv(4)) File "./vty_test_runner.py", line 1100, in data2str return "".join("{:02x}".format(ord(c)) for c in d) File "./vty_test_runner.py", line 1100, in return "".join("{:02x}".format(ord(c)) for c in d) ValueError: zero length field name in format ---------------------------------------------------------------------- --- openbsc/tests/vty_test_runner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'openbsc/tests') diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index a767ff075..143ba5d00 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -1097,7 +1097,7 @@ def nat_msc_ip(x, ip, port): x.vty.command("end") def data2str(d): - return "".join("{:02x}".format(ord(c)) for c in d) + return d.encode('hex').lower() def nat_msc_test(x, ip, port, verbose = False): msc = socket.socket(socket.AF_INET, socket.SOCK_STREAM) -- cgit v1.2.3