Re: [PATCH nft] nft-test.py: use tempfile module

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Eric!

On Tue, Jun 18, 2019 at 11:51 PM Eric Garver <eric@xxxxxxxxxxx> wrote:
>
> os.tmpfile() is not in python3.
>
Did not know that. It should resolve the problem. Thanks!

---
>  tests/py/nft-test.py | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/tests/py/nft-test.py b/tests/py/nft-test.py
> index f80517e67bfd..4da6fa650f6d 100755
> --- a/tests/py/nft-test.py
> +++ b/tests/py/nft-test.py
> @@ -20,6 +20,7 @@ import argparse
>  import signal
>  import json
>  import traceback
> +import tempfile
>
>  TESTS_PATH = os.path.dirname(os.path.abspath(__file__))
>  sys.path.insert(0, os.path.join(TESTS_PATH, '../../py/'))
> @@ -771,7 +772,7 @@ def rule_add(rule, filename, lineno, force_all_family_option, filename_path):
>              unit_tests += 1
>              table_flush(table, filename, lineno)
>
> -            payload_log = os.tmpfile()
> +            payload_log = tempfile.TemporaryFile(mode="w+")
>
>              # Add rule and check return code
>              cmd = "add rule %s %s %s" % (table, chain, rule[0])
> @@ -911,7 +912,7 @@ def rule_add(rule, filename, lineno, force_all_family_option, filename_path):
>                                gotf.name, 1)
>
>              table_flush(table, filename, lineno)
> -            payload_log = os.tmpfile()
> +            payload_log = tempfile.TemporaryFile(mode="w+")
>
>              # Add rule in JSON format
>              cmd = json.dumps({ "nftables": [{ "add": { "rule": {
> --
> 2.20.1
>


Shekhar



[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux