
Compared to tests in the repository root, tests in the package have many downsides: * Unless explicitly excluded in find_packages(), tests and their support code effectively become a part of public API. This, unfortunately, happened with FHDLTestCase, which was never intended for downstream use. * Even if explicitly excluded from the setuptools package, using an editable install, or setting PYTHONPATH still allows accessing the tests. * Having a sub-package that is present in the source tree but not exported (or, worse, exported only sometimes) is confusing. * The name `nmigen.test` cannot be used for anything else, such as testing utilities that *are* intended for downstream use.
22 lines
528 B
Python
22 lines
528 B
Python
import unittest
|
|
|
|
from nmigen._utils import _ignore_deprecated
|
|
from nmigen.compat import *
|
|
|
|
|
|
def _same_slices(a, b):
|
|
return a.value is b.value and a.start == b.start and a.stop == b.stop
|
|
|
|
|
|
class SignalSizeCase(unittest.TestCase):
|
|
def setUp(self):
|
|
self.i = C(0xaa)
|
|
self.j = C(-127)
|
|
with _ignore_deprecated():
|
|
self.s = Signal((13, True))
|
|
|
|
def test_len(self):
|
|
self.assertEqual(len(self.s), 13)
|
|
self.assertEqual(len(self.i), 8)
|
|
self.assertEqual(len(self.j), 8)
|