當前位置: 首頁>>代碼示例>>Python>>正文


Python config.TestConfig類代碼示例

本文整理匯總了Python中indico.tests.config.TestConfig的典型用法代碼示例。如果您正苦於以下問題:Python TestConfig類的具體用法?Python TestConfig怎麽用?Python TestConfig使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了TestConfig類的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _runSeleniumCycle

    def _runSeleniumCycle(self):
        """
        Run selenium over the existing test suite (or a specific test)
        """
        test_config = TestConfig.getInstance()


        mode = self.options.valueOf('mode', test_config.getRunMode())

        browser = self.options.valueOf('browser')
        if browser:
            browsers = [browser]
        elif mode == 'local':
            browsers = [test_config.getStandaloneBrowser()]
        else:
            browsers = test_config.getGridBrowsers()

        args = self._buildArgs()

        # Execute the tests
        result = True

        os.environ['INDICO_TEST_MODE'] = mode or ''
        os.environ['INDICO_TEST_URL'] = self.options.valueOf('server_url') or ''

        for browser in browsers:
            os.environ['INDICO_TEST_BROWSER'] = browser
            testResult = nose.run(argv=args)
            result = result and testResult
            self._info("%s: %s\n" % \
                       (browser, testResult and 'OK' or 'Error'))

        return result
開發者ID:VishrutMehta,項目名稱:indico,代碼行數:33,代碼來源:runners.py

示例2: setUpModule

def setUpModule():
    global webd
    config = TestConfig.getInstance()
    browser = os.environ['INDICO_TEST_BROWSER']
    mode = os.environ['INDICO_TEST_MODE']
    server_url = os.environ.get('INDICO_TEST_URL')

    if mode == 'remote':
        capabilities = {
            'firefox': DesiredCapabilities.FIREFOX,
            'chrome': DesiredCapabilities.FIREFOX,
            'ie': DesiredCapabilities.INTERNETEXPLORER,
            'ipad': DesiredCapabilities.IPAD,
            'iphone': DesiredCapabilities.IPHONE,
            'android': DesiredCapabilities.ANDROID,
            'htmlunit': DesiredCapabilities.HTMLUNITWITHJS
            }
        cap = capabilities[browser]
        webd = webdriver.Remote(server_url, desired_capabilities=cap)
    else:
        drivers = {
            'firefox': webdriver.Firefox,
            'chrome': webdriver.Chrome,
            'ie': webdriver.Ie
            }

        webd = drivers[browser]();
    webd.implicitly_wait(15)
開發者ID:bubbas,項目名稱:indico,代碼行數:28,代碼來源:seleniumTestCase.py

示例3: _setFakeConfig

    def _setFakeConfig(self, custom):
        """
        Sets a fake configuration for the current process, using a temporary directory
        """
        config = Config.getInstance()
        test_config = TestConfig.getInstance()

        temp = tempfile.mkdtemp(prefix="indico_")
        self._info('Using %s as temporary dir' % temp)

        os.mkdir(os.path.join(temp, 'log'))
        os.mkdir(os.path.join(temp, 'archive'))

        indicoDist = pkg_resources.get_distribution('indico')
        htdocsDir = indicoDist.get_resource_filename('indico', 'indico/htdocs')
        etcDir = indicoDist.get_resource_filename('indico', 'etc')

        # minimal defaults
        defaults = {
            'BaseURL': 'http://localhost:8000/indico',
            'BaseSecureURL': '',
            'UseXSendFile': False,
            'AuthenticatorList': ['Local'],
            'SmtpServer': ('localhost', 58025),
            'SmtpUseTLS': 'no',
            'DBConnectionParams': ('localhost', TestConfig.getInstance().getFakeDBPort()),
            'LogDir': os.path.join(temp, 'log'),
            'XMLCacheDir': os.path.join(temp, 'cache'),
            'HtdocsDir': htdocsDir,
            'ArchiveDir': os.path.join(temp, 'archive'),
            'UploadedFilesTempDir': os.path.join(temp, 'tmp'),
            'ConfigurationDir': etcDir
            }

        defaults.update(custom)

        # set defaults
        config.reset(defaults)

        Config.setInstance(config)
        self._cfg = config

        # re-configure logging and template generator, so that paths are updated
        from MaKaC.common import TemplateExec
        from MaKaC.common.logger import Logger
        TemplateExec.mako = TemplateExec._define_lookup()
        Logger.reset()
開發者ID:bubbas,項目名稱:indico,代碼行數:47,代碼來源:core.py

示例4: _runFakeWebServer

    def _runFakeWebServer(self):
        """
        Spawn a new refserver-based thread using the test db
        """
        config = TestConfig.getInstance()
        refserver = RefServer(config.getWebServerHost(), int(config.getWebServerPort()))

        t = threading.Thread(target=refserver.run)
        t.setDaemon(True)
        t.start()
        return refserver.addr
開發者ID:bubbas,項目名稱:indico,代碼行數:11,代碼來源:core.py

示例5: _setFakeConfig

    def _setFakeConfig(self, custom):
        """
        Sets a fake configuration for the current process, using a temporary directory
        """
        config = Config.getInstance()

        temp = tempfile.mkdtemp(prefix="indico_")
        self._info('Using %s as temporary dir' % temp)

        os.mkdir(os.path.join(temp, 'log'))
        os.mkdir(os.path.join(temp, 'archive'))

        indicoDist = pkg_resources.get_distribution('indico')
        htdocsDir = indicoDist.get_resource_filename('indico', 'indico/htdocs')
        etcDir = indicoDist.get_resource_filename('indico', 'etc')

        # minimal defaults
        defaults = {
            'Debug': True,
            'BaseURL': 'http://localhost:8000',
            'BaseSecureURL': '',
            'AuthenticatorList': [('Local', {})],
            'SmtpServer': ('localhost', 58025),
            'SmtpUseTLS': 'no',
            'DBConnectionParams': ('127.0.0.1', TestConfig.getInstance().getFakeDBPort()),
            'LogDir': os.path.join(temp, 'log'),
            'XMLCacheDir': os.path.join(temp, 'cache'),
            'HtdocsDir': htdocsDir,
            'ArchiveDir': os.path.join(temp, 'archive'),
            'UploadedFilesTempDir': os.path.join(temp, 'tmp'),
            'ConfigurationDir': etcDir
        }

        defaults.update(custom)

        # set defaults
        config.reset(defaults)

        Config.setInstance(config)
        self._cfg = config

        # Update assets environment
        core_env.directory = core_env.directory.replace('/opt/indico/htdocs', config.getHtdocsDir())
        core_env.load_path = [path.replace('/opt/indico/htdocs', config.getHtdocsDir()) for path in core_env.load_path]
        core_env.url_mapping = {path.replace('/opt/indico/htdocs', config.getHtdocsDir()): url for path, url in
                                core_env.url_mapping.iteritems()}
        core_env.config['PYSCSS_LOAD_PATHS'] = [x.replace('/opt/indico/htdocs', config.getHtdocsDir()) for x in
                                                core_env.config['PYSCSS_LOAD_PATHS']]

        # re-configure logging and template generator, so that paths are updated
        from MaKaC.common import TemplateExec
        from MaKaC.common.logger import Logger
        TemplateExec.mako = TemplateExec._define_lookup()
        Logger.reset()
開發者ID:Json-Andriopoulos,項目名稱:indico,代碼行數:54,代碼來源:core.py

示例6: _runFakeWebServer

    def _runFakeWebServer(self):
        """
        Spawn a new refserver-based thread using the test db
        """
        config = TestConfig.getInstance()
        server = WerkzeugServer(config.getWebServerHost(), int(config.getWebServerPort()), use_debugger=False)
        server.make_server()

        t = threading.Thread(target=server.run)
        t.setDaemon(True)
        t.start()
        return server.addr
開發者ID:iason-andr,項目名稱:indico,代碼行數:12,代碼來源:core.py

示例7: setup

    def setup(cls):

        # lazy import because we don't want it to be imported by default
        # (as the plugin system currently loads all submodules)
        from indico.tests.config import TestConfig

        PluginsHolder().loadAllPlugins()

        testConfig = TestConfig.getInstance()
        vidyoOptions = CollaborationTools.getPlugin("Vidyo").getOptions()

        vidyoOptions["indicoUsername"].setValue(testConfig.getCollaborationOptions()["Vidyo"]["indicoUsername"])
        vidyoOptions["indicoPassword"].setValue(testConfig.getCollaborationOptions()["Vidyo"]["indicoPassword"])

        cls._setupDone = True
開發者ID:Ictp,項目名稱:indico,代碼行數:15,代碼來源:vidyoTestTools.py

示例8: __init__

    def __init__(self, **kwargs):
        """
        Options can be passed as kwargs, currently the following is supported:

        """

        self.err = None
        self.out = None

        # make a TestConfig instance available everywhere
        self.config = TestConfig.getInstance()

        # initialize allowed options
        self.options = OptionProxy(self._runnerOptions)
        self.options.configure(**kwargs)
        self._logger = logging.getLogger('test')
開發者ID:VishrutMehta,項目名稱:indico,代碼行數:16,代碼來源:base.py

示例9: _startManageDB

    def _startManageDB(self):
        port = TestConfig.getInstance().getFakeDBPort()

        self._info("Starting fake DB in port %s" % port)
        self._startFakeDB('localhost', port)
開發者ID:bubbas,項目名稱:indico,代碼行數:5,代碼來源:core.py

示例10: buildConfFile

    def buildConfFile(self, confFilePath, coverage):
        """
        Builds a driver config file
        """
        confTemplateDir = os.path.join(self.setupDir,
                                        'javascript',
                                        'unit')
        confTemplatePath = os.path.join(confTemplateDir, 'confTemplate.conf')

        absoluteTestsDir = os.path.join(self.setupDir,
                                           "javascript",
                                           "unit",
                                           "tests")

        absolutePluginDir = os.path.join(self.setupDir,
                                            "..",
                                            "..",
                                            "indico",
                                            "MaKaC",
                                            "plugins")

        try:
            #lines needed to activate coverage plugin
            coverageConf = """\nplugin:
  - name: \"coverage\"
    jar: \"plugins/%s\"
    module: \"com.google.jstestdriver.coverage.CoverageModule\"""" % \
        TestConfig.getInstance().getJSCoverageFilename()
        except KeyError:
            return "Please, specify a JSCoverageFilename in tests.conf\n"


        try:
            #retrieve and store the template file
            f = open(confTemplatePath)
            confTemplate = f.read()
            f.close()

            #adding tests files from tests folder
            for root, __, files in os.walk(absoluteTestsDir):
                for name in files:
                    if name.endswith(".js"):
                        absoluteFilePath = os.path.join(root, name)
                        relativeFilePath = relpathto(confTemplateDir,
                                                     absoluteFilePath)

                        confTemplate += "\n  - %s" % os.path.join(relativeFilePath)


            #adding plugins test files
            for root, __, files in os.walk(absolutePluginDir):
                for name in files:
                    if name.endswith(".js") and \
                                          root.find("/tests/javascript/unit") > 0:
                        absoluteFilePath = os.path.join(root, name)
                        relativeFilePath = relpathto(confTemplateDir,
                                                     absoluteFilePath)

                        confTemplate += "\n  - %s" % os.path.join('..',
                                                                  '..',
                                                                  relativeFilePath)

            #addind coverage if necessary
            if coverage:
                confTemplate += coverageConf

            #writing the complete configuration in a file
            confFile = open(os.path.join(self.setupDir, 'javascript', 'unit',
                                         confFilePath), 'w')
            confFile.write(confTemplate)
            confFile.close()

            return ""
        except IOError, e:
            return "JS Unit Tests - Could not open a file. (%s)" % e
開發者ID:VishrutMehta,項目名稱:indico,代碼行數:75,代碼來源:runners.py

示例11: _run

    def _run(self):

        #conf file used at run time

        try:
            #Starting js-test-driver server
            server = subprocess.Popen(["java", "-jar",
                                       os.path.join(self.setupDir,
                                                    'javascript',
                                                    'unit',
                                                    TestConfig.getInstance().
                                                    getJSUnitFilename()),
                                        "--port",
                                        "9876",
                                        "--browser",
                                        "firefox"],
                                        stdout=subprocess.PIPE,
                                        stderr=subprocess.PIPE)
            time.sleep(2)

            #constructing conf file depending on installed plugins and
            #coverage activation

            success = self.buildConfFile(JSTEST_CFG_FILE, self.coverage)

            if success != "":
                self._error(success)
                return False

            #switching directory to run the tests
            os.chdir(os.path.join(self.setupDir, 'javascript', 'unit'))

            #check if server is ready
            for i in range(5):
                jsDryRun = commands.getstatusoutput(("java -jar "
                                             "%s"
                                             " --config "
                                             "%s"
                                             " --tests Fake.dryRun") %\
                                             (TestConfig.getInstance().
                                              getJSUnitFilename(),
                                              JSTEST_CFG_FILE))

                # Not very nice error checking, but how to do it nicely?
                if "browsers" in jsDryRun[1] or \
                    "Connection refused" in jsDryRun[1]:
                    print "Js-test-driver server has not started yet. " \
                          "Attempt #%s\n" % (i+1)
                    time.sleep(5)
                else:
                    #server is ready
                    break
            else:
                raise Exception('Could not start js unit tests because '
                                'js-test-driver server cannot be started.\n')

            #setting tests to run
            toTest = ""
            if self.specify:
                toTest = self.specify
            else:
                toTest = "all"

            command = ("java -jar %s "
                            "--config %s "
                            "--verbose "
                            "--tests %s ") % \
                            (TestConfig.getInstance().getJSUnitFilename(),
                             JSTEST_CFG_FILE,
                             toTest)

            if self.coverage:
                # path relative to the jar file
                command += "--testOutput %s" % \
                           os.path.join('..', '..', 'report', 'jscoverage')

            #running tests
            jsTest = commands.getoutput(command)


            #delete built conf file
            os.unlink(JSTEST_CFG_FILE)

            #restoring directory
            os.chdir(self.setupDir)

        except OSError, e:
            self._error("[ERR] Could not start js-test-driver server - command "
                        "\"java\" needs to be in your PATH. (%s)\n" % e)
開發者ID:VishrutMehta,項目名稱:indico,代碼行數:89,代碼來源:runners.py


注:本文中的indico.tests.config.TestConfig類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。