test module#

Unit test support#

The way the JITX python framework is designed makes testing a bit more complicated than one would normally expect. The reason for this is how it handles instantiation of class members. This package provides a base TestCase class that sets up the JITX framework for testing by enabling objects to be instantiated within a test case. The main issue to note here is that if a class is created inside the test case, its members will _also_ be instantiated, as class members, and will not go through the instantiation process, which will likely lead to unexpected behavior, where normally an object would be expected to be an instantiated attribute (e.g. a Port).

class TestCase(methodName='runTest')[source]#

Bases: TestCase

Base test case class with JITX context setup.

This class sets up instantiation inside the test case, and registers a TestContext which can be interrogated inside the design if desired. For the vast majority of cases, this class should be used as a base class instead of unittest.TestCase when testing code that generates JITX design elements.

classmethod setUpClass()[source]#

Hook method for setting up class fixture before running tests in the class.

class TestContext(testClass)[source]#

Bases: Context

Context for test execution. Will be set automatically if using jitx.test.TestCase as a base class for your unit tests.

Parameters:

testClass (type[TestCase])

testClass: type[TestCase]#

The test class being executed.