kuznia-rdzeni / coreblocks

RISC-V out-of-order core for education and research purposes
https://kuznia-rdzeni.github.io/coreblocks/
BSD 3-Clause "New" or "Revised" License
36 stars 14 forks source link

Drop `unittest` from `TestCaseWithSimulator` #642

Closed lekcyjna123 closed 5 months ago

lekcyjna123 commented 6 months ago

In #553 #554 #611 we have added support for the pytest. This caused that we are supporting two testing libraries in parallel, which adds code and conceptual complexity to coreblocks. Particularly I have hit in that problem when adding the hypothesis in #573, where I had to integrate it with both unittest and pytest at the same time.

This PR want to drop unittest support and left only pytest. The most important changes are in TestCaseWithSimulator class where much of code from run_simulation was moved to separate fixtures. Whats more it was possible to drop the dirty trick with wrapping functions in DependencyContext.

There is a little drawback. If we want to use DependencyContext in setUp function we have to add one more line:

    @pytest.fixture(autouse=True)
    def setup(self, configure_dependency_context):

You can observe that in test/fu/functional_common.py. It is because we have to say that configure_dependency_context has to run before setup function.

ToDo:

Please say what is your opinion about these changes? Are they ok for you and can I migrate all the tests?

piotro888 commented 5 months ago

Some unit tests still use unitest.TestCase, is that intentional? unittest is also used in scripts.

lekcyjna123 commented 5 months ago

Good catch. I will prepare a separate review for that to doesn't delay this one.