MCPcopy Index your code
hub / github.com/pex-tool/pex / test_requires_python_current

Function test_requires_python_current

tests/test_targets.py:107–156  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

105
106
107def test_requires_python_current():
108 # type: () -> None
109
110 current_target = targets.current()
111 major, minor, patch = current_target.interpreter.version
112 patch_is_zero = 0 == patch
113
114 def requires_python(template):
115 # type: (str) -> str
116 return template.format(major=major, minor=minor, patch=patch)
117
118 def assert_requires_python(
119 expected_result, # type: bool
120 template, # type: str
121 ):
122 # type: (...) -> None
123 assert_python_requirement_applies(
124 expected_result=expected_result,
125 target=current_target,
126 python_requirement=requires_python(template),
127 )
128
129 assert_requires_python(True, "~={major}.{minor}")
130
131 assert_requires_python(True, "=={major}.{minor}.*")
132 assert_requires_python(patch_is_zero, "=={major}.{minor}")
133 assert_requires_python(True, "=={major}.{minor}.{patch}")
134
135 assert_requires_python(True, "!={major}")
136 assert_requires_python(False, "!={major}.*")
137 assert_requires_python(not patch_is_zero, "!={major}.{minor}")
138 assert_requires_python(False, "!={major}.{minor}.*")
139 assert_requires_python(False, "!={major}.{minor}.{patch}")
140
141 assert_requires_python(False, "<{major}")
142 assert_requires_python(False, "<={major}")
143 assert_requires_python(False, "<{major}.{minor}")
144 assert_requires_python(patch_is_zero, "<={major}.{minor}")
145 assert_requires_python(False, "<{major}.{minor}.{patch}")
146 assert_requires_python(True, "<={major}.{minor}.{patch}")
147
148 assert_requires_python(True, ">{major}")
149 assert_requires_python(True, ">={major}")
150 assert_requires_python(not patch_is_zero, ">{major}.{minor}")
151 assert_requires_python(True, ">={major}.{minor}")
152 assert_requires_python(False, ">{major}.{minor}.{patch}")
153 assert_requires_python(True, ">={major}.{minor}.{patch}")
154
155 assert_requires_python(False, "==={major}.{minor}")
156 assert_requires_python(True, "==={major}.{minor}.{patch}")
157
158
159def test_requires_python_abbreviated_platform():

Callers

nothing calls this directly

Calls 2

assert_requires_pythonFunction · 0.85
currentMethod · 0.45

Tested by

no test coverage detected