Don't call abort unless test is scheduled.
If cocotb initialization fails, such as when the test module cannot be
imported, the scheduler attempts to call abort() on a non-existent
test, which throws:
AttributeError: 'NoneType' object has no attribute 'abort'
@@ -775,6 +775,10 @@ class Scheduler(object):
"""Directly call into the regression manager and end test
once we return the sim will close us so no cleanup is needed.
"""
+ # If there is an error during cocotb initialization, self._test may not
+ # have been set yet. Don't cause another Python exception here.
+
+ if self._test:
self.log.debug("Issue sim closedown result to regression object")
self._test.abort(exc)
cocotb.regression_manager.handle_result(self._test)
