Example #1
0
def main():
    # Command line arguments
    if len(sys.argv) >= 2 and sys.argv[1] == options.cookie_arg:
        options.rewrite_cookies = True

    logger.init_logger()
    options.read_profile()
    if options.run_tests and options.debug:
        tests.run_tests()

    tasks = []

    f = open('websites.txt', 'r')
    lines = f.readlines()
    for line in lines:
        if len(line) < 2:
            continue
        if line.split()[0] == 'SmythsToys':
            smyths_toys = websites.SmythsToys(line.split()[1])
            t = task.Task(smyths_toys)
            t.start()
            tasks.append(t)
        elif line.split()[0] == 'Target':
            target = websites.Target(line.split()[1])
            t = task.Task(target)
            t.start()
            tasks.append(t)
Example #2
0
    def __init__(self, metrics, options):
        token = os.getenv("RANCHER_SCALING_TOKEN")
        url = os.getenv("RANCHER_SCALING_URL")
        a = c.Auth(token, url)
        client = c.Client(a)

        global results
        # Setup state
        for metric in metrics:
            for label in metric.labels:
                label_to_index[label] = len(label_to_index.keys())

        first_write = True
        last_save = time.time()
        for i in range(options.iterations):
            results[i] = [None for _ in range(len(label_to_index.keys()))]
            for metric in metrics:
                result = metric.fn(client, i)
                log_dict(result)
            time.sleep(options.pulse + random.uniform(0, options.jitter))
            if time.time() - last_save > options.save_every:
                print("results", results)
                print("saving...")
                save(results, first_write)
                results = {}
                last_save = time.time()
                first_write = False
        current = save(results, first_write)
        print("METRICS RESULTS:", current)

        tests.run_tests(current)
Example #3
0
def run_testing():
    ids, utters = get_data("./TestingData/Input1.txt")
    ids = ids
    utters = utters
    # Getting Xs
    acronyms, punct, nums = getXs()
    y_ids = []
    X_xnx = []
    y_xnx = []
    # Annotating X
    print "annotating x's"
    for id, utter in zip(ids, utters):
        utter_labels = []
        utter_lst = utter.split()
        for i in xrange(len(utter_lst)):
            # Cleanup any unicode
            utter_lst[i] = str(unidecode(utter_lst[i].decode('utf-8')))
            assert (all(ord(c) < 128 for c in utter_lst[i]))
            #   This would work fine if other checks performed first (in order)
            if check_x(utter_lst[i], nums, punct,
                       acronyms) or (re.match('h[aeh]+h\S*', utter_lst[i])
                                     and set(utter_lst[i]) <= xSet):
                utter_labels.append("X")
            else:
                utter_labels.append("NX")
            utter_lst[i] = run_cleanup(utter_lst[i], utter_labels[i])
        X_xnx.append(utter_lst)
        y_ids.append(id)
        y_xnx.append(utter_labels)
    # Deconstruct X's
    print "deconstructing x's"
    X_ne, xnx_bak, _ = deconstructor(X_xnx, y_xnx, "X")
    X_ne_str = [' '.join(x_ne) for x_ne in X_ne]
    # Annotating NE
    print "annotating ne's"
    ner_annotator = Sklearn_ner(mode="test")
    y_ne = [ner_annotator.run([X_ne_str[i]]) for i in xrange(len(X_ne_str))]
    # Deconstruct NE's
    print "deconstructing ne's"
    X_li, ne_bak, _ = deconstructor(X_ne, y_ne, "NE")
    X_li_str = [' '.join(x_li) for x_li in X_li]
    # Annotating Lang
    print "annotating languages"
    li_annotator = Sklearn_li(mode="test")
    y_li = [li_annotator.run([X_li_str[i]]) for i in xrange(len(X_li_str))]
    # Reconstructing NE's
    print "reconstructing ne's"
    y_li_recon_ne = reconstructor(y_li, ne_bak, "NE")
    # Reconstructing X's
    print "reconstructing x's"
    y_li_ne_recon_x = reconstructor(y_li_recon_ne, xnx_bak, "X")
    # a final test to check reconstruction
    print "running tests"
    run_tests(include_ner_subcat=False)
    pprint(annotation_count_test("./TestingData/Annotation1.txt"))
    prepare_submission(y_ids, y_li_ne_recon_x)
Example #4
0
def run_testing():
    ids, utters = get_data("./TestingData/Input1.txt")
    ids = ids
    utters = utters
    # Getting Xs
    acronyms, punct, nums = getXs()
    y_ids = []
    X_xnx = []
    y_xnx = []
    # Annotating X
    print "annotating x's"
    for id, utter in zip(ids, utters):
        utter_labels = []
        utter_lst = utter.split()
        for i in xrange(len(utter_lst)):
            # Cleanup any unicode
            utter_lst[i] = str(unidecode(utter_lst[i].decode("utf-8")))
            assert all(ord(c) < 128 for c in utter_lst[i])
            #   This would work fine if other checks performed first (in order)
            if check_x(utter_lst[i], nums, punct, acronyms) or (
                re.match("h[aeh]+h\S*", utter_lst[i]) and set(utter_lst[i]) <= xSet
            ):
                utter_labels.append("X")
            else:
                utter_labels.append("NX")
            utter_lst[i] = run_cleanup(utter_lst[i], utter_labels[i])
        X_xnx.append(utter_lst)
        y_ids.append(id)
        y_xnx.append(utter_labels)
    # Deconstruct X's
    print "deconstructing x's"
    X_ne, xnx_bak, _ = deconstructor(X_xnx, y_xnx, "X")
    X_ne_str = [" ".join(x_ne) for x_ne in X_ne]
    # Annotating NE
    print "annotating ne's"
    ner_annotator = Sklearn_ner(mode="test")
    y_ne = [ner_annotator.run([X_ne_str[i]]) for i in xrange(len(X_ne_str))]
    # Deconstruct NE's
    print "deconstructing ne's"
    X_li, ne_bak, _ = deconstructor(X_ne, y_ne, "NE")
    X_li_str = [" ".join(x_li) for x_li in X_li]
    # Annotating Lang
    print "annotating languages"
    li_annotator = Sklearn_li(mode="test")
    y_li = [li_annotator.run([X_li_str[i]]) for i in xrange(len(X_li_str))]
    # Reconstructing NE's
    print "reconstructing ne's"
    y_li_recon_ne = reconstructor(y_li, ne_bak, "NE")
    # Reconstructing X's
    print "reconstructing x's"
    y_li_ne_recon_x = reconstructor(y_li_recon_ne, xnx_bak, "X")
    # a final test to check reconstruction
    print "running tests"
    run_tests(include_ner_subcat=False)
    pprint(annotation_count_test("./TestingData/Annotation1.txt"))
    prepare_submission(y_ids, y_li_ne_recon_x)
Example #5
0
def Dialog_RunTests(ctrl, tests_to_run=None):
    "Run the tests on dialog"

    # get all teh controls
    controls = [ctrl]
    controls.extend(ctrl.Children)

    return tests.run_tests(controls, tests_to_run)
def Dialog_RunTests(ctrl, tests_to_run = None):
    "Run the tests on dialog"

    # get all teh controls
    controls = [ctrl]
    controls.extend(ctrl.Children)

    return tests.run_tests(controls, tests_to_run)
Example #7
0
def main():
    directories = settings.fetch_file_directories()
    create_directory_structure(directories)
    arguments = fetch_argument()
    administrator = arguments.username
    force = arguments.force
    run_tests()
    remove_containers()
    remove_images()
    new_database = new_sql_database(directories, force)
    mysql_root_password, mysql_user_password = generate_passwords(new_database, directories)
    generate_guac_properties(mysql_user_password, directories)
    docker_network_name = create_docker_network()
    build_sql_image(directories)
    build_sql_container(docker_network_name, mysql_root_password, mysql_user_password, administrator, new_database)
    build_guacamole_image(directories)
    build_guacamole_container(docker_network_name)
    clean_directory_structure(directories)
def main(argv=None):
    args = argv
    if args is None:
        args = sys.argv
    try:
        if args[1] == "test":
            tests.run_tests()
        elif args[1] == "ask":
            src.run(args[2])
        elif args[1] == "bot":
            bot.run_bot()
        else:
            print("Unknown command line argument")
            logger.error("Unknown command line argument %s", args[1])
            return 1
    except IndexError as err:
        logger.exception(err)
        print("Not enough arguments")
        return 1
    except KeyError as err:
        logger.exception(err)
        print("Possible problems with JSON config. Please see logs for more information")
        return 1
    except Psycopg2Error as err:
        logger.exception(err)
        print("Problems with database. Please, check its existence and correctness of your login and password.")
        return 1
    except Psycopg2Warning as err:
        logger.exception(err)
        print("Sorry, we're experiencing problems with database.")
        return 1
    except Exception as err:
        logger.exception(err)
        print("An unexpected error occurred. For more information see the log file.")
        return 1
    return 0
Example #9
0
def _run_tests(squadron_dir, commit_info):
    commit_keys = sorted(commit_info)
    for service_name in commit_keys:
        version = commit_info[service_name]['version']
        tests_to_run = tests.get_tests(squadron_dir, service_name, version)

        log.info("Running %s tests for %s v%s", len(tests_to_run),
                service_name, version)
        failed_tests = tests.run_tests(tests_to_run, commit_info[service_name])

        if failed_tests:
            log.error("Failed tests for %s v%s: ", service_name, version)
            for failed_test, exitcode in failed_tests.items():
                log.error("\t%s failed with exitcode %s", failed_test, exitcode)

            log.error("Aborting due to %s failed tests (total tests %s)",
                    len(failed_tests), len(tests_to_run))
            raise TestException()
Example #10
0
import tests
tests.run_tests()
Example #11
0
 def run(self):
     import tests
     tests.run_tests()
Example #12
0
            if value and (b_neighbours == 0 or b_neighbours > 2):
                new_value = False
            elif not value and b_neighbours == 2:
                new_value = True
            else:
                new_value = value

            new_tiles[position] = new_value

            for neighbour_offset in offsets.values():
                b_neighbours = sum(
                    tiles.get(position + neighbour_offset + offset, False) for offset in offsets.values()
                )

                neighbour_value = tiles.get(position + neighbour_offset, False)
                if neighbour_value and (b_neighbours == 0 or b_neighbours > 2):
                    new_value = False
                elif not neighbour_value and b_neighbours == 2:
                    new_value = True
                else:
                    new_value = neighbour_value

                new_tiles[position + neighbour_offset] = new_value

        tiles = new_tiles

    return sum(tiles.values())


run_tests(func=get_solution, result=2208)
Example #13
0
"""Test the entire package; an underscore precedes this file name
so it does not include itself in the test discovery."""
import os.path as osp
from tests import run_tests

test_dir = osp.dirname(__file__)
run_tests(test_dir)
Example #14
0
File: setup.py Project: zeph/wicd
 def run(self):
     print("importing tests")
     import tests
     print('running tests')
     tests.run_tests()
Example #15
0
    wrapped_inner.append("." * len(wrapped_inner[0]))
    return wrapped_inner


def wrap_dimension(dim: list):
    wrapped_dim = []
    for layer in dim:
        wrapped_dim.append(wrap_layer(layer))

    empty_layer = [
        "." * len(wrapped_dim[0][0]) for _ in range(len(wrapped_dim[0]))
    ]
    wrapped_dim.insert(0, empty_layer)
    wrapped_dim.append(empty_layer)
    return wrapped_dim


def wrap_state(state: list):

    wrapped = []
    for dim in state:
        wrapped.append(wrap_dimension(dim))

    empty_dim = [wrapped[0][0] for _ in range(len(wrapped[0]))]
    wrapped.insert(0, empty_dim)
    wrapped.append(empty_dim)
    return wrapped


run_tests(func=get_solution, result=848)
Example #16
0
        return self.m[pos.y][pos.x]


assert Map(".#\n..").get(Position(1, 0)) == "#"
assert Map(".#.\n..#").ast == [Position(1, 0), Position(2, 1)]
assert Map(".#\n.#\n.#").is_visible(Position(1, 0), Position(1, 2)) == False
assert Map("#..\n...\n.#.\n...\n..#").is_visible(Position(0, 0),
                                                 Position(1, 2)) == True
assert Map("#..\n...\n.#.\n...\n..#").is_visible(Position(0, 0),
                                                 Position(2, 4)) == False


def part1(inp):
    m = Map(inp)
    best = (0, None)
    for pos in m.ast:
        res = m.count(pos)
        if res > best[0]:
            best = (res, (pos.x, pos.y))
    return best, m


if __name__ == "__main__":
    import tests
    tests.run_tests(part1)

    inp = None
    with open("10/input.txt") as f:
        inp = "".join(f.readlines())

    print(part1(inp))
        for user in User.objects.all():
            user.is_active = False

        self._access_deny_test()


class NotAdminTest(TestBase):
    """
    Tests with a login user
    """
    def setUp(self):
        super(NotAdminTest, self).setUp()
        self.login("normal")

    def test_access_allowed(self):
        plugin_name = "page_admin"
        method_names = (
            "edit_page", "new_page", "select_edit_page",
            "delete_pages", "sequencing"
        )
        self.assertAccessAllowed(self.base_url, plugin_name, method_names)



if __name__ == "__main__":
    # Run this unitest directly
    import os
    os.chdir("../")
    filename = os.path.splitext(os.path.basename(__file__))[0]
    tests.run_tests(test_labels=[filename], verbosity=1)
Example #18
0
from tests import run_tests


def get_solution(puzzle_input: str):

    numbers = [int(num) for num in puzzle_input.split(",")]
    print(numbers)

    for i in range(len(numbers), 2020):
        last = numbers[-1]

        numbers_before = numbers[:i - 1]
        if last in numbers_before:
            numbers_before.reverse()
            previous_occurrence = numbers_before.index(last)
            numbers.append(previous_occurrence + 1)

        else:
            numbers.append(0)

    print(numbers[2019])
    return numbers[2019]


run_tests(func=get_solution, result=1836)
Example #19
0
from tests import run_tests


def get_solution(puzzle_input: str):

    numbers = [int(num) for num in puzzle_input.split(",")]
    indices = {num: [i] for i, num in enumerate(numbers)}
    last_number = numbers[-1]

    for i in range(len(numbers), 30000000):
        num_indices = indices[last_number]

        if len(num_indices) > 1:
            new_number = num_indices[-1] - num_indices[-2]
        else:
            new_number = 0

        if new_number in indices:
            indices[new_number].append(i)
        else:
            indices[new_number] = [i]

        last_number = new_number

    return last_number


run_tests(func=get_solution, result=362)
Example #20
0
def main():
  import argparse
  parser = argparse.ArgumentParser()
  parser.add_argument('--test', action='store_true')
  args = parser.parse_args()

  if args.test:
    import tests
    tests.run_tests()

  cam_t = (0, -.5)
  r_angle = 0
  fov = 75 * np.pi/180.
  cam1d = flatland.Camera1d(cam_t, r_angle, fov, SIZE)
  cam2d = flatland.Camera2d(WORLD_MIN, WORLD_MAX, SIZE)

  tracker = Tracker(np.ones((SIZE, SIZE)))

  poly_center = np.array([0., 0.])
  poly_scale = .5
  poly_rot = 0.
  while True:
    poly_pts = np.array([[-0.5, -0.5], [ 0.5, -0.5], [ 0.5,  0.5], [-0.5,  0.5]]).dot(flatland.rotation2d(poly_rot).T)*poly_scale + poly_center[None,:]

    #poly = flatland.Polygon([[.2, .2], [0,1], [1,1], [1,.5]])
    poly = flatland.Polygon(poly_pts)
    polylist = [poly]

    image1d, depth1d = cam1d.render(polylist)
    # print 'depth1d', depth1d

    depth_min, depth_max = 0, 1
    depth1d_normalized = (np.clip(depth1d, depth_min, depth_max) - depth_min)/(depth_max - depth_min)
    depth1d_image = np.array([[.5, 0, 0]])*depth1d_normalized[:,None] + np.array([[1., 1., 1.]])*(1. - depth1d_normalized[:,None])
    depth1d_image[np.logical_not(np.isfinite(depth1d))] = (0, 0, 0)

    # observed_XYs = cam1d.unproject(depth1d)
    # filtered_obs_XYs = np.array([p for p in observed_XYs if np.isfinite(p).all()])
    # obs_render_list = [flatland.Point(p, c) for (p, c) in zip(observed_XYs, depth1d_image) if np.isfinite(p).all()]
    # print 'obs world', filtered_obs_XYs
    obs_render_list = []
    camera_poly_list = [flatland.make_camera_poly(cam1d.t, cam1d.r_angle, fov)]
    image2d = cam2d.render(polylist + obs_render_list + camera_poly_list)
    image2d_poly = cam2d.render(polylist)
    #import IPython; IPython.embed()

    drawn_inds = np.nonzero((abs(image2d_poly) > .00001).astype(int).sum(axis=2)) # HACK: assumes not drawn is filled with 0
    image2d[drawn_inds] = [0,1,0]
    drawn_pts = np.transpose(drawn_inds)

    P = flatland.Render2d(cam2d.bl, cam2d.tr, cam2d.width).P
    observed_XYs = np.array([p for p in cam1d.unproject(depth1d) if np.isfinite(p).all()])
    observed_px = np.round(observed_XYs.dot(P[:2,:2].T) + P[:2,2]).astype(int)
    # from scipy.spatial import KDTree
    # kdt = KDTree(drawn_pts)
    # print observed_px
    # print kdt.query(observed_px)
    # observed_drawn_pts = drawn_pts[kdt.query(observed_px)[1]]
    #image2d[observed_drawn_pts[:,1],observed_drawn_pts[:,0]] = [1,0,0]
    image2d[observed_px[:,1],observed_px[:,0]] = [0,0,1]
    Pinv = np.linalg.inv(P)
    filtered_obs_XYs = observed_px.dot(Pinv[:2,:2].T) + Pinv[:2,2]


    flatland.show_1d_image([image1d, depth1d_image], "image1d+depth1d")
    flatland.show_2d_image(image2d, "image2d")
    cv2.moveWindow("image2d", 0, 0)
    key = cv2.waitKey() & 255
    print "key", key

    # linux
    if key == 81:
        cam1d.t[0] += .1
    elif key == 82:
        cam1d.t[1] += .1
    elif key == 84:
        cam1d.t[1] -= .1
    elif key == 83:
        cam1d.t[0] -= .1
    elif key == ord('['):
        cam1d.r_angle -= .1
    elif key == ord(']'):
        cam1d.r_angle += .1

    elif key == ord('q'):
        break

    if key == ord('a'):
        poly_center[0] += .01
    elif key == ord('w'):
        poly_center[1] += .01
    elif key == ord('s'):
        poly_center[1] -= .01
    elif key == ord('d'):
        poly_center[0] -= .01
    elif key == ord('-'):
      poly_rot -= .1
    elif key == ord('='):
      poly_rot += .1

#   elif key == ord('c'):
#     tracker = Tracker(empty_sdf)
#     tracker.plot()
#     print 'zeroed out sdf and control'

    elif key == ord('i'):
      # initialization
      # compute sdf of starting state as initialization
      image2d = cam2d.render(polylist)
      init_state_edge = np.ones((SIZE, SIZE), dtype=int)
      is_edge = image2d[:,:,0] > .5
      init_state_edge[is_edge] = 0
      init_sdf_img = distance_transform_edt(init_state_edge) * np.sqrt(sqp_problem.Config.PIXEL_AREA)
      # negate inside the boundary
      orig_filling = [p.filled for p in polylist]
      for p in polylist: p.filled = True
      image2d_filled = cam2d.render(polylist)
      for orig, p in zip(orig_filling, polylist): p.filled = orig
      init_sdf_img[image2d_filled[:,:,0] > .5] *= -1
      init_sdf = init_sdf_img
      #init_sdf = sqp_problem.make_interp(init_sdf_img)#grid.SpatialFunction.FromImage(WORLD_MIN[0], WORLD_MAX[0], WORLD_MIN[1], WORLD_MAX[1], init_sdf_img)

      tracker = Tracker(init_sdf)#smooth_by_edt(init_sdf))
      tracker.observe(filtered_obs_XYs)
      tracker.plot()

    elif key == ord('o'):
      tracker.observe(filtered_obs_XYs)
      tracker.plot()
      print 'observed.'

    elif key == ord(' '):
      tracker.optimize_sqp()
      tracker.plot()
Example #21
0
    # with Connection(MEGA) as mega, \
    #         Connection(UNO) as uno:
    with Connection(MEGA) as mega:
        """
            блок инициализации объектов
        """
        # navi = Navigation(uno, TAG_PORT)
        touch_probe = TouchProbe(mega, tower)
        heater = Heater(mega)
        table = TableCalibrate(mega, tower, touch_probe)
        edge_search = EdgeSearch(mega, tower, table)
        time.sleep(2)
        print('start')
        if (is_interactive):

            run_tests(mega, num_tests=1000)

        else:
            # list_of_files = ['1st_move.gcode', '2nd_move.txt']
            # for file_name in list_of_files:
            for i in range(1):
                file_name = 'aramka200x100.gcode'
                with open(file_name) as gcode:
                    for line in gcode:
                        command = parse_gcode(line)
                        h = heater.get_temp()
                        print(h)
                        if command['cmd'] == 'G0' or command['cmd'] == 'G1':
                            table.transform_command(command)
                            for command_for_mega in tower.move_to(command):
                                mega.send(*command_for_mega)
Example #22
0
    # adjust first n cups based on the input cup order
    lookup_table[cups[-1]].next = lookup_table[len(cups) + 1]
    for i, value in enumerate(cups[:-1]):
        lookup_table[value].next = lookup_table[cups[i + 1]]

    current_cup = lookup_table[cups[0]]

    for _ in range(number_of_steps):
        next1, next2, next3 = current_cup.next, current_cup.next.next, current_cup.next.next.next
        # take out the next 3 cups
        current_cup.next = next3.next

        # find where to move the 3 cups
        destination_cup_value = current_cup.value - 1 if current_cup.value > 1 else number_of_cups
        while destination_cup_value in {next1.value, next2.value, next3.value}:
            destination_cup_value -= 1
            if destination_cup_value < 1:
                destination_cup_value = number_of_cups

        # move the 3 cups
        destination_cup = lookup_table[destination_cup_value]
        next3.next = destination_cup.next
        destination_cup.next = next1
        # go to next cup
        current_cup = current_cup.next

    return lookup_table[1].next.value * lookup_table[1].next.next.value


run_tests(func=get_solution, result=149245887792)
Example #23
0
def main():
    meta_lib = {
        'lang': targets.langs['python'],
        'macros': {
            'let': {
                "head, val, body": ["mkp", ["mkv", "head", "body"], 'val']
            },
            'let*': {
                "head, val, body":
                ["star_app", ["mkv", "head", "body"], 'val']
            },
            'dot': {
                "obj, key": [['obj', '+', ["'", '.']], '+', 'key']
            },
            'do': 'do_notation',
            'gets': 'gets_notation'
        },
        'defs': {
            'eval_lispson': {
                'lispson, lib, output_code': [
                    'do', ['let*', 'code, defs', ['decode', 'lispson', 'lib']],
                    ['let', 'def_codes', [['dot', 'defs', 'values']]],
                    ['let', 'defs_code', ['n_join', 'def_codes']],
                    [
                        'let', '_',
                        [
                            'exec', 'defs_code',
                            ['gets', 'lib', 'lang', 'native']
                        ]
                    ],
                    [
                        'let', 'val',
                        ['eval', 'code', ['gets', 'lib', 'lang', 'native']]
                    ],
                    [
                        'if', 'output_code',
                        ["mkl", 'val', 'code', 'def_codes'], 'val'
                    ]
                ]
            },
            'decode': {
                'lispson, lib': [
                    'do', ['let', 'defs', {}],
                    [
                        'let', 'code_str',
                        ['decode_acc', 'lispson', 'lib', 'defs']
                    ], ['mkl', 'code_str', 'defs']
                ]
            },
            'decode_acc': {
                'json_o, lib, defs': [
                    'let', 't', ['type', 'json_o'],
                    [
                        'if', ['t', 'is', 'list'],
                        ['decode_list', 'json_o', 'lib', 'defs'],
                        [
                            'if', ['t', 'is', 'dict'],
                            ['decode_dict', 'json_o', 'lib', 'defs'],
                            [
                                'if', ['t', 'is', 'str'],
                                [
                                    'do',
                                    [
                                        'let', '_',
                                        [
                                            'handle_def', 'json_o', 'lib',
                                            'defs'
                                        ]
                                    ], ['str', 'json_o']
                                ], ['str', 'json_o']
                            ]
                        ]
                    ]
                ]
            },
            'decode_dict': {
                'json_dict, lib, defs': [
                    'do',
                    [
                        'let', 'decoded_dict',
                        ['decode_dict_internal', 'json_dict', 'lib', 'defs']
                    ],
                    [
                        'if', ['gets', 'decoded_dict', 'is_lambda'],
                        [['gets', 'lib', 'lang', 'target', "lam"],
                         ['gets', 'decoded_dict', 'head'],
                         ['gets', 'decoded_dict', 'body']],
                        ['gets', 'decoded_dict', 'json_str']
                    ]
                ]
            },
            'add_dict': {
                'a, b': ['dict', 'a', ['**', 'b']]
            },  # todo udělat pak líp než přes add_dict ale spíš evalovat obecně vnitřky objektů
            'decode_dict_internal': {
                'json_dict, lib, defs': [
                    'let', 'keys', ['list', 'json_dict'],
                    [
                        'if', [['len', 'keys'], '==', 1],
                        [
                            'do', ['let', 'head', ['get', 'keys', 0]],
                            [
                                'let', 'body',
                                [
                                    'decode_acc', ['get', 'json_dict', 'head'],
                                    'lib', 'defs'
                                ]
                            ],
                            [
                                'add_dict', ['mkv', ["'", 'is_lambda'], True],
                                [
                                    'add_dict', ['mkv', ["'", 'head'], 'head'],
                                    ['mkv', ["'", 'body'], 'body']
                                ]
                            ]
                        ],
                        [
                            'add_dict', ['mkv', ["'", 'is_lambda'], False],
                            [
                                'mkv', ["'", 'json_str'],
                                ['json_dumps', 'json_dict']
                            ]
                        ]
                    ]
                ]
            },
            'decode_list': {
                'json_list, lib, defs': [
                    'if',
                    ['not', 'json_list'],
                    ["'", '[]'],
                    [
                        'if',
                        ['is_infix', 'json_list', 'lib'],
                        ['decode_infix', 'lib', 'defs', ['*', 'json_list']],
                        [
                            'do',
                            [
                                'let', 'fun',
                                [
                                    'decode_acc', ['get', 'json_list', 0],
                                    'lib', 'defs'
                                ]
                            ],
                            ['let', 'args', ['tail', 'json_list']],
                            [
                                'if',
                                ['fun', '==', ["'", "'"]],
                                ['decode_quote', 'args'],
                                [
                                    'if',
                                    ['fun', 'in', ['gets', 'lib', 'macros']],
                                    [
                                        'decode_macro', 'fun', 'args', 'lib',
                                        'defs'
                                    ],
                                    [
                                        'do',
                                        [
                                            'let', 'decoded_args',
                                            [
                                                'list',
                                                [
                                                    'map', {
                                                        'o': [
                                                            'decode_acc', 'o',
                                                            'lib', 'defs'
                                                        ]
                                                    }, 'args'
                                                ]
                                            ]
                                        ],  # todo je tu list(map(..))
                                        [
                                            'if', ['fun', '==', ["'", 'if']],
                                            [
                                                'decode_if', 'decoded_args',
                                                'lib'
                                            ],
                                            [
                                                'do',
                                                [
                                                    'let', '_',
                                                    [
                                                        'handle_def', 'fun',
                                                        'lib', 'defs'
                                                    ]
                                                ],
                                                [[
                                                    'gets', 'lib', 'lang',
                                                    'target', 'app'
                                                ], "fun", 'decoded_args']
                                            ]
                                        ]
                                    ]
                                ]
                            ]
                        ]
                    ]
                ]
            },
            'decode_quote': {
                'args': [
                    'json_dumps',
                    [
                        'if', [['len', 'args'], '==', 1], ['get', 'args', 0],
                        'args'
                    ]
                ]
            },
            'is_infix': {
                'json_list, lib': [
                    'if', [['len', 'json_list'], '==', 3],
                    [
                        'do', ['let', 'op', ['get', 'json_list', 1]],
                        [['isinstance', 'op', 'str'], 'and',
                         ['op', 'in', ['gets', 'lib', 'lang', 'infix']]]
                    ], False
                ]
            },
            'decode_infix': {
                'lib, defs, a, op, b': [
                    'do',
                    ['let', 'decoded_a', ['decode_acc', 'a', 'lib', 'defs']],
                    ['let', 'decoded_b', ['decode_acc', 'b', 'lib', 'defs']],
                    [['gets', 'lib', 'lang', 'target', 'infix'], 'decoded_a',
                     'op', 'decoded_b']
                ]
            },
            'decode_macro': {
                'macro_name, args, lib, defs': [
                    'do', ['let', 'macros', ['gets', 'lib', "macros"]],
                    ['let', 'macro', ['get', 'macros', 'macro_name']],
                    [
                        'let', 'macro_fun',
                        ['eval_lispson', 'macro', 'lib', False]
                    ],
                    [
                        'decode_acc', ['macro_fun', ['*', 'args']], 'lib',
                        'defs'
                    ]
                ]
            },
            'decode_if': {
                'decoded_args, lib': [['gets', 'lib', 'lang', 'target', 'if'],
                                      ['*', 'decoded_args']]
            },
            'handle_def': {
                'sym, lib, defs': [
                    'let', 'lib_defs', ['gets', 'lib', 'defs'],
                    [
                        'if',
                        [['sym', 'in', 'lib_defs'], 'and',
                         ['not', ['sym', 'in', 'defs']]],
                        [
                            'let', 'sym_def', ['get', 'lib_defs', 'sym'],
                            [
                                'if', ['isinstance', 'sym_def', 'str'],
                                [
                                    'set_val', 'defs', 'sym',
                                    [['gets', 'lib', 'lang', 'target', 'def'],
                                     'sym', 'sym_def']
                                ],
                                [
                                    'do',
                                    [
                                        'let', '_',
                                        ['set_val', 'defs', 'sym', 'None']
                                    ],
                                    [
                                        'if',
                                        ['isinstance', 'sym_def', 'dict'],
                                        [
                                            'handle_def_dict', 'sym', 'lib',
                                            'defs', 'sym_def'
                                        ],
                                        [
                                            'handle_def_non_dict', 'sym',
                                            'lib', 'defs', 'sym_def'
                                        ]
                                    ]
                                ]
                            ]
                        ], 'None'
                    ]
                ]
            },
            'handle_def_dict': {
                'sym, lib, defs, sym_def': [
                    'do',
                    [
                        'let', 'decoded_dict',
                        ['decode_dict_internal', 'sym_def', 'lib', 'defs']
                    ], ['let', 'target', ['gets', 'lib', 'lang', 'target']],
                    [
                        'let', 'sym_def',
                        [
                            'if', ['gets', 'decoded_dict', 'is_lambda'],
                            [['gets', 'target', 'def_fun'], 'sym',
                             ['gets', 'decoded_dict', 'head'],
                             ['gets', 'decoded_dict', 'body']],
                            [['gets', 'target', 'def'], 'sym',
                             ['gets', 'decoded_dict', 'json_str']]
                        ]
                    ], ['set_val', 'defs', 'sym', 'sym_def']
                ]
            },
            'handle_def_non_dict': {
                'sym, lib, defs, sym_def': [
                    'do',
                    ['let', 'body', ['decode_acc', 'sym_def', 'lib', 'defs']],
                    [
                        'let', 'sym_def',
                        [['gets', 'lib', 'lang', 'target', 'def'], 'sym',
                         'body']
                    ], ['set_val', 'defs', 'sym', 'sym_def']
                ]
            }
        },
    }

    eval_lispson, _, def_codes, natives = decoder.eval_lispson('eval_lispson',
                                                               meta_lib,
                                                               output_all=True)

    num_tested = tests.run_tests(eval_lispson)
    print_defs(def_codes)

    print('\n(meta_)eval_lispson natives:', natives)

    return num_tested
Example #24
0
from tests import run_tests

from .classes import Tile


def get_solution(puzzle_input: str):
    tiles = {
        tile.splitlines()[0].split(" ")[1][:-1]:
        Tile(tile.splitlines()[1:],
             tile.splitlines()[0].split(" ")[1][:-1])
        for tile in puzzle_input.split("\n\n")
    }

    result = 1
    for tile_id, tile in tiles.items():
        borders = [
            tile.borders(other) for other_id, other in tiles.items()
            if tile_id != other_id and tile.borders(other)
        ]
        if len([border for border in borders if border]) == 2:
            result *= int(tile_id)

    return result


run_tests(func=get_solution, result=20899048083289)
Example #25
0
def run_tests():
    """Run tests without install library into python path
    """
    from tests import run_tests
    return run_tests()
Example #26
0
from tests import run_tests


def get_solution(puzzle_input: str):
    cups = list(map(int, puzzle_input))

    for _ in range(100):
        current_cup = cups[0]
        three_cups = [cups.pop(1), cups.pop(1), cups.pop(1)]

        try:
            diff = min(current_cup - cup for cup in cups if current_cup - cup > 0)
            destination_cup = current_cup - diff
        except ValueError:
            destination_cup = max(cups)

        destination_index = cups.index(destination_cup)
        cups = cups[:destination_index + 1] + three_cups + cups[destination_index + 1:]
        cups = cups[1:] + cups[:1]

    return "".join(map(str, cups[cups.index(1) + 1:] + cups[:cups.index(1)]))


run_tests(func=get_solution, result="67384529")
Example #27
0
import sys
from tests import run as run_tests

if __name__ == "__main__":
    result = run_tests()
    tests_clear = (len(result.errors) == 0 & len(result.failures) == 0)
    if not tests_clear:
        sys.exit('failed test cases...')
Example #28
0
def main():
  import argparse
  parser = argparse.ArgumentParser()
  parser.add_argument('--test', action='store_true')
  args = parser.parse_args()

  if args.test:
    import tests
    tests.run_tests()

  cam_t = (0, -.5)
  r_angle = 0
  fov = 75 * np.pi/180.
  cam1d = flatland.Camera1d(cam_t, r_angle, fov, SIZE)
  cam2d = flatland.Camera2d(WORLD_MIN, WORLD_MAX, SIZE)

  empty_sdf = grid.SpatialFunction(WORLD_MIN[0], WORLD_MAX[0], WORLD_MIN[1], WORLD_MAX[1], np.ones((SIZE, SIZE)))
  tracker = Tracker(empty_sdf)

  poly_center = np.array([0., 0.])
  poly_scale = .5
  poly_rot = 0.
  while True:
    poly_pts = np.array([[-0.5, -0.5], [ 0.5, -0.5], [ 0.5,  0.5], [-0.5,  0.5]]).dot(flatland.rotation2d(poly_rot).T)*poly_scale + poly_center[None,:]

    #poly = flatland.Polygon([[.2, .2], [0,1], [1,1], [1,.5]])
    poly = flatland.Polygon(poly_pts)
    polylist = [poly]

    image1d, depth1d = cam1d.render(polylist)
    # print 'depth1d', depth1d

    depth_min, depth_max = 0, 1
    depth1d_normalized = (np.clip(depth1d, depth_min, depth_max) - depth_min)/(depth_max - depth_min)
    depth1d_image = np.array([[.5, 0, 0]])*depth1d_normalized[:,None] + np.array([[1., 1., 1.]])*(1. - depth1d_normalized[:,None])
    depth1d_image[np.logical_not(np.isfinite(depth1d))] = (0, 0, 0)

    observed_XYs = cam1d.unproject(depth1d)
    filtered_obs_XYs = np.array([p for p in observed_XYs if np.isfinite(p).all()])

    obs_render_list = [flatland.Point(p, c) for (p, c) in zip(observed_XYs, depth1d_image) if np.isfinite(p).all()]
    # print 'obs world', filtered_obs_XYs
    camera_poly_list = [flatland.make_camera_poly(cam1d.t, cam1d.r_angle, fov)]
    image2d = cam2d.render(polylist + obs_render_list + camera_poly_list)

    flatland.show_1d_image([image1d, depth1d_image], "image1d+depth1d")
    flatland.show_2d_image(image2d, "image2d")
    cv2.moveWindow("image2d", 0, 0)
    key = cv2.waitKey() & 255
    print "key", key

    # linux
    if key == 81:
        cam1d.t[0] += .1
    elif key == 82:
        cam1d.t[1] += .1
    elif key == 84:
        cam1d.t[1] -= .1
    elif key == 83:
        cam1d.t[0] -= .1
    elif key == ord('['):
        cam1d.r_angle -= .1
    elif key == ord(']'):
        cam1d.r_angle += .1

    elif key == ord('q'):
        break

    if key == ord('a'):
        poly_center[0] += .01
    elif key == ord('w'):
        poly_center[1] += .01
    elif key == ord('s'):
        poly_center[1] -= .01
    elif key == ord('d'):
        poly_center[0] -= .01
    elif key == ord('-'):
      poly_rot -= .1
    elif key == ord('='):
      poly_rot += .1

    elif key == ord('c'):
      tracker = Tracker(empty_sdf)
      tracker.plot()
      print 'zeroed out sdf and control'

    elif key == ord('i'):
      # initialization
      # compute sdf of starting state as initialization
      image2d = cam2d.render(polylist)
      init_state_edge = np.ones((SIZE, SIZE), dtype=int)
      is_edge = image2d[:,:,0] > .5
      init_state_edge[is_edge] = 0
      init_sdf_img = distance_transform_edt(init_state_edge) * PIXEL_SIDE
      # negate inside the boundary
      orig_filling = [p.filled for p in polylist]
      for p in polylist: p.filled = True
      image2d_filled = cam2d.render(polylist)
      for orig, p in zip(orig_filling, polylist): p.filled = orig
      init_sdf_img[image2d_filled[:,:,0] > .5] *= -1
      init_sdf = grid.SpatialFunction.FromImage(WORLD_MIN[0], WORLD_MAX[0], WORLD_MIN[1], WORLD_MAX[1], init_sdf_img)

      tracker = Tracker(init_sdf)
      tracker.observe(filtered_obs_XYs)
      tracker.plot()

    elif key == ord('o'):
      obs = filtered_obs_XYs
      # hack: ensure obs occurs only on grid

      obs_inds = np.c_[empty_sdf.to_grid_inds(obs[:,0], obs[:,1])].round()
      print 'grid inds', obs_inds
      obs = np.c_[empty_sdf.to_world_xys(obs_inds[:,0], obs_inds[:,1])]

      # print 'orig obs', obs
      # render2d = flatland.Render2d(cam2d.bl, cam2d.tr, cam2d.width)
      # xys = obs.dot(render2d.P[:2,:2].T) + render2d.P[:2,2]
      # ixys = xys.astype(int)
      # pts = []
      # for ix, iy in ixys:
      #   if 0 <= iy < render2d.image.shape[0] and 0 <= ix < render2d.image.shape[1]:
      #     pts.append([ix,iy])
      # print 'orig pts', pts
      # pts = np.array(pts)
      # obs = pts
      # Pinv = np.linalg.inv(render2d.P)
      # obs = np.array(pts).dot(Pinv[:2,:2].T) + Pinv[:2,2]
      # print 'rounded obs', obs
      # print 'rounded obs inds', empty_sdf.to_grid_inds(obs[:,0], obs[:,1])

      tracker.observe(obs)
      tracker.plot()
      print 'observed.'

    elif key == ord(' '):
      tracker.optimize_sqp()
      tracker.plot()
Example #29
0
#!/usr/bin/env python

import tests

tests.run_tests()
Example #30
0
"""Test the '_test_all_* test files. This is a much more complete test suite,
but accesses the larger, private test data."""
import os.path as osp

from tests import run_tests


test_dir = osp.dirname(__file__)
run_tests(test_dir, pattern='_test_all_*.py')
Example #31
0
# Unit tests to check your solution
from tests import run_tests

run_tests(shirt_one, shirt_two, total, total_discount)
Example #32
0

def handle_def_2(sym, lib, acc):
    defs = acc['defs']
    lib_defs = lib['defs']
    if sym in lib_defs:
        if sym not in defs:
            pass # todo
    elif sym not in acc['vars']:
        pass # todo


def handle_def_dict(sym, lib, acc, sym_def):
    decoded_dict = decode_dict_internal(sym_def, lib, acc)
    target = lib['lang']['target']
    sym_def2 = (
        target['def_fun'](sym, decoded_dict['head'], decoded_dict['body'])
        if decoded_dict['is_lambda']
        else target['def_fun'](sym, decoded_dict['json_str']))
    acc['defs'][sym] = sym_def2


def handle_def_non_dict(sym, lib, acc, sym_def):
    body = decode_acc(sym_def, lib, acc)
    sym_def2 = lib['lang']['target']['def'](sym, body)
    acc['defs'][sym] = sym_def2


if __name__ == '__main__':
    tests.run_tests(eval_lispson)
Example #33
0
#!/usr/bin/env python

import os
import sys

from tests import run_tests

sys.path.insert(0, os.path.dirname(__file__))

run_tests()
Example #34
0
def main():
    import argparse
    parser = argparse.ArgumentParser()
    parser.add_argument('--test', action='store_true')
    args = parser.parse_args()

    if args.test:
        import tests
        tests.run_tests()

    cam_t = (0, -.5)
    r_angle = 0
    fov = 75 * np.pi / 180.
    cam1d = flatland.Camera1d(cam_t, r_angle, fov, SIZE)
    cam2d = flatland.Camera2d(WORLD_MIN, WORLD_MAX, SIZE)

    tracker = Tracker(np.ones((SIZE, SIZE)))

    poly_center = np.array([0., 0.])
    poly_scale = .5
    poly_rot = 0.
    while True:
        poly_pts = np.array([[-0.5, -0.5], [0.5, -0.5], [0.5, 0.5], [
            -0.5, 0.5
        ]]).dot(flatland.rotation2d(poly_rot).T) * poly_scale + poly_center[
            None, :]

        #poly = flatland.Polygon([[.2, .2], [0,1], [1,1], [1,.5]])
        poly = flatland.Polygon(poly_pts)
        polylist = [poly]

        image1d, depth1d = cam1d.render(polylist)
        # print 'depth1d', depth1d

        depth_min, depth_max = 0, 1
        depth1d_normalized = (np.clip(depth1d, depth_min, depth_max) -
                              depth_min) / (depth_max - depth_min)
        depth1d_image = np.array(
            [[.5, 0, 0]]) * depth1d_normalized[:, None] + np.array(
                [[1., 1., 1.]]) * (1. - depth1d_normalized[:, None])
        depth1d_image[np.logical_not(np.isfinite(depth1d))] = (0, 0, 0)

        # observed_XYs = cam1d.unproject(depth1d)
        # filtered_obs_XYs = np.array([p for p in observed_XYs if np.isfinite(p).all()])
        # obs_render_list = [flatland.Point(p, c) for (p, c) in zip(observed_XYs, depth1d_image) if np.isfinite(p).all()]
        # print 'obs world', filtered_obs_XYs
        obs_render_list = []
        camera_poly_list = [
            flatland.make_camera_poly(cam1d.t, cam1d.r_angle, fov)
        ]
        image2d = cam2d.render(polylist + obs_render_list + camera_poly_list)
        image2d_poly = cam2d.render(polylist)
        #import IPython; IPython.embed()

        drawn_inds = np.nonzero((abs(image2d_poly) > .00001).astype(int).sum(
            axis=2))  # HACK: assumes not drawn is filled with 0
        image2d[drawn_inds] = [0, 1, 0]
        drawn_pts = np.transpose(drawn_inds)

        P = flatland.Render2d(cam2d.bl, cam2d.tr, cam2d.width).P
        observed_XYs = np.array(
            [p for p in cam1d.unproject(depth1d) if np.isfinite(p).all()])
        observed_px = np.round(observed_XYs.dot(P[:2, :2].T) +
                               P[:2, 2]).astype(int)
        # from scipy.spatial import KDTree
        # kdt = KDTree(drawn_pts)
        # print observed_px
        # print kdt.query(observed_px)
        # observed_drawn_pts = drawn_pts[kdt.query(observed_px)[1]]
        #image2d[observed_drawn_pts[:,1],observed_drawn_pts[:,0]] = [1,0,0]
        image2d[observed_px[:, 1], observed_px[:, 0]] = [0, 0, 1]
        Pinv = np.linalg.inv(P)
        filtered_obs_XYs = observed_px.dot(Pinv[:2, :2].T) + Pinv[:2, 2]

        flatland.show_1d_image([image1d, depth1d_image], "image1d+depth1d")
        flatland.show_2d_image(image2d, "image2d")
        cv2.moveWindow("image2d", 0, 0)
        key = cv2.waitKey() & 255
        print "key", key

        # linux
        if key == 81:
            cam1d.t[0] += .1
        elif key == 82:
            cam1d.t[1] += .1
        elif key == 84:
            cam1d.t[1] -= .1
        elif key == 83:
            cam1d.t[0] -= .1
        elif key == ord('['):
            cam1d.r_angle -= .1
        elif key == ord(']'):
            cam1d.r_angle += .1

        elif key == ord('q'):
            break

        if key == ord('a'):
            poly_center[0] += .01
        elif key == ord('w'):
            poly_center[1] += .01
        elif key == ord('s'):
            poly_center[1] -= .01
        elif key == ord('d'):
            poly_center[0] -= .01
        elif key == ord('-'):
            poly_rot -= .1
        elif key == ord('='):
            poly_rot += .1

#   elif key == ord('c'):
#     tracker = Tracker(empty_sdf)
#     tracker.plot()
#     print 'zeroed out sdf and control'

        elif key == ord('i'):
            # initialization
            # compute sdf of starting state as initialization
            image2d = cam2d.render(polylist)
            init_state_edge = np.ones((SIZE, SIZE), dtype=int)
            is_edge = image2d[:, :, 0] > .5
            init_state_edge[is_edge] = 0
            init_sdf_img = distance_transform_edt(init_state_edge) * np.sqrt(
                sqp_problem.Config.PIXEL_AREA)
            # negate inside the boundary
            orig_filling = [p.filled for p in polylist]
            for p in polylist:
                p.filled = True
            image2d_filled = cam2d.render(polylist)
            for orig, p in zip(orig_filling, polylist):
                p.filled = orig
            init_sdf_img[image2d_filled[:, :, 0] > .5] *= -1
            init_sdf = init_sdf_img
            #init_sdf = sqp_problem.make_interp(init_sdf_img)#grid.SpatialFunction.FromImage(WORLD_MIN[0], WORLD_MAX[0], WORLD_MIN[1], WORLD_MAX[1], init_sdf_img)

            tracker = Tracker(init_sdf)  #smooth_by_edt(init_sdf))
            tracker.observe(filtered_obs_XYs)
            tracker.plot()

        elif key == ord('o'):
            tracker.observe(filtered_obs_XYs)
            tracker.plot()
            print 'observed.'

        elif key == ord(' '):
            tracker.optimize_sqp()
            tracker.plot()
Example #35
0
from Functions import *
from tests import run_tests

run_tests()

obtiuni = """
1 - Genereaza umratorul numar prim
2 - Goldbach
3 - Determina varsta in functie de zile
4 - Genereaza numere prime gemene
5 - Produsul factorilor lui n
6 - Calculeaza palindromul unui numar
7 - Nr perfect mai mare ca n
8 - Nr prim mai mic ca n
9 - Nr perfect mai mic ca n
10 - Numar din fibonacci mai mare ca n
11 - Produs numere prime din sir
12 - Suma numere prime din sir
13 - Cel mai mare numar prim din  sir
14 - Cel mai mic numar prim din  sir
15 - Sume numere neprime din sir
Obtiune:
"""


def read_numbers():
    numbers = input("Numbers (space separated):").strip()
    numbers = list(map(int, numbers.split(" ")))
    return numbers

Example #36
0
 def do_tests(self, _opts):
     """ Command run test suite """
     tests.run_tests(self.comm)
Example #37
0
    def flip_grid(grid):
        return [line[::-1] for line in grid]

    @staticmethod
    def rotate_grid(grid):
        rows = []
        for i in range(len(grid)):
            row = "".join(r[i] for r in grid[::-1])
            rows.append(row)
        return rows

    def grid_rotations(self):
        zero = self.inner_grid
        once = self.rotate_grid(zero)
        twice = self.rotate_grid(once)
        thrice = self.rotate_grid(twice)

        return [
            zero,
            self.flip_grid(zero),
            once,
            self.flip_grid(once),
            twice,
            self.flip_grid(twice),
            thrice,
            self.flip_grid(thrice),
        ]


run_tests(func=get_solution, result=273)
Example #38
0
            else:
                end = parentheses_match.span()[1]

            value = reduce(line[start + 1:end - 1])

        # then evaluate + and finally *
        else:
            match = re.search(r"\d+ \+ \d+", line) or re.search(
                r"\d+ \* \d+", line)
            value = str(eval(match[0]))
            start, end = match.span()[0], match.span()[1]

        line = line[:start] + value + line[end:]

    return line


def find_closing_parenthesis(line, start):
    opening, closing = 0, 0
    for i, char in enumerate(line[start:]):
        if char == "(":
            opening += 1
        elif char == ")":
            closing += 1

        if opening == closing:
            return start + i + 1


run_tests(func=get_solution, result=669060)
Example #39
0
File: setup.py Project: gryf/wicd
 def run(self):
     log.info("importing tests")
     import tests
     log.info('running tests')
     tests.run_tests()
            \t<td>2 lines<br />in Cell 1.2</td>
            </tr>
            <tr>
            \t<td>Cell 2.1</td>
            \t<td>Cell 2.2</td>
            </tr>
            </table>
            <p>table 1 end</p>
            <table>
            <tr>
            \t<td>Cell 1.1</td>
            \t<td>Cell 1.2</td>
            \t<td>Cell 1.3</td>
            </tr>
            <tr>
            \t<td>Cell 2.1</td>
            \t<td>Cell 2.2</td>
            \t<td>Cell 2.3</td>
            </tr>
            </table>
            
        """)


if __name__ == "__main__":
    # Run this unitest directly
    import os
    os.chdir("../")
    filename = os.path.splitext(os.path.basename(__file__))[0]
    tests.run_tests(test_labels=[filename])
Example #41
0
def run():
    list_complex = []  # main list
    undoList = []
    run_tests()
    ui_project(list_complex, undoList)  # start ui function
Example #42
0
 def run(self):
     print "importing tests"
     import tests
     print 'running tests'
     tests.run_tests()
Example #43
0
def testrunner():
    import tests
    return tests.run_tests()
Example #44
0
reload(sys)
sys.setdefaultencoding('utf8')
from __init__ import __version__



args = arg_parser.parse_args()


if args.version:
    print __version__
    sys.exit()

if args.test:
    import tests
    tests.run_tests(verbose=args.verbose)
    sys.exit()

if not sys.stdin.isatty():
    # read and evaluate piped input
    if args.eval is None: args.eval = ''
    args.eval = sys.stdin.read() + args.eval


interactive = (not args.file and not args.eval) or args.interactive


def run():
    if interactive: print '''Scotch %s''' % __version__

    for input_file in args.file:
Example #45
0
 def run(self):
     print "importing tests"
     import tests
     print 'running tests'
     tests.run_tests()