MCPcopy
hub / github.com/pytest-dev/pytest / _get_twisted_version

Function _get_twisted_version

src/_pytest/unittest.py:556–572  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

554
555
556def _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

Callers 3

pytest_configureFunction · 0.85
pytest_runtest_protocolFunction · 0.85
_handle_twisted_exc_infoFunction · 0.85

Calls 1

parseMethod · 0.45

Tested by

no test coverage detected