Rename your pwd.py
to something else, such as winpwd.py
. Then use:
try:
import pwd
except ImportError:
import winpwd as pwd
By importing pwd
this way, you will get the built-in pwd
on Linux, and winpwd
on Windows. Then you should be able to run tests and mock it as you please.