There are a few issues with the robustness of the testDs9.py tests in AFW.
- The tests are skipped if the display_ds9 package can not be loaded but they should also skip if ds9 is missing or if ds9 can not be loaded. The latter is especially important during builds that unset $DISPLAY.
- The launching code in initDS9 can not notice the simple case of ds9 immediately failing to load. It simply assumes that there are delays in launch. The reason for this is that os.system does not return bad status if the command has been started in the background. Another scheme for starting ds9 should be considered. Maybe a different exception could be raised specifically for failing to start it.
- At the moment each test independently has a go at starting ds9. This makes the tests take a very long time (made worse by _mtv also trying multiple times) despite it being clear pretty quickly that ds9 is never going to work.
- Currently the mtv tests must run early as they are the only tests that attempt to start ds9 if it is not running. If the two tests that call mtv are disabled two other tests fail. Ideally the initDS9 code should be called in all cases.