question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Getting rid of None in an option of TestFactory

See original GitHub issue

Hello 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:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ktbarrettcommented, Apr 9, 2020

Don’t decorate run_test with cocotb.test, instead use cocotb.coroutine.

0reactions
eric-wiesercommented, Apr 10, 2020

@ktbarrett, could you update the docs for cocotb.test to point to triggers.with_timeout for an explanation of the timeout arguments?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Remove --none-- option from dependant field - ServiceNow
Solved: Hello Experts, How to remove --none-- option from dropdown of dependant field? I have one field named "Stage". Values of this field....
Read more >
Library Reference — cocotb 1.7.2 documentation
If the Task ran to completion, None is returned. If the Task failed with an exception, the exception is returned. If the Task...
Read more >
Advanced testing topics - Django documentation
The first option to do so is to add the hosts to your settings file. ... TestCase): def test_remove_image(self): os.remove(self.filename) self.
Read more >
Documentation - TestNG
The default name to use for a test. This specifies the name for a test defined on the command line. This option is...
Read more >
How to filter None's out of List[Option]? - scala - Stack Overflow
If you want to get rid of the options at the same time, you can use flatten : scala> someList.flatten res0: List[String] =...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found