• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python test.main函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中test.main函数的典型用法代码示例。如果您正苦于以下问题:Python main函数的具体用法?Python main怎么用?Python main使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了main函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_script

 def test_script(self, execute_manager):
     # The test script should execute the standard Django test
     # command with any apps given as its arguments.
     test.main('cheeseshop.development',  'spamm', 'eggs')
     # We only care about the arguments given to execute_manager
     self.assertEqual(execute_manager.call_args[1],
                      {'argv': ['test', 'test', 'spamm', 'eggs']})
开发者ID:carlitux,项目名称:djbuild,代码行数:7,代码来源:tests.py


示例2: test_deeply_nested_settings

    def test_deeply_nested_settings(self, execute_manager):
        # Settings files can be more than two levels deep. We need to
        # make sure the test script can properly import those. To
        # demonstrate this we need to add another level to our
        # sys.modules entries.
        settings = mock.sentinel.SettingsModule
        nce = mock.sentinel.NCE
        nce.development = settings
        sys.modules['cheeseshop'].nce = nce
        sys.modules['cheeseshop.nce'] = nce
        sys.modules['cheeseshop.nce.development'] = settings

        test.main('cheeseshop.nce.development',  'tilsit', 'stilton')
        self.assertEqual(execute_manager.call_args[0], (settings,))
开发者ID:carlitux,项目名称:djbuild,代码行数:14,代码来源:tests.py


示例3: run

def run():
	global USE_GPUS
	val_num = np.random.randint(1, 6)
	cifar10_input.set_constants(train=True, val_num=val_num)
	if USE_GPUS:			
		import cifar10_multi_gpu_train
		cifar10_multi_gpu_train.main()
	else:
		import cifar10_train
		cifar10_train.main()
	if TEST:
		test.main()
	else:
		cifar10_input.set_constants(train=False, val_num=val_num)
		cifar10_eval.main()
开发者ID:phrayezzen,项目名称:COMP540,代码行数:15,代码来源:cifar_validate.py


示例4: exampleSetup

def exampleSetup(): 
	import test
	data4,data5,handover_starts,l0,U0,l1,U1e,U1,l2,U2,U2e,ainds,alabs = test.main()

	def loader(handover_starts,data_object,n): 
		try: 
			starts = [handover_starts[n],handover_starts[n+1]]
		except IndexError: 
			starts = [handover_starts[n],data_object.num_vectors-1]
		return starts

	def runTasks(data_obj,task_obj,n,max_ind=10): 
		inds = np.random.randint(max_ind,size=n)
		for i in inds: 
			task_obj.update(data_obj,loader(handover_starts,data_obj,i))

	#initializing a task for the data4 object then showing the times for each path member
	task = Task(data4,loader(handover_starts,data4,0))
	print task.times
	out = task.printTaskDef()

	#updating a task for the data4 object then showing the times for each path member
	task.update(data4,loader(handover_starts,data4,1))
	print task.times
	out = task.printTaskDef()

	#or can do: 
	task = Task(data4,loader(handover_starts,data4,0))
	n = 20 #run 20 random updates from the handover set
	runTasks(data4,task,n,max_ind=11)
开发者ID:jvahala,项目名称:lucid-robotics,代码行数:30,代码来源:process.py


示例5:

#!/usr/bin/env python
# -*- coding: UTF-8 -*-

#
# Copyright 2016 sadikovi
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import sys
import test
sys.exit(test.main())
开发者ID:sadikovi,项目名称:queue,代码行数:22,代码来源:__main__.py


示例6: main

import pyximport; pyximport.install()
from test import main

main()
开发者ID:ctm22396,项目名称:dailyprogrammer,代码行数:4,代码来源:exec_test.py


示例7: main

def main():
    """TODO: Docstring for main.
    :returns: TODO

    """
    test.main()
开发者ID:ShiehShieh,项目名称:shieh-recsys,代码行数:6,代码来源:test.py


示例8: open

        
        total_run_time += time_use

    tree_information = {
        'max_depth': master.max_depth,
        'min_bag_size': master.min_bag_size,
        'total_run_time': total_run_time,
        'avg_run_time': total_run_time/(number_of_tree*1.0),
        'file_list': file_list
    }

    with open(os.path.join(tree_root_folder, mainfile), 'w') as f:
        json.dump(tree_information, f, indent=2)

    print('\n{} Tree(s) creation successful'.format(number_of_tree))
    print('Total run time: {} sec'.format(total_run_time))
    print('Avg run time per tree: {} sec'.format(1.0*total_run_time/number_of_tree*1.0))

if __name__ == '__main__':
    if len(sys.argv) < 3:
        print('Usage: {} <main JSON file name> <dataset file> [optional:number of tree]')
        sys.exit(1)
    elif len(sys.argv) == 3:
        main(sys.argv[1], sys.argv[2])
    elif len(sys.argv) == 4:
        main(sys.argv[1], sys.argv[2], int(sys.argv[3]))

    clmax = 5

    test.main(clmax, os.path.join(tree_root_folder, sys.argv[1]))
开发者ID:wasit7,项目名称:ImageSearch,代码行数:29,代码来源:main.py


示例9: print

    'Intended Audience :: Developers',
    'Intended Audience :: Information Technology',
    'License :: OSI Approved :: BSD License',
    'Programming Language :: Cython',
    'Programming Language :: Python :: 2',
    'Programming Language :: Python :: 2.3',
    'Programming Language :: Python :: 2.4',
    'Programming Language :: Python :: 2.5',
    'Programming Language :: Python :: 2.6',
    'Programming Language :: Python :: 3',
    'Programming Language :: Python :: 3.0',
    'Programming Language :: C',
    'Operating System :: OS Independent',
    'Topic :: Text Processing :: Markup :: HTML',
    'Topic :: Text Processing :: Markup :: XML',
    'Topic :: Software Development :: Libraries :: Python Modules'
    ],

    package_dir = {'': 'src'},
    packages = ['lxml', 'lxml.html'],
    ext_modules = setupinfo.ext_modules(
        STATIC_INCLUDE_DIRS, STATIC_LIBRARY_DIRS,
        STATIC_CFLAGS, STATIC_BINARIES),
    **extra_options
)

if OPTION_RUN_TESTS:
    print("Running tests.")
    import test
    sys.exit( test.main(sys.argv[:1]) )
开发者ID:kery-chen,项目名称:lxml-maintenance,代码行数:30,代码来源:setup.py


示例10:

    parser.add_argument('--init_emb', default=None, help='Initial embedding to be loaded')
    parser.add_argument('--opt', default='adam', help='optimization method')
    parser.add_argument('--lr', type=float, default=0.01, help='learning rate')
    parser.add_argument('--reg', type=float, default=0.0001, help='L2 Reg rate')
    parser.add_argument('--batch', type=int, default=32, help='batch size')
    parser.add_argument('--epoch', type=int, default=500, help='number of epochs to train')
    parser.add_argument('--no-shuffle', action='store_true', default=False, help='don\'t shuffle training data')

    """ test options """
    parser.add_argument('--model', default=None, help='path to model')
    parser.add_argument('--arg_dict', default=None, help='path to arg dict')
    parser.add_argument('--vocab_dict', default=None, help='path to vocab dict')
    parser.add_argument('--emb_dict', default=None, help='path to emb dict')

    argv = parser.parse_args()

    print
    print argv
    print

    if argv.mode == 'train':
        import train
        train.main(argv)
    else:
        import test
        assert argv.model is not None
        assert argv.arg_dict is not None
        assert argv.vocab_dict is not None
        assert argv.emb_dict is not None
        test.main(argv)
开发者ID:hiroki13,项目名称:neural-semantic-role-labeler,代码行数:30,代码来源:main.py


示例11: test

def test():
    import test
    test.main()
开发者ID:sadikovi,项目名称:octohaven,代码行数:3,代码来源:octohaven.py


示例12: OptionParser

                        output_dir + '/%s-%s' % (test, plot_file),
                        )


if __name__ == "__main__":
    
    parser = OptionParser()
    parser.add_option('-b', '--BuildName', default=None)
    (options, args) = parser.parse_args()

    print "Are you sure you want to rerun the entire test suite? (y/n)"
    print "You will create a lot of images and it may take a while"
    res = raw_input()
    if res == 'y':
        print "RUNNING ALL TEST CASES AND SAVING IT"
        test.main(options.BuildName) 
        dir_name = make_dir_name()
        if not os.path.exists(dir_name):
            os.mkdir(dir_name)
        print 'Copying data to ' + dir_name
        shutil.copy('test_results/test_event_results.html', dir_name)
        shutil.copy('test_results/test_event_results.csv', dir_name)
        shutil.copy('test_results/test_frame_results.html', dir_name)
        shutil.copy('test_results/test_frame_results.csv', dir_name)


        # so that it renders in github
        shutil.copy('test_results/test_event_results_bw.html', dir_name + '/' + 'README.md')
        shutil.copy('test_results/test_frame_results_bw.html', dir_name + '/' + 'README.md')
        copy_test_plots('test_suite/test_cases/', dir_name)
        
开发者ID:chrisngan24,项目名称:fydp,代码行数:30,代码来源:make_test_results.py


示例13: generate

def generate():
	test.parsedata(T.get())
	prog_list = test.main()
	output = sorted(list(prog_list), key=len)
	T2.insert(END, output[0])
开发者ID:BambooL,项目名称:pbe,代码行数:5,代码来源:ui.py


示例14: evaluate

def evaluate(sb, options):
    state = EvalState()
    phase_argv = ['--sandbox', sb.get_root()]
    with ioutil.WorkingDir(sb.get_root()) as td:
        with sb.lock('eval') as lock:
            try:
                try:
                    if not options.no_update:
                        with Phase(state, EvalPhase.UPDATE, lock) as phase:
                            state.err = update(sb, lock)
                    if not state.err:
                        with Phase(state, EvalPhase.BUILD, lock) as phase:
                            argv = get_build_phase_args(phase_argv, options)
                            state.err = build.main(argv)
                    if not state.err:
                        with Phase(state, EvalPhase.TEST, lock) as phase:
                            argv = get_test_phase_args(["test"], options)
                            state.err = test.main(argv)
                    if (not state.err) and sb.get_sandboxtype().get_should_publish():
                        with Phase(state, EvalPhase.PUBLISH, lock) as phase:
                            state.err = publish.main(phase_argv)
                except:
                    txt = traceback.format_exc()
                    print(txt)
                    # It is possible for us to get an exception as we try to enter
                    # a phase (including the first one). In such a case, we need
                    # to work extra hard to help the user understand what's wrong.
                    txt = txt.replace('\r', '').replace('\n', '; ').replace(',', ' ')
                    state.reason = 'exception in build process itself: ' + txt
                    if not state.timestamps:
                        state.timestamps.append(time.time())
                        state.phase = EvalPhase.UPDATE
            finally:
                if os.path.exists(os.path.join(sb.get_root(), 'notify.txt')):
                    if (not sb.get_sandboxtype().get_notify_on_success()) and (not state.err):
                        os.remove('%snotify.txt' % sb.get_root())
                    else:
                        notify = open('%snotify.txt' % sb.get_root(), 'r')
                        emails = notify.read()
                        notify.close()
                        body = ''
                        if os.path.exists(os.path.join(sb.get_root(), 'eval-log.txt')):
                            body = os.path.join(sb.get_root(), 'eval-log.txt')
                        os.remove('%snotify.txt' % sb.get_root())
                        bi = buildinfo.BuildInfo()
                        if state.err:
                            status = 'Failed'
                        else:
                            status = 'Succeeded'
                        subject = '%s build of %s on %s %s.' % (sb.get_variant(), sb.get_top_component(), bi.host, status)
                        arguments = '--to %s --sender sadm --subject "%s" --host smtp.example.com --port 587' % (emails, subject) # TODO KIM TO CONF
                        arguments += ' --username [email protected] --password password' # TODO KIM TO CONF
                        if body:
                            arguments += ' --body "%s"' % body
                        os.system('python %s/buildscripts/mailout.py %s' % (sb.get_code_root(), arguments))
                if not state.err:
                    state.reason = ''
                if _should_report(sb, options):
                    report(sb, state)
                else:
                    print('Skipping report phase.')
    return state.err
开发者ID:perfectsearch,项目名称:sandman,代码行数:62,代码来源:eval.py


示例15: google

def google():
    main()
    if False:
        from test2 import main
开发者ID:rainywh269,项目名称:Experiments,代码行数:4,代码来源:a1.py


示例16: main

def main(argv):
    arg_parser = argparse.ArgumentParser(
        description='Update the Python Project Template using diff3.')
    arg_parser.add_argument(
        'current_project_directory',
        help='Directory for the project wanting to be updated')
    # arg_parser.add_argument(
    #     'old_ppt_directory',
    #     help='PPT version from which this project originated')
    # arg_parser.add_argument(
    #     'new_ppt_directory',
    #     help='PPT version to which this project should be updated')

    args = arg_parser.parse_args(args=argv[1:])

    # Find the .ppt-version file and read the commit hash from it.
    ppt_version_path = os.path.join(
        args.current_project_directory, '.ppt-version')
    if not os.path.exists(ppt_version_path):
        raise SystemExit(
            'PPT version cookie not found: {0}'.format(ppt_version_path))
    with open(ppt_version_path) as ppt_version_file:
        for line in ppt_version_file:
            # Allow for comments in the file.
            if not line.startswith('#'):
                old_revision = line.rstrip()
                break

    # Grab the path to metadata from setup.py, as we know where that file is.
    # We're not sure of the directory where metadata.py resides. We need to
    # change directories instead of importing the module directly because there
    # are dependent imports.
    print("Finding project's `metadata.py' file...")
    with cwd(args.current_project_directory):
        current_project_setup_module = imp.load_source(
            'setup', os.path.join(args.current_project_directory, 'setup.py'))
    package_name = current_project_setup_module.metadata.package
    metadata_path = os.path.join(
        args.current_project_directory, package_name, 'metadata.py')
    if not os.path.exists(metadata_path):
        raise SystemExit(
            'Project metadata file not found: {0}'.format(metadata_path))

    # Setup the new PPT directory.
    print('Setting up new PPT directory...')
    new_ppt_directory = mkdtemp(prefix='ppt-new-')
    test.main(['unused_progname',
               '--metadata-path', metadata_path,
               new_ppt_directory])

    # Setup the old PPT directory.
    print('Setting up old PPT directory...')
    old_ppt_directory = mkdtemp(prefix='ppt-old-')
    test.main(['unused_progname',
               '--metadata-path', metadata_path,
               '--revision', old_revision,
               old_ppt_directory])

    dirs = [
        args.current_project_directory,
        old_ppt_directory,
        new_ppt_directory,
    ]

    with cwd(args.current_project_directory):
        git_ls_files = subprocess.check_output(
            ['git', 'ls-files']).splitlines()

    # Don't diff3 the version cookie.
    git_ls_files.remove('.ppt-version')

    print('Running diff3...')
    for git_path in git_ls_files:
        paths = []
        for dir_ in dirs:
            path = os.path.join(dir_, git_path)
            if not os.path.exists(path):
                path = '/dev/null'
            paths.append(path)
        process = subprocess.Popen(
            ['diff3', '--merge'] + paths,
            stdout=subprocess.PIPE)
        diff3_out, diff3_err = process.communicate()
        if process.returncode != 0:
            print('{0}: merge conflicts found, please resolve manually'.format(
                paths[0]))
        with open(paths[0], 'w') as current_file:
            current_file.write(diff3_out)

    new_revision = subprocess.check_output(
        ['git', 'rev-parse', 'HEAD']).rstrip()
    print('Updating PPT version cookie (revision {0})...'.format(new_revision))
    # Open file for reading and writing.
    with open(ppt_version_path, 'r+') as ppt_version_file:
        # Strip off the last line.
        new_contents_lines = ppt_version_file.readlines()[:-1]
        # Append the new revision.
        new_contents_lines.append(new_revision)
        # Write new contents to file.
        new_contents = ''.join(new_contents_lines)
#.........这里部分代码省略.........
开发者ID:ChuyuHsu,项目名称:python-project-template,代码行数:101,代码来源:update_existing_ppt_project.py


示例17:

__author__ = 'EL13115'
import Tkinter
import tkFileDialog

import test

root = Tkinter.Tk()
filename = tkFileDialog.askopenfilename(parent=root, title='Choose a file')
help_class = test.main_args()
if filename != None:
    help_class.url = filename
    test.main(help_class)
else:
    test.main(help_class)

root.mainloop()
开发者ID:sudo-Whateverman,项目名称:openCv_shenanigans,代码行数:16,代码来源:input_gui.py


示例18: test_obtain_AND_release

        invalidButNotRejected = '%:$|!#$%#$U%O\\/^'
        lock, _ = self.testConstructor(filename=invalidButNotRejected)
        self.assertEqual(invalidButNotRejected, lock.filename)


    def test_obtain_AND_release(self):
        lock, filename = self.testConstructor()
        self.failUnless(lock.obtain())
        self.failUnless(os.path.exists(lock.filename))
        lock.release()
        self.failIf(os.path.exists(lock.filename))


    def test_release_invalid(self):
        # Make sure the FSLock doesn't segfault if the lock file gets deleted
        # out from under it.  It's allowed to raise an exception, though.
        lock, filename = self.testConstructor()
        self.failUnless(lock.obtain())
        self.failUnless(os.path.exists(lock.filename))
        os.remove(lock.filename)
        try:
            lock.release()
        except:
            pass


if __name__ == '__main__':
    import test
    test.main(suite=getFullTestSuite())
开发者ID:shiwenxiang,项目名称:clucene,代码行数:29,代码来源:test_store.py


示例19: test_settings_error

 def test_settings_error(self, sys_exit):
     # When the settings file cannot be imported the test runner
     # wil exit with a message and a specific exit code.
     test.main('cheeseshop.tilsit', 'stilton')
     self.assertEqual(sys_exit.call_args, ((1,), {}))
开发者ID:carlitux,项目名称:djbuild,代码行数:5,代码来源:tests.py


示例20: _nameOfTestFile

        self.tok('0', [(0,1,'<NUM>','0')])
        self.tok('0.', [(0,1,'<NUM>','0')])
        self.tok('-1', [(0,2,'<NUM>','-1')])
        self.tok('+1', [(1,2,'<NUM>','1')])
        self.tok('+12.', [(1,3,'<NUM>','12')])
        self.tok('-12.', [(0,3,'<NUM>','-12')])
        self.tok('+.1', [(1,3,'<NUM>','.1')])
        self.tok('+.1.', [(1,3,'<NUM>','.1')])
        self.tok('-.1', [(0,3,'<NUM>','-.1')])
        self.tok('-.1.', [(0,3,'<NUM>','-.1')])
        self.tok('-1.5abc', [(0,4,'<NUM>','-1.5'), (4,7,'<ALPHANUM>','abc')])
        self.tok('-123.4567-abc', [(0,9,'<NUM>','-123.4567'), (10,13,'<ALPHANUM>','abc')])


### SUPPORT ###
def _nameOfTestFile():
    # Can't naively use __file__ because it changes from 'test_analysis.py'
    # to 'test_analysis.py[c|o]' upon bytecode compilation, and the bytecode
    # file isn't suitable for [ASCII-oriented] tokenization.
    return test_base.getFilenameOfThisPythonTestModule(__file__)


def _textOfTestFile():
    return file(_nameOfTestFile(), 'rb').read()


if __name__ == '__main__':
    import test
    test.main(suite=getFullTestSuite(), createTestIndex=False)
开发者ID:shiwenxiang,项目名称:clucene,代码行数:29,代码来源:test_analysis.py



注:本文中的test.main函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python test.render函数代码示例发布时间:2022-05-27
下一篇:
Python test.log函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap