()
| 554 | |
| 555 | |
| 556 | def _get_twisted_version() -> TwistedVersion: |
| 557 | # We need to check if "twisted.trial.unittest" is specifically present in sys.modules. |
| 558 | # This is because we intend to integrate with Trial only when it's actively running |
| 559 | # the test suite, but not needed when only other Twisted components are in use. |
| 560 | if "twisted.trial.unittest" not in sys.modules: |
| 561 | return TwistedVersion.NotInstalled |
| 562 | |
| 563 | import importlib.metadata |
| 564 | |
| 565 | import packaging.version |
| 566 | |
| 567 | version_str = importlib.metadata.version("twisted") |
| 568 | version = packaging.version.parse(version_str) |
| 569 | if version.major <= 24: |
| 570 | return TwistedVersion.Version24 |
| 571 | else: |
| 572 | return TwistedVersion.Version25 |
| 573 | |
| 574 | |
| 575 | # Name of the attribute in `twisted.python.Failure` instances that stores |
no test coverage detected