forked from sagemath/sage
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sagemathgh-36989: OS-dependent doctest tags
# known bug: macos
, `# …
…known bug: linux` <!-- ^^^^^ Please provide a concise, informative and self-explanatory title. Don't put issue numbers in there, do this in the PR body below. For example, instead of "Fixes sagemath#1234" use "Introduce new method to calculate 1+1" --> <!-- Describe your changes here in detail --> <!-- Why is this change required? What problem does it solve? --> <!-- If this PR resolves an open issue, please link to it here. For example "Fixes sagemath#12345". --> <!-- If your change requires a documentation PR, please link it appropriately. --> Cherry-picked from - sagemath#36960 Author: @tobiasdiez Reviewer: @mkoeppe ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [x] The title is concise, informative, and self-explanatory. - [ ] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - sagemath#12345: short description why this is a dependency - sagemath#34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: sagemath#36989 Reported by: Matthias Köppe Reviewer(s):
- Loading branch information
Showing
7 changed files
with
171 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import sys | ||
|
||
import pytest | ||
from sage.doctest.parsing import SageDocTestParser, parse_optional_tags | ||
|
||
onlyLinux = pytest.mark.skipif( | ||
sys.platform != "linux", | ||
reason="No Linux system", | ||
) | ||
"""A decorator to specify that this function should only execute on Linux systems. | ||
""" | ||
|
||
|
||
def test_parse_optional_tags_known_bug_returns_bug(): | ||
tags = parse_optional_tags("sage: # known bug") | ||
assert tags == {"bug": None} | ||
|
||
|
||
def test_parse_optional_tags_known_bug_with_value_returns_bug_and_value(): | ||
tags = parse_optional_tags("sage: # known bug: linux") | ||
assert tags == {"bug": "linux"} | ||
|
||
|
||
def test_parse_optional_tags_known_bug_with_description_returns_bug(): | ||
tags = parse_optional_tags("sage: # known bug, #34506") | ||
assert tags == {"bug": None} | ||
|
||
|
||
def test_parse_optional_tags_known_bug_with_description_in_parentheses_returns_bug(): | ||
tags = parse_optional_tags("sage: # known bug (#34506)") | ||
assert tags == {"bug": None} | ||
|
||
|
||
def test_parse_optional_tags_known_bug_with_value_and_description_returns_bug_and_value(): | ||
tags = parse_optional_tags("sage: # known bug: linux (#34506)") | ||
assert tags == {"bug": "linux"} | ||
|
||
|
||
def test_parse_known_bug_returns_empty(): | ||
parser = SageDocTestParser(("sage",)) | ||
parsed = parser.parse("sage: x = int('1'*4301) # known bug") | ||
assert parsed == ["", ""] | ||
|
||
|
||
def test_parse_known_bug_returns_code_if_requested(): | ||
parser = SageDocTestParser(("sage", "bug")) | ||
parsed = parser.parse("sage: x = int('1'*4301) # known bug") | ||
assert len(parsed) == 3 | ||
assert parsed[1].sage_source == "x = int('1'*4301) # known bug\n" | ||
|
||
|
||
@onlyLinux | ||
def test_parse_known_bug_returns_code_if_requested_even_on_affected_os(): | ||
parser = SageDocTestParser(("sage", "bug")) | ||
parsed = parser.parse("sage: x = int('1'*4301) # known bug: macos") | ||
assert len(parsed) == 3 | ||
assert parsed[1].sage_source == "x = int('1'*4301) # known bug: macos\n" | ||
|
||
|
||
@onlyLinux | ||
def test_parse_known_bug_returns_code_on_not_affected_os(): | ||
parser = SageDocTestParser(("sage",)) | ||
parsed = parser.parse("sage: x = int('1'*4301) # known bug: macos") | ||
assert len(parsed) == 3 | ||
assert parsed[1].sage_source == "x = int('1'*4301) # known bug: macos\n" | ||
|
||
|
||
@onlyLinux | ||
def test_parse_known_bug_returns_empty_on_affected_os(): | ||
parser = SageDocTestParser(("sage",)) | ||
parsed = parser.parse("sage: x = int('1'*4301) # known bug: linux") | ||
assert parsed == ["", ""] | ||
|
||
|
||
def test_parse_known_bug_with_description_returns_empty(): | ||
parser = SageDocTestParser(("sage",)) | ||
parsed = parser.parse("sage: x = int('1'*4301) # known bug, #34506") | ||
assert parsed == ["", ""] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters