Getting rid of None in an option of TestFactory
See original GitHub issueHello everyone,
I did not find this in the documentation, so maybe you can push me in the right direction: I want to use TestFactory to supply a list of discrete values to create different tests. To achieve this, I create a function annotated with @cocotb.test run_test(dut, my_option=None) which has the general structure of my test, depending on the value of my_option. After defining this function, I do the following:
factory = TestFactory(run_test)
factory.add_option("my_option", list_of_values)
factory.generate_tests()
And it almost works as expected. It creates a test for each of my entries. However, the first test that gets created provides the value None to the parameter my_option. Therefore, I have one more test than intended which obviously fails, as I cannot do anything sensible with None in my test. I assume that this is the result of cocotb running all functions annotated with @cocotb.test if I don’t supply the TESTCASE environment variable. Using cocotb.coroutine as an annotation resolves my problem, but I highly appreciate the timeout functionality of the cocotb.test annotation. Is there a clean way how to ensure that the default implementation of my function is not used as a test, without the need to hardcode the test names in TESTCASE?
Cheers and thanks in advance!
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
Don’t decorate
run_test
withcocotb.test
, instead usecocotb.coroutine
.@ktbarrett, could you update the docs for
cocotb.test
to point totriggers.with_timeout
for an explanation of the timeout arguments?