Skip to contentSkip to conversation

test/py: Fix exception, do not parametrize with empty set

PATCH New Stefan Brüns 2 participants 6 messages Oct 16, 2016 – Oct 17, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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@[...]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]" ""
---

---
 test/py/conftest.py | 2 ++
 1 file changed, 2 insertions(+)
test/py/conftest.py +2 -0
index 5b3a923..ebef40d 100644
@@ -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']
Signature · 1 line
2.10.1
#1 lore raw

PATCH 1/1 test/py: Fix exception, do not parametrize with empty set

Quoted 6 lines · Stefan Br?ns

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>
---

Quoted 7 lines

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)

#2 lore raw

PATCH 1/1 test/py: Fix exception, do not parametrize with empty set

Quoted 17 lines · On Montag, 17. Oktober 2016 12:11:26 CEST Stephen Warren wrote:
Quoted 16 lines · Stefan Br?ns

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]" ""

Quoted 8 lines
Quoted 1 line

---

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

#3 lore raw

PATCH 1/1 test/py: Fix exception, do not parametrize with empty set

Quoted 25 lines · Stefan
Quoted 24 lines · On Montag, 17. Oktober 2016 12:11:26 CEST Stephen Warren wrote:
Quoted 13 lines · Stefan Br?ns

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:
---

Quoted 4 lines

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.

Quoted 7 lines
Quoted 1 line

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

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

#4 lore raw

PATCH 1/1 test/py: Fix exception, do not parametrize with empty set

Quoted 32 lines · Stephen Warren
Quoted 31 lines · Stefan
Quoted 19 lines · On Montag, 17. Oktober 2016 12:11:26 CEST Stephen Warren wrote:
Quoted 13 lines · Stefan Br?ns

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:
---

Quoted 4 lines

Exception: Block nesting mismatch:
"test_dfu[env__usb_dev_port0-env__dfu_config0]" ""

---

Quoted 7 lines

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

Quoted 8 lines
Quoted 3 lines

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.

#5 lore raw

PATCH 1/1 test/py: Fix exception, do not parametrize with empty set

In reply to Stefan Brüns
Quoted 6 lines · Stefan Br?ns

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>
---

Quoted 7 lines

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.