You should just add testcase to this, and define self.testcase = testcase. Then pass self when instantiating the Keyboard object in GaiaTestCase.