The default open mode for NamedTemporaryFile is 'wb+'. Force non-binary 'w+' mode so that yaml.dump() works.
Signed-off-by: Adrian Moreno amorenoz@redhat.com --- lnst/Tests/TRex.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lnst/Tests/TRex.py b/lnst/Tests/TRex.py index aa65231..e09be00 100644 --- a/lnst/Tests/TRex.py +++ b/lnst/Tests/TRex.py @@ -136,7 +136,7 @@ class TRexServer(TRexCommon): {'src_mac': str(src["mac_addr"]), 'dest_mac': str(dst["mac_addr"])})
- with tempfile.NamedTemporaryFile() as cfg_file: + with tempfile.NamedTemporaryFile(mode="w+") as cfg_file: yaml.dump(trex_server_conf, cfg_file) cfg_file.flush() os.fsync(cfg_file.file.fileno())