示例#1
0
def run_tests():
    all_tests, features, common.VERBOSE, force = arguments.arguments()
    common.USE_PROMPT = not force

    common.printer('Features:', *sorted(features))

    good_tests = []
    for test in all_tests:
        required_features = set(getattr(test, 'FEATURES', []))
        missing = required_features - features

        if missing:
            plural = '' if len(missing) == 1 else 's'
            missing = ', '.join(missing)
            common.printer(SKIPPING_MESSAGE % (_name(test), plural, missing))
        else:
            good_tests.append(test)

    'list' in good_tests and good_tests.remove('list')
    if not good_tests:
        return
    common.printer('Running tests:', *[_name(t) for t in good_tests])

    failures = 0
    for test in good_tests:
        common.printer(RUNNING_MESSAGE % _name(test), end='', flush=True)
        try:
            test.run()
        except:
            traceback.print_exc()
            failures += 1
        common.printer('done', flush=True)
    sys.exit(failures)
示例#2
0
def run_tests():
    all_tests, features, common.VERBOSE, force = arguments.arguments()
    common.USE_PROMPT = not force

    common.printer('Features:', *sorted(features))

    good_tests = []
    for test in all_tests:
        required_features = set(getattr(test, 'FEATURES', []))
        missing = required_features - features

        if missing:
            plural = '' if len(missing) == 1 else 's'
            missing = ', '.join(missing)
            common.printer(SKIPPING_MESSAGE % (_name(test), plural, missing))
        else:
            good_tests.append(test)

    'list' in good_tests and good_tests.remove('list')
    if not good_tests:
        return
    common.printer('Running tests:', *[_name(t) for t in good_tests])

    failures = 0
    for test in good_tests:
        common.printer(RUNNING_MESSAGE % _name(test), end='', flush=True)
        try:
            test.run()
        except:
            traceback.print_exc()
            failures += 1
        common.printer('done', flush=True)
    sys.exit(failures)
示例#3
0
def arguments(argv=sys.argv[1:]):
    parser = argparse.ArgumentParser()

    names = ', '.join(tests.__all__)

    parser.add_argument(
        'tests', nargs='*',
        help='The list of tests to run.  Tests are: ' + names)

    features = ', '.join(FEATURES)
    parser.add_argument(
        '--features', default=[], action='append',
        help='A list of features separated by colons.  Features are: ' +
        features)

    parser.add_argument(
        '--force', '-f', action='store_true',
        help='Do not wait for a prompt')

    parser.add_argument(
        '--verbose', '-v', action='store_true',
        help='More verbose output')

    args = parser.parse_args(argv)

    test_list = args.tests or tests.__all__
    all_tests = [(t, getattr(tests, t, None)) for t in test_list]
    bad_tests = [t for (t, a) in all_tests if a is None]
    if bad_tests:
        common.printer(test_list, all_tests, bad_tests)
        raise ValueError('Bad test names: ' + ', '.join(bad_tests))
    all_tests = tuple(a for (t, a) in all_tests)

    if args.features:
        features = set(':'.join(args.features).split(':'))
        check_features(features)

    else:
        features = get_features()

    return all_tests, features, args.verbose, args.force
示例#4
0
文件: bp.py 项目: ymz000/BiblioPixel
def run():
    common.run_project('bp.yml', flag='-s')
    common.run_project('bp.yml+{animation: {color: green}}',
                       flag='--simpixel=https://www.simpixel.io')
    common.run_project('bp.yml+{animation: {color: blue}}')

    results = []

    def printer(*args, **kwds):
        results.append(' '.join(args))

    with mock.patch('common.printer', side_effect=printer):
        try:
            common.run_project('bp.yml+{animation: {color: wombat}}')
        except:
            pass

    if ERROR not in ''.join(results):
        common.printer()
        common.printer('ERROR: expected error not found')
        common.printer(''.join(results))
示例#5
0
def run():
    from . import __all__
    common.printer('\n', *__all__)
示例#6
0
def put(name, url, data):
    resp = requests.put(ROOT + url, data=data or {})
    common.printer('PUT', name + ':', resp.text)
示例#7
0
def get(name, url, method='GET'):
    common.printer(method, name + ':', requests.get(ROOT + url).json())
示例#8
0
def put(name, url, data):
    resp = requests.put(ROOT + url, data=data or {})
    common.printer('PUT', name + ':', resp.text)
示例#9
0
def get(name, url, method='GET'):
    common.printer(method, name + ':', requests.get(ROOT + url).json())
示例#10
0
   return int(raw_input("Enter album id: "))
def safe_call(method):
	done = False
	result = None
	while not done:
		try:
			result = method()
			done = True
		except Exception, e:
			print "Cought execption sleeping for 3 secs", e
			sleep(3)
	return result

default_path = r'C:\Users\herbion\Downloads\_'
pictures_path = raw_input('Enter path to folder or leave blank [%s]: ' % default_path) or default_path
aid = getAlbumId(vk)

if not pictures_path.endswith(os.path.sep): pictures_path += os.path.sep

pics = filter(lambda pic: any([pic.endswith(ext) for ext in ['jpg', 'jpeg', 'png']]), os.listdir(unicode(pictures_path)))

raw_input("Found %d pics. Go? " % len(pics))
total_pics = len(pics)

while len(pics) > 0:
	part = map(lambda x: os.path.join(pictures_path, x), pics[:5])
	safe_call(lambda:vk_photos.photo(part, album_id=aid))
	pics = pics[5:]
	# print str(len(pics)) + " left"
	common.printer('%{0:3} <> {1}/{2}'.format(int((total_pics - len(pics)) / float(total_pics) * 100), total_pics - len(pics), total_pics))
示例#11
0
    parser.add_argument(
        '--force', '-f', action='store_true',
        help='Do not wait for a prompt')

    parser.add_argument(
        '--verbose', '-v', action='store_true',
        help='More verbose output')

    args = parser.parse_args(argv)

    test_list = args.tests or tests.__all__
    all_tests = [(t, getattr(tests, t, None)) for t in test_list]
    bad_tests = [t for (t, a) in all_tests if a is None]
    if bad_tests:
        common.printer(test_list, all_tests, bad_tests)
        raise ValueError('Bad test names: ' + ', '.join(bad_tests))
    all_tests = tuple(a for (t, a) in all_tests)

    if args.features:
        features = set(':'.join(args.features).split(':'))
        check_features(features)

    else:
        features = get_features()

    return all_tests, features, args.verbose, args.force


if __name__ == '__main__':
    common.printer(arguments())