diff options
author | Phil Sutter <phil@nwl.cc> | 2019-10-29 12:20:18 +0100 |
---|---|---|
committer | Phil Sutter <phil@nwl.cc> | 2019-10-29 13:16:35 +0100 |
commit | 6b53baa89f5b6a0c1d2520820d9654418cda7105 (patch) | |
tree | 716a35d4d0aabf93b824f5ab40fb4562959707f6 /tests | |
parent | 707ad229d48f2ba7920541527b755b155ddedcda (diff) |
tests/py: Fix test script for Python3 tempfile
When instantiating a temporary file using tempfile's TemporaryFile()
constructor, the resulting object's 'name' attribute is of type int.
This in turn makes print_msg() puke while trying to concatenate string
and int using '+' operator.
Fix this by using format strings consequently, thereby cleaning up code
a bit.
Signed-off-by: Phil Sutter <phil@nwl.cc>
Acked-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/py/nft-test.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/tests/py/nft-test.py b/tests/py/nft-test.py index bc0849e0..ce42b5dd 100755 --- a/tests/py/nft-test.py +++ b/tests/py/nft-test.py @@ -115,12 +115,12 @@ def print_msg(reason, errstr, filename=None, lineno=None, color=None): ''' Prints a message with nice colors, indicating file and line number. ''' + color_errstr = "%s%s%s" % (color, errstr, Colors.ENDC) if filename and lineno: - sys.stderr.write(filename + ": " + color + errstr + Colors.ENDC + \ - " line %d: %s" % (lineno + 1, reason)) + sys.stderr.write("%s: %s line %d: %s\n" % + (filename, color_errstr, lineno + 1, reason)) else: - sys.stderr.write(color + errstr + Colors.ENDC + " %s" % reason) - sys.stderr.write("\n") + sys.stderr.write("%s %s\n" % (color_errstr, reason)) sys.stderr.flush() # So that the message stay in the right place. |