The optcomplete module lacks unittests, in particular the core function optcomplete.autocomplete(). For instance, the completions part towards the end does not appear to be fully covered. The unittest names should be looked over and doc strings added where missing. At the moment, it's not obvious what's testing what.