Check console script with Pytest

Pytest is the de facto standard for Python unit testing and continuous integration. To be complete in testing, one should test the interactive console scripts that for many Python programs is the main method of use.

Console script testing can be added through Pytest Console Scripts addon, but I usually simply use subprocess.check_call directly like Pytest Console Scripts addon does.


From the findssh package tests/

#!/usr/bin/env python
import pytest
import subprocess

def test_find():

if __name__ == '__main__':

Note that I did not include the .py suffix because my includes the argument:

```python entry_points={‘console_scripts’: [‘findssh = findssh:main’]},


which is useful for cross-platform uniform use–the user just types findssh no matter what platform they’re on.