{"repo":"nschloe/pytest-codeblocks","free":true,"listed":false,"github":"https://github.com/nschloe/pytest-codeblocks","clone":"git clone https://github.com/nschloe/pytest-codeblocks.git","description":":page_facing_up: Test code blocks in your READMEs","language":"Python","stars":120,"topics":["python","markdown","testing","pytest"],"license":"MIT","category":"dev-tools","readme_excerpt":"Test code blocks in your READMEs. This is pytest-codeblocks, a pytest plugin for testing code blocks from README files. It supports Python and shell code. Install with and run pytest with pytest-codeblocks will only pick up code blocks with python and sh / bash / zsh syntax highlighting. Marking code blocks It is possible to use pytest.mark for marking code blocks. For example, to skip a code block use pytest.mark.skip or pytest.mark.skipif : python foo + bar # not working You can skip code blocks on import errors with Skip the entire file by putting in the first line. For expected errors, use pytest.mark.xfail : python 1 / 0 Merging code blocks Broken-up code blocks can be merged into one with the pytest-codeblocks:cont prefix python a = 1 python this would otherwise fail since a is not defined a + 1 If you'd like to prepend code that you don't want to show, you can just comment it out; pytest-codeblocks will pick it up anyway: python a = 1 python this would otherwise fail since a is not defined a + 1 Expected output You can also define the expected output of a code block: sh print(1 + 3) 4 Use expected-output-ignore-whitespace if you'd like whitespace differences to be ignored. (Conditionally) Skipping the output verfication works by prepending the first block with skip / skipif (see above).","default_branch":null,"files":null,"tree":[],"storefront":"/r/nschloe","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/nschloe/pytest-codeblocks/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}