Пример #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
Пример #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
Пример #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
Пример #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
Пример #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
Пример #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
Пример #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)
Пример #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
Пример #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
Пример #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
Пример #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"])
Пример #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"])
Пример #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"]
Пример #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"]
Пример #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)
Пример #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]
Пример #17
0
def test_dir_jvmview_default():
    with example_app_process():
        with gateway() as g:
            helper_dir_jvmview(g.jvm)
Пример #18
0
def test_dir_jvmview_new():
    with example_app_process():
        with gateway() as g:
            view = g.new_jvm_view()
            helper_dir_jvmview(view)
Пример #19
0
def test_dir_jvmview_default():
    with example_app_process():
        with gateway() as g:
            helper_dir_jvmview(g.jvm)
Пример #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)
Пример #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]
Пример #22
0
def test_dir_jvmview_new():
    with example_app_process():
        with gateway() as g:
            view = g.new_jvm_view()
            helper_dir_jvmview(view)
Пример #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
Пример #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