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.

TestFactory: Passing individual *args/**kwargs/ subcase identifier to run_test has changed/ stopped working in 1.6.0

See original GitHub issue

Using TestFactory, I am facing difficulties in providing test-individual arguments to run_test() in cocotb==1.6.0.

I will elaborate on an example using the test-inidividual subcase string:

  1. Prior usage ( with cocotb <= 1.5.2):

1.1 Assume a run_test, which gets a per-test individual string e.g. subcase as an argument.

[...]
@cocotb.test(timeout_time=200000, timeout_unit="us")
def run_test(dut, subcase=None):
	if not subcase:
		print("ERROR: Subcase is none!")
        [...]

1.2 Assume two different example test factories, which could provide the subcase string with cocotb <=1.5.2:

1.2.1 First example TestFactory

factory = TestFactory(run_test)
factory.add_option("subcase",  longListOfSubcases)
factory.generate_tests()

1.2.2 Second example TestFactory

factory = TestFactory(run_test)
 for case in longListOfSubcases:
 	setattr(mod, arbitraryVaryingName, _create_test(run_test, arbitraryVaryingName, "nodoc", mod, case))
  1. Current problem: I failed when trying different approaches for providing test-inidividual arguments to run_test(). Either with implicit arguments like substring or explicit arguments it did not work for me. I am not sure, whether it is a bug, or me using the software wrongly.

Suggestion: Please verify how to provide test-inidividual arguments in cocotb==1.6.0. Thank you.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:13 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
suzizecatcommented, Nov 16, 2021

Coming across this by chance. Isn’t this issue due to the fact that using the @cocotb.test() registers the function as a test on its own, thus running it outside the test factory with, obviously, None as a parameter (perhaps before starting the tests generated by the test factory) ?

On a very side note, be careful when using not stuff to test if stuff is None. In your example, if you have an empty subcase, it will be treated as a “None”. You might prefer using stuff is None instead.

0reactions
github-actions[bot]commented, Dec 17, 2021

Has your question been resolved? If so please close this issue. If it has not been resolved, you may need to provide more information. If no more activity on this issue occurs in 7 days, it will be closed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error "TestEngine with ID 'junit-vintage' failed to discover tests ...
I found the error. The dependency on spring-boot-starter-test brings a dependency on junit-vintage-engine . The latter must be excluded:
Read more >
Guide to Dynamic Tests in Junit 5 - Baeldung
A DynamicTest is a test generated during runtime. These tests are generated by a factory method annotated with the @TestFactory annotation.
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