diff mbox series

[nft,v2,7/7] tests/py: minor cleaning

Message ID 20180619214656.25636-8-eric@regit.org
State Accepted
Delegated to: Pablo Neira
Headers show
Series python install and build fixes | expand

Commit Message

Eric Leblond June 19, 2018, 9:46 p.m. UTC
Move import and use explicit parameter in object creation.
---
 tests/py/nft-test.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Phil Sutter June 20, 2018, 8:10 a.m. UTC | #1
Hi Eric,

On Tue, Jun 19, 2018 at 11:46:56PM +0200, Eric Leblond wrote:
> Move import and use explicit parameter in object creation.
> ---
>  tests/py/nft-test.py | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/tests/py/nft-test.py b/tests/py/nft-test.py
> index c02294a..fdc1cd5 100755
> --- a/tests/py/nft-test.py
> +++ b/tests/py/nft-test.py
> @@ -19,6 +19,10 @@ import argparse
>  import signal
>  import json
>  
> +sys.path.insert(0,'../../py/')
> +
> +from nftables import Nftables
> +
>  TESTS_PATH = os.path.dirname(os.path.abspath(__file__))
>  TESTS_DIRECTORY = ["any", "arp", "bridge", "inet", "ip", "ip6"]
>  LOGFILE = "/tmp/nftables-test.log"
> @@ -1329,7 +1333,6 @@ def main():
>      os.chdir(TESTS_PATH + "/../..")
>  
>      sys.path.append('py/')
> -    from nftables import Nftables

With that import statement moved to the top, I guess you can remove the
call to sys.path.append here also. AFAIU, the directory change should
not be problematic since the import caches the module's content and
therefore it doesn't matter that sys.path contains '../../py' which is
not valid anymore.

Apart from that, series LGTM!

Thanks, Phil
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Pablo Neira Ayuso June 20, 2018, 11:45 a.m. UTC | #2
On Wed, Jun 20, 2018 at 10:10:34AM +0200, Phil Sutter wrote:
> Hi Eric,
> 
> On Tue, Jun 19, 2018 at 11:46:56PM +0200, Eric Leblond wrote:
> > Move import and use explicit parameter in object creation.
> > ---
> >  tests/py/nft-test.py | 7 +++++--
> >  1 file changed, 5 insertions(+), 2 deletions(-)
> > 
> > diff --git a/tests/py/nft-test.py b/tests/py/nft-test.py
> > index c02294a..fdc1cd5 100755
> > --- a/tests/py/nft-test.py
> > +++ b/tests/py/nft-test.py
> > @@ -19,6 +19,10 @@ import argparse
> >  import signal
> >  import json
> >  
> > +sys.path.insert(0,'../../py/')
> > +
> > +from nftables import Nftables
> > +
> >  TESTS_PATH = os.path.dirname(os.path.abspath(__file__))
> >  TESTS_DIRECTORY = ["any", "arp", "bridge", "inet", "ip", "ip6"]
> >  LOGFILE = "/tmp/nftables-test.log"
> > @@ -1329,7 +1333,6 @@ def main():
> >      os.chdir(TESTS_PATH + "/../..")
> >  
> >      sys.path.append('py/')

I have removed this line above as you request.

> > -    from nftables import Nftables
> 
> With that import statement moved to the top, I guess you can remove the
> call to sys.path.append here also. AFAIU, the directory change should
> not be problematic since the import caches the module's content and
> therefore it doesn't matter that sys.path contains '../../py' which is
> not valid anymore.
> 
> Apart from that, series LGTM!

I'm going to apply this series with the change I'm indicating above.

Please, just follow up with an incremental patch in case of any
fallout.

Thanks!
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Phil Sutter June 21, 2018, 8:50 a.m. UTC | #3
On Wed, Jun 20, 2018 at 01:45:25PM +0200, Pablo Neira Ayuso wrote:
> On Wed, Jun 20, 2018 at 10:10:34AM +0200, Phil Sutter wrote:
> > Hi Eric,
> > 
> > On Tue, Jun 19, 2018 at 11:46:56PM +0200, Eric Leblond wrote:
> > > Move import and use explicit parameter in object creation.
> > > ---
> > >  tests/py/nft-test.py | 7 +++++--
> > >  1 file changed, 5 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/tests/py/nft-test.py b/tests/py/nft-test.py
> > > index c02294a..fdc1cd5 100755
> > > --- a/tests/py/nft-test.py
> > > +++ b/tests/py/nft-test.py
> > > @@ -19,6 +19,10 @@ import argparse
> > >  import signal
> > >  import json
> > >  
> > > +sys.path.insert(0,'../../py/')
> > > +
> > > +from nftables import Nftables
> > > +
> > >  TESTS_PATH = os.path.dirname(os.path.abspath(__file__))
> > >  TESTS_DIRECTORY = ["any", "arp", "bridge", "inet", "ip", "ip6"]
> > >  LOGFILE = "/tmp/nftables-test.log"
> > > @@ -1329,7 +1333,6 @@ def main():
> > >      os.chdir(TESTS_PATH + "/../..")
> > >  
> > >      sys.path.append('py/')
> 
> I have removed this line above as you request.
> 
> > > -    from nftables import Nftables
> > 
> > With that import statement moved to the top, I guess you can remove the
> > call to sys.path.append here also. AFAIU, the directory change should
> > not be problematic since the import caches the module's content and
> > therefore it doesn't matter that sys.path contains '../../py' which is
> > not valid anymore.
> > 
> > Apart from that, series LGTM!
> 
> I'm going to apply this series with the change I'm indicating above.

Acked-by: Phil Sutter <phil@nwl.cc> :)

Cheers, Phil
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox series

Patch

diff --git a/tests/py/nft-test.py b/tests/py/nft-test.py
index c02294a..fdc1cd5 100755
--- a/tests/py/nft-test.py
+++ b/tests/py/nft-test.py
@@ -19,6 +19,10 @@  import argparse
 import signal
 import json
 
+sys.path.insert(0,'../../py/')
+
+from nftables import Nftables
+
 TESTS_PATH = os.path.dirname(os.path.abspath(__file__))
 TESTS_DIRECTORY = ["any", "arp", "bridge", "inet", "ip", "ip6"]
 LOGFILE = "/tmp/nftables-test.log"
@@ -1329,7 +1333,6 @@  def main():
     os.chdir(TESTS_PATH + "/../..")
 
     sys.path.append('py/')
-    from nftables import Nftables
 
     if not os.path.exists('src/.libs/libnftables.so'):
         print "The nftables library does not exist. " \
@@ -1337,7 +1340,7 @@  def main():
         return
 
     global nftables
-    nftables = Nftables('src/.libs/libnftables.so')
+    nftables = Nftables(sofile = 'src/.libs/libnftables.so')
 
     test_files = files_ok = run_total = 0
     tests = passed = warnings = errors = 0