本文整理汇总了Python中test.main函数的典型用法代码示例。如果您正苦于以下问题:Python main函数的具体用法?Python main怎么用?Python main使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了main函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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']})
示例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,))
示例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()
示例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)
示例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())
示例6: main
import pyximport; pyximport.install()
from test import main
main()
示例7: main
def main():
"""TODO: Docstring for main.
:returns: TODO
"""
test.main()
示例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]))
示例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]) )
示例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)
示例11: test
def test():
import test
test.main()
示例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)
示例13: generate
def generate():
test.parsedata(T.get())
prog_list = test.main()
output = sorted(list(prog_list), key=len)
T2.insert(END, output[0])
示例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
示例15: google
def google():
main()
if False:
from test2 import main