mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
Signed-off-by: José Luis Di Biase <josx@interorganic.com.ar> Co-authored-by: José Luis Di Biase <josx@interorganic.com.ar> Co-authored-by: Oriana <oriana@camba.coop> Co-authored-by: Charlie <charlie@camba.coop> Co-authored-by: Juan Manuel Daza <61162223+juanmanueldaza@users.noreply.github.com> Co-authored-by: Juan Manuel Daza <juandaza@camba.coop> Co-authored-by: Cody Kociemba <cody@symbaventures.com> Co-authored-by: Rohit Malhotra <rohitvinodmalhotra@gmail.com> Co-authored-by: Engel Nyst <enyst@users.noreply.github.com>
57 lines
1.7 KiB
Python
57 lines
1.7 KiB
Python
from openhands.resolver.utils import extract_issue_references
|
|
|
|
|
|
def test_extract_issue_references():
|
|
# Test basic issue reference
|
|
assert extract_issue_references('Fixes #123') == [123]
|
|
|
|
# Test multiple issue references
|
|
assert extract_issue_references('Fixes #123, #456') == [123, 456]
|
|
|
|
# Test issue references in code blocks should be ignored
|
|
assert extract_issue_references("""
|
|
Here's a code block:
|
|
```python
|
|
# This is a comment with #123
|
|
def func():
|
|
pass # Another #456
|
|
```
|
|
But this #789 should be extracted
|
|
""") == [789]
|
|
|
|
# Test issue references in inline code should be ignored
|
|
assert extract_issue_references(
|
|
'This `#123` should be ignored but #456 should be extracted'
|
|
) == [456]
|
|
assert extract_issue_references(
|
|
'This `#123` should be ignored but #456 should be extracted'
|
|
) == [456]
|
|
|
|
# Test issue references in URLs should be ignored
|
|
assert extract_issue_references(
|
|
'Check http://example.com/#123 but #456 should be extracted'
|
|
) == [456]
|
|
assert extract_issue_references(
|
|
'Check http://example.com/#123 but #456 should be extracted'
|
|
) == [456]
|
|
|
|
# Test issue references in markdown links should be extracted
|
|
assert extract_issue_references('[Link to #123](http://example.com) and #456') == [
|
|
123,
|
|
456,
|
|
]
|
|
assert extract_issue_references('[Link to #123](http://example.com) and #456') == [
|
|
123,
|
|
456,
|
|
]
|
|
|
|
# Test issue references with text around them
|
|
assert extract_issue_references('Issue #123 is fixed and #456 is pending') == [
|
|
123,
|
|
456,
|
|
]
|
|
assert extract_issue_references('Issue #123 is fixed and #456 is pending') == [
|
|
123,
|
|
456,
|
|
]
|