In my code I have this for the regular gpios: try: import RPi.GPIO as GPIO except: import Mock.GPIO as GPIO # If not running on rpi, mock gpio Something similar for the hardware pwm would have been great!