summaryrefslogtreecommitdiffstats
path: root/openbsc/tests/vty_test_runner.py
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2016-04-14 21:40:04 -0400
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2016-04-14 21:40:04 -0400
commit8bb6204d50373ad99b769f8cf42850ae30551c08 (patch)
treed05cc50f61d294dc03cf6693c9a06d97ef86256b /openbsc/tests/vty_test_runner.py
parent2abf2b072d7616ffa760461b6d6bd44a28490066 (diff)
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 "<stdin>", line 1, in <module> File "<stdin>", line 1, in <genexpr> 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 <genexpr> return "".join("{:02x}".format(ord(c)) for c in d) ValueError: zero length field name in format ----------------------------------------------------------------------
Diffstat (limited to 'openbsc/tests/vty_test_runner.py')
-rw-r--r--openbsc/tests/vty_test_runner.py2
1 files changed, 1 insertions, 1 deletions
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)