generated from BCDevOps/opendev-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from bcgov/pr5
updating stable to include latest fixes including adding "latest update" plugin
- Loading branch information
Showing
9 changed files
with
140 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Unit Tests | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
run_tests: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.10' | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install pytest | ||
- name: Test with pytest | ||
run: | | ||
pytest |
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 |
---|---|---|
|
@@ -41,3 +41,4 @@ Thumbs.db | |
/.idea/* | ||
/test.sh | ||
__pycache__ | ||
.vscode/ |
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
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,86 @@ | ||
from patcher import patch | ||
|
||
def test_ignores_bullets_in_code_blocks(): | ||
input = """```yaml | ||
example: | ||
- item1 | ||
- item2 | ||
``` | ||
""" | ||
result = patch(input.splitlines(True)) | ||
result = ''.join(result) | ||
assert result == input | ||
|
||
def test_bullets_formatted_outside_of_code_blocks(): | ||
input = """introduction sentence | ||
- item1 | ||
- item2 | ||
""" | ||
expected_result = """introduction sentence | ||
- item1 | ||
- item2 | ||
""" | ||
|
||
result = patch(input.splitlines(True)) | ||
result = ''.join(result) | ||
assert result == expected_result | ||
|
||
# 4 backticks escapes code blocks. Used in markdown when you want to display the markdown for a code block | ||
def test_ignore_bullets_in_escaped_code_blocks(): | ||
input = """```` | ||
```yaml | ||
example: | ||
- item1 | ||
- item2 | ||
``` | ||
```` | ||
""" | ||
result = patch(input.splitlines(True)) | ||
result = ''.join(result) | ||
assert result == input | ||
|
||
# Test a more complex case. Escaped code block, bulletted list and another code block | ||
def test_code_blocks_and_bullets(): | ||
input = """```` | ||
```yaml | ||
example: | ||
- item1 | ||
- item2 | ||
``` | ||
```` | ||
another line | ||
- bullet 1 | ||
- bullet 2 | ||
more code | ||
``` | ||
something: | ||
- x | ||
- y | ||
``` | ||
""" | ||
|
||
expected_result = """```` | ||
```yaml | ||
example: | ||
- item1 | ||
- item2 | ||
``` | ||
```` | ||
another line | ||
- bullet 1 | ||
- bullet 2 | ||
more code | ||
``` | ||
something: | ||
- x | ||
- y | ||
``` | ||
""" | ||
|
||
result = patch(input.splitlines(True)) | ||
result = ''.join(result) | ||
assert result == expected_result |
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