|
6 | 6 |
|
7 | 7 | from cuda.core._utils.enum_explanations_helpers import ( |
8 | 8 | DocstringBackedExplanations, |
| 9 | + _binding_version_has_usable_enum_docstrings, |
9 | 10 | _strip_doxygen_double_colon_prefixes, |
10 | 11 | clean_enum_member_docstring, |
11 | 12 | ) |
@@ -96,25 +97,43 @@ def test_docstring_backed_get_returns_default_for_missing_docstring_without_fall |
96 | 97 | assert lut.get(7, default="sentinel") == "sentinel" |
97 | 98 |
|
98 | 99 |
|
99 | | -def test_get_best_available_explanations_uses_fallback_before_13_2(monkeypatch): |
100 | | - import cuda.core._utils.enum_explanations_helpers as cleanup |
101 | | - |
102 | | - fallback = {7: "fallback text"} |
103 | | - monkeypatch.setattr(cleanup, "_binding_version", lambda: (13, 1, 1)) |
104 | | - assert cleanup.get_best_available_explanations(_FakeEnumType({7: _FakeEnumMember("doc")}), fallback) is fallback |
| 100 | +@pytest.mark.parametrize( |
| 101 | + ("version", "expected"), |
| 102 | + [ |
| 103 | + pytest.param((12, 9, 5), False, id="before_12_9_6"), |
| 104 | + pytest.param((12, 9, 6), True, id="from_12_9_6"), |
| 105 | + pytest.param((13, 0, 0), False, id="13_0_mainline_gap"), |
| 106 | + pytest.param((13, 1, 1), False, id="13_1_1"), |
| 107 | + pytest.param((13, 2, 0), True, id="from_13_2_0"), |
| 108 | + ], |
| 109 | +) |
| 110 | +def test_binding_version_has_usable_enum_docstrings(version, expected): |
| 111 | + assert _binding_version_has_usable_enum_docstrings(version) is expected |
105 | 112 |
|
106 | 113 |
|
107 | | -def test_get_best_available_explanations_prefers_docstrings_from_13_2(monkeypatch): |
| 114 | +@pytest.mark.parametrize( |
| 115 | + ("version", "expects_docstrings"), |
| 116 | + [ |
| 117 | + pytest.param((12, 9, 5), False, id="before_12_9_6"), |
| 118 | + pytest.param((12, 9, 6), True, id="from_12_9_6"), |
| 119 | + pytest.param((13, 0, 0), False, id="13_0_mainline_gap"), |
| 120 | + pytest.param((13, 2, 0), True, id="from_13_2_0"), |
| 121 | + ], |
| 122 | +) |
| 123 | +def test_get_best_available_explanations_switches_by_version(monkeypatch, version, expects_docstrings): |
108 | 124 | import cuda.core._utils.enum_explanations_helpers as cleanup |
109 | 125 |
|
110 | 126 | fallback = {7: "fallback text"} |
111 | | - monkeypatch.setattr(cleanup, "_binding_version", lambda: (13, 2, 0)) |
| 127 | + monkeypatch.setattr(cleanup, "_binding_version", lambda: version) |
112 | 128 | expl = cleanup.get_best_available_explanations( |
113 | 129 | _FakeEnumType({7: _FakeEnumMember("clean me")}), |
114 | 130 | fallback, |
115 | 131 | ) |
116 | | - assert isinstance(expl, DocstringBackedExplanations) |
117 | | - assert expl.get(7) == "clean me" |
| 132 | + if expects_docstrings: |
| 133 | + assert isinstance(expl, DocstringBackedExplanations) |
| 134 | + assert expl.get(7) == "clean me" |
| 135 | + else: |
| 136 | + assert expl is fallback |
118 | 137 |
|
119 | 138 |
|
120 | 139 | def test_driver_cu_result_explanations_get_matches_clean_docstring(): |
|
0 commit comments