[U-Boot] [PATCH] test/py: Fix exception, do not parametrize with empty set

If the parameter set is empty, the pytest setup fails: --- call: <CallInfo when='setup' exception: got empty parameter set ['env__dfu_config'], function test_dfu at [...]test_dfu.py:107> ---
This aborts pytest_runtest_makereport and later leads to an exception during the report generation, as the call to log.start_section(...) is never executed: --- Exception: Block nesting mismatch: "test_dfu[env__usb_dev_port0-env__dfu_config0]" "" ---
Signed-off-by: Stefan Brüns stefan.bruens@rwth-aachen.de --- test/py/conftest.py | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/test/py/conftest.py b/test/py/conftest.py index 5b3a923..ebef40d 100644 --- a/test/py/conftest.py +++ b/test/py/conftest.py @@ -270,6 +270,8 @@ def generate_config(metafunc, fixture_name): # ... otherwise, see if there's a key that contains a list of # values to use instead. vals = subconfig.get(fixture_name+ 's', []) + if len(vals) == 0: + return def fixture_id(index, val): try: return val['fixture_id']

On 10/16/2016 12:17 PM, Stefan Brüns wrote:
If the parameter set is empty, the pytest setup fails:
call: <CallInfo when='setup' exception: got empty parameter set ['env__dfu_config'], function test_dfu at [...]test_dfu.py:107>
This aborts pytest_runtest_makereport and later leads to an exception during the report generation, as the call to log.start_section(...) is never executed:
Exception: Block nesting mismatch: "test_dfu[env__usb_dev_port0-env__dfu_config0]" ""
How do you trigger this? I believe my test setup has many cases where the test you added would trigger, but without the issues you mention, but I'm not 100% sure since I don't know for sure what is causing this issue.
Which pytest version do you have? I appear to have 2.5.1 (on Ubuntu Trusty)

On Montag, 17. Oktober 2016 12:11:26 CEST Stephen Warren wrote:
On 10/16/2016 12:17 PM, Stefan Brüns wrote:
If the parameter set is empty, the pytest setup fails:
call: <CallInfo when='setup' exception: got empty parameter set ['env__dfu_config'], function test_dfu at [...]test_dfu.py:107>
This aborts pytest_runtest_makereport and later leads to an exception during the report generation, as the call to log.start_section(...) is never executed:
Exception: Block nesting mismatch: "test_dfu[env__usb_dev_port0-env__dfu_config0]" ""
How do you trigger this? I believe my test setup has many cases where the test you added would trigger, but without the issues you mention, but I'm not 100% sure since I don't know for sure what is causing this issue.
Which pytest version do you have? I appear to have 2.5.1 (on Ubuntu Trusty)
1. You need "dfu_configs" to be empty 2. Maybe its pytest version dependent, IIRC I have 3.0.2
The first error above can be seen when running pytest with "--debug", it is written to IIRC pytestdebug.log
Kind regards,
Stefan

On 10/17/2016 01:18 PM, Brüns, Stefan wrote:
On Montag, 17. Oktober 2016 12:11:26 CEST Stephen Warren wrote:
On 10/16/2016 12:17 PM, Stefan Brüns wrote:
If the parameter set is empty, the pytest setup fails:
call: <CallInfo when='setup' exception: got empty parameter set ['env__dfu_config'], function test_dfu at [...]test_dfu.py:107>
This aborts pytest_runtest_makereport and later leads to an exception during the report generation, as the call to log.start_section(...) is never executed:
Exception: Block nesting mismatch: "test_dfu[env__usb_dev_port0-env__dfu_config0]" ""
How do you trigger this? I believe my test setup has many cases where the test you added would trigger, but without the issues you mention, but I'm not 100% sure since I don't know for sure what is causing this issue.
Which pytest version do you have? I appear to have 2.5.1 (on Ubuntu Trusty)
- You need "dfu_configs" to be empty
- Maybe its pytest version dependent, IIRC I have 3.0.2
The first error above can be seen when running pytest with "--debug", it is written to IIRC pytestdebug.log
Looks like this is a bug in pytest 3, and has been fixed upstream:
https://github.com/pytest-dev/pytest/issues/1849 Pytest 3.0 does not accept empty list in fixture

On 10/17/2016 04:01 PM, Stephen Warren wrote:
On 10/17/2016 01:18 PM, Brüns, Stefan wrote:
On Montag, 17. Oktober 2016 12:11:26 CEST Stephen Warren wrote:
On 10/16/2016 12:17 PM, Stefan Brüns wrote:
If the parameter set is empty, the pytest setup fails:
call: <CallInfo when='setup' exception: got empty parameter set ['env__dfu_config'], function test_dfu at [...]test_dfu.py:107>
This aborts pytest_runtest_makereport and later leads to an exception during the report generation, as the call to log.start_section(...) is never executed:
Exception: Block nesting mismatch: "test_dfu[env__usb_dev_port0-env__dfu_config0]" ""
How do you trigger this? I believe my test setup has many cases where the test you added would trigger, but without the issues you mention, but I'm not 100% sure since I don't know for sure what is causing this issue.
Which pytest version do you have? I appear to have 2.5.1 (on Ubuntu Trusty)
- You need "dfu_configs" to be empty
- Maybe its pytest version dependent, IIRC I have 3.0.2
The first error above can be seen when running pytest with "--debug", it is written to IIRC pytestdebug.log
Looks like this is a bug in pytest 3, and has been fixed upstream:
https://github.com/pytest-dev/pytest/issues/1849 Pytest 3.0 does not accept empty list in fixture
Actually, I take that back; that's something else. I'll keep looking.

On 10/16/2016 12:17 PM, Stefan Brüns wrote:
If the parameter set is empty, the pytest setup fails:
call: <CallInfo when='setup' exception: got empty parameter set ['env__dfu_config'], function test_dfu at [...]test_dfu.py:107>
This aborts pytest_runtest_makereport and later leads to an exception during the report generation, as the call to log.start_section(...) is never executed:
Exception: Block nesting mismatch: "test_dfu[env__usb_dev_port0-env__dfu_config0]" ""
This patch causes failures with pytest 2.5 when env__dfu_configs is an empty list or not set at all. I've created an alternative patch that seems to work with both pytest 2.5 and 3, which I'll send in a minute.
participants (3)
-
Brüns, Stefan
-
Stefan Brüns
-
Stephen Warren