[PATCH] test: fix some pylint errors in test_bind.py

2022-04-30 Thread Heinrich Schuchardt
* Use spaces not tabs
* Limit lines to 100 spaces
* Remove an unused import
* Sort imports correctly
* Add a module description

Signed-off-by: Heinrich Schuchardt 
---
 test/py/tests/test_bind.py | 345 +++--
 1 file changed, 175 insertions(+), 170 deletions(-)

diff --git a/test/py/tests/test_bind.py b/test/py/tests/test_bind.py
index 8ad277da19..d7e6626d45 100644
--- a/test/py/tests/test_bind.py
+++ b/test/py/tests/test_bind.py
@@ -1,186 +1,191 @@
 # SPDX-License-Identifier: GPL-2.0
 # Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
 
-import os.path
-import pytest
+""" Test for bind command """
+
 import re
+import pytest
 
 def in_tree(response, name, uclass, drv, depth, last_child):
-   lines = [x.strip() for x in response.splitlines()]
-   leaf = ''
-   if depth != 0:
-   leaf = '   ' + '' * (depth - 1) ;
-   if not last_child:
-   leaf = leaf + r'\|'
-   else:
-leaf = leaf + '`'
-
-   leaf = leaf + '-- ' + name
-   line = (r' *{:10.10} *[0-9]*  \[ [ +] \]   {:20.20}  [` |]{}$'
-   .format(uclass, drv, leaf))
-   prog = re.compile(line)
-   for l in lines:
-   if prog.match(l):
-   return True
-   return False
+lines = [x.strip() for x in response.splitlines()]
+leaf = ''
+if depth != 0:
+leaf = '   ' + '' * (depth - 1)
+if not last_child:
+leaf = leaf + r'\|'
+else:
+leaf = leaf + '`'
+
+leaf = leaf + '-- ' + name
+line = (r' *{:10.10} *[0-9]*  \[ [ +] \]   {:20.20}  [` |]{}$'
+.format(uclass, drv, leaf))
+prog = re.compile(line)
+for l in lines:
+if prog.match(l):
+return True
+return False
 
 
 @pytest.mark.buildconfigspec('cmd_bind')
 def test_bind_unbind_with_node(u_boot_console):
 
-   tree = u_boot_console.run_command('dm tree')
-   assert in_tree(tree, 'bind-test', 'simple_bus', 'simple_bus', 0, True)
-   assert in_tree(tree, 'bind-test-child1', 'phy', 'phy_sandbox', 1, False)
-   assert in_tree(tree, 'bind-test-child2', 'simple_bus', 'simple_bus', 1, 
True)
-
-   #bind usb_ether driver (which has no compatible) to usb@1 node.
-   ##New entry usb_ether should appear in the dm tree
-   response = u_boot_console.run_command('bind  /usb@1 usb_ether')
-   assert response == ''
-   tree = u_boot_console.run_command('dm tree')
-   assert in_tree(tree, 'usb@1', 'ethernet', 'usb_ether', 1, True)
-
-   #Unbind child #1. No error expected and all devices should be there 
except for bind-test-child1
-   response = u_boot_console.run_command('unbind  
/bind-test/bind-test-child1')
-   assert response == ''
-   tree = u_boot_console.run_command('dm tree')
-   assert in_tree(tree, 'bind-test', 'simple_bus', 'simple_bus', 0, True)
-   assert 'bind-test-child1' not in tree
-   assert in_tree(tree, 'bind-test-child2', 'simple_bus', 'simple_bus', 1, 
True)
-
-   #bind child #1. No error expected and all devices should be there
-   response = u_boot_console.run_command('bind  
/bind-test/bind-test-child1 phy_sandbox')
-   assert response == ''
-   tree = u_boot_console.run_command('dm tree')
-   assert in_tree(tree, 'bind-test', 'simple_bus', 'simple_bus', 0, True)
-   assert in_tree(tree, 'bind-test-child1', 'phy', 'phy_sandbox', 1, True)
-   assert in_tree(tree, 'bind-test-child2', 'simple_bus', 'simple_bus', 1, 
False)
-
-   #Unbind child #2. No error expected and all devices should be there 
except for bind-test-child2
-   response = u_boot_console.run_command('unbind  
/bind-test/bind-test-child2')
-   assert response == ''
-   tree = u_boot_console.run_command('dm tree')
-   assert in_tree(tree, 'bind-test', 'simple_bus', 'simple_bus', 0, True)
-   assert in_tree(tree, 'bind-test-child1', 'phy', 'phy_sandbox', 1, True)
-   assert 'bind-test-child2' not in tree
-
-
-   #Bind child #2. No error expected and all devices should be there
-   response = u_boot_console.run_command('bind /bind-test/bind-test-child2 
simple_bus')
-   assert response == ''
-   tree = u_boot_console.run_command('dm tree')
-   assert in_tree(tree, 'bind-test', 'simple_bus', 'simple_bus', 0, True)
-   assert in_tree(tree, 'bind-test-child1', 'phy', 'phy_sandbox', 1, False)
-   assert in_tree(tree, 'bind-test-child2', 'simple_bus', 'simple_bus', 1, 
True)
-
-   #Unbind parent. No error expected. All devices should be removed and 
unbound
-   response = u_boot_console.run_command('unbind  /bind-test')
-   assert response == ''
-   tree = u_boot_console.run_command('dm tree')
-   assert 'bind-test' not in tree
-   assert 'bind-test-child1' not in tree
-   assert 'bind-test-child2' not in tree
-
-   #try binding invalid node with valid driver

Re: [PATCH] test: fix some pylint errors in test_bind.py

2022-06-28 Thread Simon Glass
* Use spaces not tabs
* Limit lines to 100 spaces
* Remove an unused import
* Sort imports correctly
* Add a module description

Signed-off-by: Heinrich Schuchardt 
---
 test/py/tests/test_bind.py | 345 +++--
 1 file changed, 175 insertions(+), 170 deletions(-)

Applied to u-boot-dm, thanks!