In the future, this pattern can be greatly simplified if you make the test a method of a class inheriting from `unittest.TestCase`. If you do so, you can use `self.assertRaises(AssertionError, Sparse(sparse_init=12).get_weights, rng, shape=(10, 12))`.
It is not blocking the PR.