Skip to content

Latest commit

 

History

History

ep001

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

I build out a simple skeleton for a command line interface in python and show how to test it with pytest!

thanks to PanosTrak for the question!

Setup commands

virtualenv venv

. venv/bin/activate

pip install pytest

# if you want to try babi
pip install babi

Interactive examples

Python

import hello

dir(hello)
hello.main()

hello.__name__
__name__

Bash

python -S <<< 'exit'

python -S <<< 'import pytest'

echo $?

bash -c 'exit 2'; echo $?

bash -c 'exit 42'

prev_exit_code=$?

echo "$prev_exit_code"