import sublime
from sublime_plugin import ApplicationCommand
from .mixin import UnitTestingMixin
from .const import DONE_MESSAGE

try:
    from ColorSchemeUnit.lib.runner import ColorSchemeUnit
except Exception:
    print('ColorSchemeUnit runner could not be imported')


class UnitTestingColorSchemeCommand(ApplicationCommand, UnitTestingMixin):

    def run(self, package=None, **kargs):
        if not package:
            return

        window = sublime.active_window()
        settings = self.load_unittesting_settings(package, **kargs)
        stream = self.load_stream(package, settings["output"])

        tests = sublime.find_resources("color_scheme_test*")
        tests = [t for t in tests if t.startswith("Packages/%s/" % package)]

        if not tests:
            stream.write("ERROR: No syntax_test files are found in %s!" % package)
            stream.write("\n")
            stream.write(DONE_MESSAGE)
            stream.close()
            return

        # trigger "Start reading output"
        stream.write("Running ColorSchemeUnit\n")
        stream.flush()

        result = ColorSchemeUnit(window).run(output=stream, package=package, async=False)

        if result:
            stream.write('\n')
            stream.write("OK.\n")
        else:
            stream.write('\n')
            stream.write("FAILED.\n")

        stream.write("\n")
        stream.write(DONE_MESSAGE)
        stream.close()

@@ -127,149 +127,8 @@
 GE%0A%0A
-try:%0A    from ColorSchemeUnit.lib.runner import ColorSchemeUnit%0Aexcept Exception:%0A    print('ColorSchemeUnit runner could not be imported')%0A%0A
 %0Acla
@@ -459,16 +459,321 @@
 put%22%5D)%0A%0A
+        try:%0A            from ColorSchemeUnit.lib.runner import ColorSchemeUnit%0A        except ImportError:%0A            stream.write('ERROR: ColorSchemeUnit runner could not be imported')%0A            stream.write('%5Cn')%0A            stream.write(DONE_MESSAGE)%0A            stream.close()%0A            return%0A%0A
         

Fix #72 ColorSchemeUnit runner could not be imported