def setUp(self):
     self.platform_settings = PlatformSettingsOSX(executable_path="some_executable_path",
                                                 cmdline_args="some-cmdline_args")
    class PlatformSettingsOSXTest(unittest.TestCase):

        platform_settings = None
    
        def setUp(self):
            self.platform_settings = PlatformSettingsOSX(executable_path="some_executable_path",
                                                        cmdline_args="some-cmdline_args")


        def test_set_enable_autostart(self):
            # Set path for launch agent to current dir
            self.platform_settings.LAUNCH_AGENTS_PATH = "."
            exptected_launch_agent_pathname = os.path.join(self.platform_settings.LAUNCH_AGENTS_PATH, self.platform_settings.LAUNCH_AGENT_PLIST_FILENAME)
            try:
                self.platform_settings.set_autostart(True)
                self.assertTrue(os.path.exists(exptected_launch_agent_pathname))
            finally:
                os.unlink(exptected_launch_agent_pathname)

        def test_set_twice_enable_autostart(self):
            # Set path for launch agent to current dir
            self.platform_settings.LAUNCH_AGENTS_PATH = "."
            exptected_launch_agent_pathname = os.path.join(self.platform_settings.LAUNCH_AGENTS_PATH, self.platform_settings.LAUNCH_AGENT_PLIST_FILENAME)
            try:
                self.platform_settings.set_autostart(True)
                self.platform_settings.set_autostart(True)
                self.assertTrue(os.path.exists(exptected_launch_agent_pathname))
            finally:
                os.unlink(exptected_launch_agent_pathname)

        def test_set_enable_autostart_without_launch_agent_folder(self):
            self.platform_settings.LAUNCH_AGENTS_PATH = "./non-existing-path"

            # Just to be sure...
            if os.path.exists(self.platform_settings.LAUNCH_AGENTS_PATH):
                if os.path.isdir(self.platform_settings.LAUNCH_AGENTS_PATH):
                    import shutil
                    shutil.rmtree(self.platform_settings.LAUNCH_AGENTS_PATH)
                else:
                    os.unlink(self.platform_settings.LAUNCH_AGENTS_PATH)

            exptected_launch_agent_pathname = os.path.join(self.platform_settings.LAUNCH_AGENTS_PATH, self.platform_settings.LAUNCH_AGENT_PLIST_FILENAME)

            try:
                self.platform_settings.set_autostart(True)
                self.assertTrue(os.path.exists(exptected_launch_agent_pathname))
            finally:
                os.unlink(exptected_launch_agent_pathname)
                os.rmdir(self.platform_settings.LAUNCH_AGENTS_PATH)


        def test_set_disable_autostart(self):
            # Set path for launch agent to current dir
            self.platform_settings.LAUNCH_AGENTS_PATH = "."
            exptected_launch_agent_pathname = os.path.join(self.platform_settings.LAUNCH_AGENTS_PATH, self.platform_settings.LAUNCH_AGENT_PLIST_FILENAME)
            self.platform_settings.set_autostart(False)
            self.assertTrue(not os.path.exists(exptected_launch_agent_pathname))

        def test_set_disable_autostart_twice(self):
            # Set path for launch agent to current dir
            self.platform_settings.LAUNCH_AGENTS_PATH = "."
            exptected_launch_agent_pathname = os.path.join(self.platform_settings.LAUNCH_AGENTS_PATH, self.platform_settings.LAUNCH_AGENT_PLIST_FILENAME)
            self.platform_settings.set_autostart(False)
            self.platform_settings.set_autostart(False)
            self.assertTrue(not os.path.exists(exptected_launch_agent_pathname))

        def test_set_disable_autostart_with_existing_agent(self):
            # Set path for launch agent to current dir
            self.platform_settings.LAUNCH_AGENTS_PATH = "."
            exptected_launch_agent_pathname = os.path.join(self.platform_settings.LAUNCH_AGENTS_PATH, self.platform_settings.LAUNCH_AGENT_PLIST_FILENAME)
            try:
                with open(exptected_launch_agent_pathname, "w") as fp:
                    fp.write("")
                self.platform_settings.set_autostart(False)
                self.assertTrue(not os.path.exists(exptected_launch_agent_pathname))
            finally:
                if os.path.exists(exptected_launch_agent_pathname):
                    os.unlink(exptected_launch_agent_pathname)


        def test_is_systray_icon_whitelisted(self):
            self.assertTrue(self.platform_settings.is_systray_icon_whitelisted)