[U-Boot] [PATCHv2 04/13] test/py: Fix pytest4 deprecation warnings

Tom Rini trini at konsulko.com
Wed Oct 23 03:20:01 UTC 2019


From: Marek Vasut <marek.vasut at gmail.com>

Fix the following spit from pytest:

u-boot/test/py/conftest.py:438: RemovedInPytest4Warning: MarkInfo objects are deprecated as they contain merged marks which are hard to deal with correctly.
  Please use node.get_closest_marker(name) or node.iter_markers(name).
  Docs: https://docs.pytest.org/en/latest/mark.html#updating-code
    for board in mark.args:

In both cases, the later suggestion is applicable.

Reviewed-by: Stephen Warren <swarren at nvidia.com>
Signed-off-by: Marek Vasut <marek.vasut+renesas at gmail.com>
Cc: Igor Opaniuk <igor.opaniuk at linaro.org>
Cc: Tom Rini <trini at konsulko.com>
Cc: Simon Glass <sjg at chromium.org>
[trini: Update for current file with a few more cases, un-pin pytest in CI]
Signed-off-by: Tom Rini <trini at konsulko.com>
---
 .gitlab-ci.yml      |  2 +-
 .travis.yml         |  2 +-
 test/py/conftest.py | 30 ++++++++++++------------------
 3 files changed, 14 insertions(+), 20 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index ab294997e463..5a34321570ce 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -20,7 +20,7 @@ stages:
     - ln -s travis-ci /tmp/uboot-test-hooks/py/`hostname`
     - virtualenv /tmp/venv
     - . /tmp/venv/bin/activate
-    - pip install pytest==2.8.7
+    - pip install pytest
     - pip install python-subunit
     - pip install coverage
     - grub-mkimage --prefix="" -o ~/grub_x86.efi -O i386-efi normal  echo lsefimmap lsefi lsefisystab efinet tftp minicmd
diff --git a/.travis.yml b/.travis.yml
index a3e7451bcb17..f61278f9656a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -49,7 +49,7 @@ install:
  - cat ~/.buildman
  - virtualenv /tmp/venv
  - . /tmp/venv/bin/activate
- - pip install pytest==2.8.7
+ - pip install pytest
  - pip install python-subunit
  - pip install pyelftools
  - grub-mkimage --prefix="" -o ~/grub_x86.efi -O i386-efi normal  echo lsefimmap lsefi lsefisystab efinet tftp minicmd
diff --git a/test/py/conftest.py b/test/py/conftest.py
index 00d8ef8ba99c..30c898b40a0d 100644
--- a/test/py/conftest.py
+++ b/test/py/conftest.py
@@ -431,11 +431,9 @@ def setup_boardspec(item):
         Nothing.
     """
 
-    mark = item.get_marker('boardspec')
-    if not mark:
-        return
     required_boards = []
-    for board in mark.args:
+    for boards in item.iter_markers('boardspec'):
+        board = boards.args[0]
         if board.startswith('!'):
             if ubconfig.board_type == board[1:]:
                 pytest.skip('board "%s" not supported' % ubconfig.board_type)
@@ -459,16 +457,14 @@ def setup_buildconfigspec(item):
         Nothing.
     """
 
-    mark = item.get_marker('buildconfigspec')
-    if mark:
-        for option in mark.args:
-            if not ubconfig.buildconfig.get('config_' + option.lower(), None):
-                pytest.skip('.config feature "%s" not enabled' % option.lower())
-    notmark = item.get_marker('notbuildconfigspec')
-    if notmark:
-        for option in notmark.args:
-            if ubconfig.buildconfig.get('config_' + option.lower(), None):
-                pytest.skip('.config feature "%s" enabled' % option.lower())
+    for options in item.iter_markers('buildconfigspec'):
+        option = options.args[0]
+        if not ubconfig.buildconfig.get('config_' + option.lower(), None):
+            pytest.skip('.config feature "%s" not enabled' % option.lower())
+    for option in item.iter_markers('notbuildconfigspec'):
+        option = options.args[0]
+        if ubconfig.buildconfig.get('config_' + option.lower(), None):
+            pytest.skip('.config feature "%s" enabled' % option.lower())
 
 def tool_is_in_path(tool):
     for path in os.environ["PATH"].split(os.pathsep):
@@ -491,10 +487,8 @@ def setup_requiredtool(item):
         Nothing.
     """
 
-    mark = item.get_marker('requiredtool')
-    if not mark:
-        return
-    for tool in mark.args:
+    for tools in item.iter_markers('requiredtool'):
+        tool = tools.args[0]
         if not tool_is_in_path(tool):
             pytest.skip('tool "%s" not in $PATH' % tool)
 
-- 
2.17.1



More information about the U-Boot mailing list