Add test for section splitting (for #312)

This commit is contained in:
Anatoli Babenia 2021-10-22 13:29:41 +03:00
parent cbf001cede
commit 3d1e4ec2f9
3 changed files with 29 additions and 1 deletions

View file

@ -17,8 +17,10 @@ jobs:
run: pip install --upgrade -r requirements.txt
- name: fetch upstream cheat sheets
run: python lib/fetch.py fetch-all
- name: run tests
- name: run bash tests
run: bash tests/run-tests.sh
- name: run pytest
run: pytest lib/
docker:
runs-on: ubuntu-20.04

25
lib/cheat_wrapper_test.py Normal file
View file

@ -0,0 +1,25 @@
from cheat_wrapper import _add_section_name
unchanged = """
python/:list
ls
btrfs~volume
:intro
:cht.sh
python/copy+file
python/rosetta/:list
emacs:go-mode/:list
"""
split = """
python copy file
python/copy file
"""
def test_header_split():
for inp in unchanged.strip().splitlines():
assert inp == _add_section_name(inp)
for test in split.strip().split('\n\n'):
inp, outp = test.split('\n')
assert outp == _add_section_name(inp)

View file

@ -15,3 +15,4 @@ pycld2
colorama
pyyaml
python-Levenshtein
pytest