<s> from __future__ import unicode_literals , absolute_import <EOL> from py4j . java_gateway import JavaGateway , GatewayParameters <EOL> from py4j . tests . java_gateway_test import ( <EOL> start_example_app_process ) <EOL> from contextlib import contextmanager <EOL> @ contextmanager <EOL> def example_app_process ( ) : <EOL> p = start_example_app_process ( ) <EOL> try : <EOL> yield p <EOL> finally : <EOL> p . join ( ) <EOL> @ contextmanager <EOL> def gateway ( * args , ** kwargs ) : <EOL> g = JavaGateway ( <EOL> gateway_parameters = GatewayParameters ( <EOL> * args , auto_convert = True , ** kwargs ) ) <EOL> lineSep = g . jvm . System . lineSeparator ( ) <EOL> try : <EOL> yield g <EOL> assert lineSep == g . jvm . System . lineSeparator ( ) <EOL> finally : <EOL> g . shutdown ( ) <EOL> def test_help_object ( ) : <EOL> with example_app_process ( ) : <EOL> with gateway ( ) as g : <EOL> ex = g . getNewExample ( ) <EOL> doc = g . help ( ex , display = False ) <EOL> assert "<STR_LIT>" in doc <EOL> assert "<STR_LIT>" in doc <EOL> assert "<STR_LIT>" in doc <EOL> def test_doc_object ( ) : <EOL> with example_app_process ( ) : <EOL> with gateway ( ) as g : <EOL> ex = g . getNewExample ( ) <EOL> doc = ex . __doc__ <EOL> assert "<STR_LIT>" in doc <EOL> assert "<STR_LIT>" in doc <EOL> assert "<STR_LIT>" in doc <EOL> def test_not_callable ( ) : <EOL> with example_app_process ( ) : <EOL> with gateway ( ) as g : <EOL> ex = g . getNewExample ( ) <EOL> try : <EOL> ex ( ) <EOL> raise AssertionError <EOL> except TypeError as e : <EOL> assert "<STR_LIT>" in str ( e ) <EOL> def test_help_pattern_1 ( ) : <EOL> with example_app_process ( ) : <EOL> with gateway ( ) as g : <EOL> ex = g . getNewExample ( ) <EOL> doc = g . help ( ex , display = False , pattern = "<STR_LIT>" ) <EOL> assert "<STR_LIT>" in doc <EOL> assert "<STR_LIT>" in doc <EOL> assert "<STR_LIT>" not in doc <EOL> def test_help_pattern_2 ( ) : <EOL> with example_app_process ( ) : <EOL> with gateway ( ) as g : <EOL> ex = g . getNewExample ( ) <EOL> doc = g . help ( ex , display = False , pattern = "<STR_LIT>" ) <EOL> assert "<STR_LIT>" in doc <EOL> assert "<STR_LIT>" not in doc <EOL> assert "<STR_LIT>" in doc <EOL> def test_help_method ( ) : <EOL> with example_app_process ( ) : <EOL> with gateway ( ) as g : <EOL> ex = g . getNewExample ( ) <EOL> doc = g . help ( ex . method7 , display = False ) <EOL> assert "<STR_LIT>" in doc <EOL> assert "<STR_LIT>" in doc <EOL> assert "<STR_LIT>" not in doc <EOL> def test_doc_method ( ) : <EOL> with example_app_process ( ) : <EOL> with gateway ( ) as g : <EOL> ex = g . getNewExample ( ) <EOL> doc = ex . method7 . __doc__ <EOL> assert "<STR_LIT>" in doc <EOL> assert "<STR_LIT>" in doc <EOL> assert "<STR_LIT>" not in doc <EOL> def test_help_class ( ) : <EOL> with example_app_process ( ) : <EOL> with gateway ( ) as g : <EOL> clazz = g . jvm . py4j . examples . ExampleClass <EOL> doc = g . help ( clazz , display = False ) <EOL> assert "<STR_LIT>" in doc <EOL> assert "<STR_LIT>" in doc <EOL> assert "<STR_LIT>" in doc <EOL> def test_doc_class ( ) : <EOL> with example_app_process ( ) : <EOL> with gateway ( ) as g : <EOL> clazz = g . jvm . py4j . examples . ExampleClass <EOL> doc = clazz . __doc__ <EOL> assert "<STR_LIT>" in doc <EOL> assert "<STR_LIT>" in doc <EOL> assert "<STR_LIT>" in doc </s>
