(
cls, name: str, bases: t.Sequence[t.Any], attrs: t.Dict[str, t.Any]
)
| 376 | } |
| 377 | |
| 378 | def __new__( |
| 379 | cls, name: str, bases: t.Sequence[t.Any], attrs: t.Dict[str, t.Any] |
| 380 | ) -> t.Any: |
| 381 | def make_test( |
| 382 | d: t.Dict[str, ExampleWithVariables], |
| 383 | ) -> collections.abc.Callable[["unittest.TestCase"], None]: |
| 384 | def _test_(self: "unittest.TestCase") -> None: |
| 385 | for k, v in d.items(): |
| 386 | with self.subTest(template=k, **v): |
| 387 | t = URITemplate(k) |
| 388 | self.assertEqual( |
| 389 | t.expand(v["expansion"]), v["expected"] |
| 390 | ) |
| 391 | |
| 392 | return _test_ |
| 393 | |
| 394 | examples = [ |
| 395 | (n, getattr(RFCTemplateExamples, n)) |
| 396 | for n in dir(RFCTemplateExamples) |
| 397 | if n.startswith("level") |
| 398 | ] |
| 399 | |
| 400 | for name, value in examples: |
| 401 | testname = "test_%s" % name |
| 402 | attrs[testname] = make_test(value) |
| 403 | |
| 404 | return type.__new__(cls, name, bases, attrs) # type: ignore |
| 405 | |
| 406 | |
| 407 | class TestURITemplate(unittest.TestCase, metaclass=RFCTemplateExamples): |
nothing calls this directly
no outgoing calls
no test coverage detected