Exemplo n.º 1
0
def test_upload_file_pyc(c, s, w):
    with tmpfile() as dirname:
        os.mkdir(dirname)
        with open(os.path.join(dirname, "foo.py"), mode="w") as f:
            f.write("def f():\n    return 123")

        sys.path.append(dirname)
        try:
            import foo

            assert foo.f() == 123
            pyc = cache_from_source(os.path.join(dirname, "foo.py"))
            assert os.path.exists(pyc)
            yield c.upload_file(pyc)

            def g():
                import foo

                return foo.x

            future = c.submit(g)
            result = yield future
            assert result == 123
        finally:
            sys.path.remove(dirname)
Exemplo n.º 2
0
def test_upload_file_pyc(c, s, w):
    with tmpfile() as dirname:
        os.mkdir(dirname)
        with open(os.path.join(dirname, 'foo.py'), mode='w') as f:
            f.write('def f():\n    return 123')

        sys.path.append(dirname)
        try:
            import foo
            assert foo.f() == 123
            pyc = cache_from_source(os.path.join(dirname, 'foo.py'))
            assert os.path.exists(pyc)
            yield c.upload_file(pyc)

            def g():
                import foo
                return foo.x

            future = c.submit(g)
            result = yield future
            assert result == 123
        finally:
            sys.path.remove(dirname)