示例#1
0
class TestBase(VSCTest):

    FIXTURE = Fixture

    FILENAME = None
    SOURCE = ''

    def setUp(self):
        super(TestBase, self).setUp()
        self._pathentry = PathEntry()
        # Tests run a new thread in the same process and use that
        # thread as the main thread -- the current thread which is
        # managing the test should be invisible to the debugger.
        import threading
        threading.current_thread().is_pydev_daemon_thread = True

        self._filename = None
        if self.FILENAME is not None:
            self.set_source_file(self.FILENAME, self.SOURCE)

    def tearDown(self):
        super(TestBase, self).tearDown()
        self._pathentry.cleanup()

    @property
    def pathentry(self):
        return self._pathentry

    @property
    def workspace(self):
        try:
            return vars(self)['_workspace']
            #return self._workspace
        except KeyError:
            self._workspace = Workspace()
            self.addCleanup(self._workspace.cleanup)
            return self._workspace

    @property
    def filename(self):
        return None if self._filename is None else self._filePath

    def _new_fixture(self, new_daemon):
        self.assertIsNotNone(self._filename)
        return self.FIXTURE(self._filename, new_daemon)

    def set_source_file(self, filename, content=None):
        self.assertIsNone(self._fix)
        if content is not None:
            filename = self.pathentry.write(filename, content=content)
        self.pathentry.install()
        self._filePath = filename
        self._filename = 'file:' + filename

    def set_module(self, name, content=None):
        self.assertIsNone(self._fix)
        if content is not None:
            self.write_module(name, content)
        self.pathentry.install()
        self._filename = 'module:' + name
示例#2
0
class TestBase(VSCTest):

    FIXTURE = Fixture

    FILENAME = None
    SOURCE = ''

    def setUp(self):
        super(TestBase, self).setUp()
        self._pathentry = PathEntry()

        self._filename = None
        if self.FILENAME is not None:
            self.set_source_file(self.FILENAME, self.SOURCE)

    def tearDown(self):
        super(TestBase, self).tearDown()
        self._pathentry.cleanup()

    @property
    def pathentry(self):
        return self._pathentry

    @property
    def workspace(self):
        try:
            return vars(self)['_workspace']
            #return self._workspace
        except KeyError:
            self._workspace = Workspace()
            self.addCleanup(self._workspace.cleanup)
            return self._workspace

    @property
    def filename(self):
        return None if self._filename is None else self._filePath

    def _new_fixture(self, new_daemon):
        self.assertIsNotNone(self._filename)
        return self.FIXTURE(self._filename, new_daemon)

    def set_source_file(self, filename, content=None):
        self.assertIsNone(self._fix)
        if content is not None:
            filename = self.pathentry.write(filename, content=content)
        self.pathentry.install()
        self._filePath = filename
        self._filename = 'file:' + filename

    def set_module(self, name, content=None):
        self.assertIsNone(self._fix)
        if content is not None:
            self.write_module(name, content)
        self.pathentry.install()
        self._filename = 'module:' + name