class SuperTestCase(unittest.TestCase): """ Provides a base for higher level test cases. """ def setUp(self): """ Creates an application and almost launches it. """ logFileName = Path('tmp/app data/test.conf') Config._getConfigPathOptions = lambda s: [logFileName] if not logFileName.dirname().exists(): logFileName.dirname().makedirs() confParser = ConfigParser() self._setupConfigFile(confParser) confParser.write(logFileName) self.app = Application() self.app.loadConfiguration() self.app.preLaunch() self.client = FakeClient() self.package = Package('temp') self.app.webServer.root.bindNewPackage(self.package) self.mainpage = self.app.webServer.root.children['temp'] def tearDown(self): """ Remove the global app instance """ from exe import globals globals.application = None def _setupConfigFile(self, configParser): """ Override this to setup any customised config settings """ system = configParser.addSection('system') system.exePath = '../exe/exe' system.exeDir = '../exe' system.webDir = '../exe/webui' system.localeDir = '../exe/locale' system.port = 8081 tmpDir = Path('tmp') if not tmpDir.exists(): tmpDir.mkdir() dataDir = tmpDir/'data' if not dataDir.exists(): dataDir.mkdir() system.dataDir = dataDir system.browserPath = 'not really used in tests so far' logging = configParser.addSection('logging') logging.root = 'DEBUG' def _request(self, **kwargs): """ Pass me args and I return you a fake request object. eg. self._request(action='addIdevice').args['action'][0] == 'addIdevice' """ return FakeRequest(**kwargs)
'fulldata': self._HTMLParser__starttag_text, 'line': self.lineno, 'offset': self.offset, 'tag': tag, 'attr': attr_name, 'type': 'tag' } self.HTMLDATA.append(datadict) if __name__ == "__main__": # Load eXe configuration application = Application() application.processArgs() application.loadConfiguration() # We have to make sure eXe has english configured as its language to prevent it # from pre-translating the templates application.config.locale = 'en' application.config.loadLocales() # List of strings that shouldn't make it to the .po files excluded_strings = [u'', u'.', u'...', u'\n'] # Open output file and write generation date file_w = open(application.config.templatesDir / u'strings.py', 'w') file_w.write(u'# Generated on %s\n' % str(datetime.now())) file_w.write(u'\ntemplates = {\n')
action="store_true", dest="website", help=_(u"Include Web Site export files").encode(sys.stdout.encoding), default=False) parser.add_option_group(group) return parser if __name__ == "__main__": application = Application() if '--standalone' in sys.argv: application.standalone = True sys.argv.remove("--standalone") application.loadConfiguration() application.preLaunch() optparse._ = application.config.locales[application.config.locale].gettext parser = prepareParser() options, args = parser.parse_args() if options.x and options.i: parser.error(_(u'Options --export and --import are mutually \ exclusive.').encode(sys.stdout.encoding)) if not options.x and not options.i and not options.set_options and not options.report: parser.error(_(u'No --export, --import, --set or --report option supplied.')\ .encode(sys.stdout.encoding)) if not args:
class SuperTestCase(unittest.TestCase): """ Provides a base for higher level test cases. """ def setUp(self): """ Creates an application and almost launches it. """ # Make whatever config class that application uses only look for our # Set up our customised config file logFileName = Path('tmp/app data/test.conf') Config._getConfigPathOptions = lambda s: [logFileName] if not logFileName.dirname().exists(): logFileName.dirname().makedirs() confParser = ConfigParser() self._setupConfigFile(confParser) confParser.write(logFileName) # Start up the app and friends self.app = Application() self.app.loadConfiguration() self.app.preLaunch() self.client = FakeClient() self.package = Package('temp') self.app.webServer.root.bindNewPackage(self.package) self.mainpage = self.app.webServer.root.children['temp'] def tearDown(self): """ Remove the global app instance """ from exe import globals globals.application = None def _setupConfigFile(self, configParser): """ Override this to setup any customised config settings """ # Set up the system section system = configParser.addSection('system') system.exePath = '../exe/exe' system.exeDir = '../exe' system.webDir = '../exe/webui' system.localeDir = '../exe/locale' system.port = 8081 # Make a temporary dir where we can save packages and exports etc tmpDir = Path('tmp') if not tmpDir.exists(): tmpDir.mkdir() dataDir = tmpDir / 'data' if not dataDir.exists(): dataDir.mkdir() system.dataDir = dataDir system.browserPath = 'not really used in tests so far' # Setup the logging section logging = configParser.addSection('logging') logging.root = 'DEBUG' def _request(self, **kwargs): """ Pass me args and I return you a fake request object. eg. self._request(action='addIdevice').args['action'][0] == 'addIdevice' """ return FakeRequest(**kwargs)