Exemplo n.º 1
0
def test_dir_object():
    with example_app_process():
        with gateway() as g:
            ex = g.getNewExample()
            print(sorted(dir(ex)))
            print(ExampleClassMethods)
            assert sorted(dir(ex)) == ExampleClassMethods
Exemplo n.º 2
0
def test_dir_object():
    with example_app_process():
        with gateway() as g:
            ex = g.getNewExample()
            print(sorted(dir(ex)))
            print(ExampleClassMethods)
            assert sorted(dir(ex)) == ExampleClassMethods
Exemplo n.º 3
0
def test_help_class():
    with example_app_process():
        with gateway() as g:
            clazz = g.jvm.py4j.examples.ExampleClass
            doc = g.help(clazz, display=False)
            assert "Help on class ExampleClass in package py4j.examples" in doc
            assert "method1" in doc
            assert "method2" in doc
Exemplo n.º 4
0
def test_help_object():
    with example_app_process():
        with gateway() as g:
            ex = g.getNewExample()
            doc = g.help(ex, display=False)
            assert "Help on class ExampleClass in package py4j.examples" in doc
            assert "method1" in doc
            assert "method2" in doc
Exemplo n.º 5
0
def test_help_pattern_2():
    with example_app_process():
        with gateway() as g:
            ex = g.getNewExample()
            doc = g.help(ex, display=False, pattern="getField1(*")
            assert "Help on class ExampleClass in package py4j.examples" in doc
            assert "method1" not in doc
            assert "getField1" in doc
Exemplo n.º 6
0
def test_doc_object():
    with example_app_process():
        with gateway() as g:
            ex = g.getNewExample()
            doc = ex.__doc__
            assert "Help on class ExampleClass in package py4j.examples" in doc
            assert "method1" in doc
            assert "getField1" in doc
Exemplo n.º 7
0
def test_not_callable():
    with example_app_process():
        with gateway() as g:
            ex = g.getNewExample()
            try:
                ex()
                raise AssertionError
            except TypeError as e:
                assert "object is not callable" in str(e)
Exemplo n.º 8
0
def test_doc_class():
    with example_app_process():
        with gateway() as g:
            clazz = g.jvm.py4j.examples.ExampleClass
            doc = clazz.__doc__
            # Make sure multiple method7s appear (overloaded method)
            assert "Help on class ExampleClass in package py4j.examples" in doc
            assert "method1" in doc
            assert "method2" in doc
Exemplo n.º 9
0
def test_doc_method():
    with example_app_process():
        with gateway() as g:
            ex = g.getNewExample()
            doc = ex.method7.__doc__
            # Make sure multiple method7s appear (overloaded method)
            assert "method7(int)" in doc
            assert "method7(Object)" in doc
            assert "method1" not in doc
Exemplo n.º 10
0
def test_help_method():
    with example_app_process():
        with gateway() as g:
            ex = g.getNewExample()
            doc = g.help(ex.method7, display=False)
            # Make sure multiple method7s appear (overloaded method)
            assert "method7(int)" in doc
            assert "method7(Object)" in doc
            assert "method1" not in doc
Exemplo n.º 11
0
def test_dir_object_shows_manually_called_before_dir():
    with example_app_process():
        with gateway() as g:
            ex = g.getNewExample()
            try:
                ex.does_not_exist_in_example()
                raise AssertionError("Method should not have succeeded")
            except Py4JError:
                pass
            # Make sure the manually called method now shows up
            assert sorted(dir(ex)) == sorted(ExampleClassMethods + ["does_not_exist_in_example"])
Exemplo n.º 12
0
def test_dir_object_shows_manually_called_before_dir():
    with example_app_process():
        with gateway() as g:
            ex = g.getNewExample()
            try:
                ex.does_not_exist_in_example()
                raise AssertionError("Method should not have succeeded")
            except Py4JError:
                pass
            # Make sure the manually called method now shows up
            assert sorted(dir(ex)) == sorted(ExampleClassMethods +
                                             ["does_not_exist_in_example"])
Exemplo n.º 13
0
def test_dir_jvmview_two():
    with example_app_process():
        with gateway() as g:
            view1 = g.new_jvm_view()
            view2 = g.new_jvm_view()
            helper_dir_jvmview(view1)
            helper_dir_jvmview(view2)

            # now give them different contents
            java_import(view1, "com.fourth.Class4")
            java_import(view2, "com.fiftg.Class5")

            assert sorted(dir(view1)) == [UserHelpAutoCompletion.KEY, "Class1", "Class2", "Class3", "Class4"]
            assert sorted(dir(view2)) == [UserHelpAutoCompletion.KEY, "Class1", "Class2", "Class3", "Class5"]
Exemplo n.º 14
0
def test_dir_jvmview_two():
    with example_app_process():
        with gateway() as g:
            view1 = g.new_jvm_view()
            view2 = g.new_jvm_view()
            helper_dir_jvmview(view1)
            helper_dir_jvmview(view2)

            # now give them different contents
            java_import(view1, "com.fourth.Class4")
            java_import(view2, "com.fiftg.Class5")

            assert sorted(dir(view1)) == [
                UserHelpAutoCompletion.KEY, "Class1", "Class2", "Class3",
                "Class4"]
            assert sorted(dir(view2)) == [
                UserHelpAutoCompletion.KEY, "Class1", "Class2", "Class3",
                "Class5"]
Exemplo n.º 15
0
def test_dir_object_fields():
    with example_app_process():
        with gateway(auto_field=True) as g:
            ex = g.getNewExample()
            assert sorted(dir(ex)) == sorted(ExampleClassMethods +
                                             ExampleClassFields)
Exemplo n.º 16
0
def test_dir_package():
    with example_app_process():
        with gateway() as g:
            assert sorted(dir(g.jvm)) == [UserHelpAutoCompletion.KEY]
            assert sorted(dir(g.jvm.java)) == [UserHelpAutoCompletion.KEY]
            assert sorted(dir(g.jvm.java.util)) == [UserHelpAutoCompletion.KEY]
Exemplo n.º 17
0
def test_dir_jvmview_default():
    with example_app_process():
        with gateway() as g:
            helper_dir_jvmview(g.jvm)
Exemplo n.º 18
0
def test_dir_jvmview_new():
    with example_app_process():
        with gateway() as g:
            view = g.new_jvm_view()
            helper_dir_jvmview(view)
Exemplo n.º 19
0
def test_dir_jvmview_default():
    with example_app_process():
        with gateway() as g:
            helper_dir_jvmview(g.jvm)
Exemplo n.º 20
0
def test_dir_object_fields():
    with example_app_process():
        with gateway(auto_field=True) as g:
            ex = g.getNewExample()
            assert sorted(dir(ex)) == sorted(
                ExampleClassMethods + ExampleClassFields)
Exemplo n.º 21
0
def test_dir_package():
    with example_app_process():
        with gateway() as g:
            assert sorted(dir(g.jvm)) == [UserHelpAutoCompletion.KEY]
            assert sorted(dir(g.jvm.java)) == [UserHelpAutoCompletion.KEY]
            assert sorted(dir(g.jvm.java.util)) == [UserHelpAutoCompletion.KEY]
Exemplo n.º 22
0
def test_dir_jvmview_new():
    with example_app_process():
        with gateway() as g:
            view = g.new_jvm_view()
            helper_dir_jvmview(view)
Exemplo n.º 23
0
def test_dir_class():
    with example_app_process():
        with gateway() as g:
            exclass = g.jvm.py4j.examples.ExampleClass
            assert sorted(dir(exclass)) == ExampleClassStatics
Exemplo n.º 24
0
def test_dir_class():
    with example_app_process():
        with gateway() as g:
            exclass = g.jvm.py4j.examples.ExampleClass
            assert sorted(dir(exclass)) == ExampleClassStatics