()
| 105 | |
| 106 | |
| 107 | def 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 | |
| 159 | def test_requires_python_abbreviated_platform(): |
nothing calls this directly
no test coverage detected