diff --git a/gnes/cli/parser.py b/gnes/cli/parser.py index ab08d760..e3a2e3ae 100644 --- a/gnes/cli/parser.py +++ b/gnes/cli/parser.py @@ -154,6 +154,7 @@ def set_preprocessor_service_parser(parser=None): parser = set_base_parser() from pkg_resources import resource_stream set_loadable_service_parser(parser) + parser.get_default('yaml_path').close() parser.set_defaults(yaml_path=resource_stream( 'gnes', '/'.join(('resources', 'config', 'preprocessor', 'default.yml')))) @@ -166,6 +167,7 @@ def set_router_service_parser(parser=None): if not parser: parser = set_base_parser() set_loadable_service_parser(parser) + parser.get_default('yaml_path').close() parser.set_defaults(yaml_path=resource_stream( 'gnes', '/'.join(('resources', 'config', 'router', 'default.yml')))) @@ -180,6 +182,7 @@ def set_indexer_service_parser(parser=None): if not parser: parser = set_base_parser() set_loadable_service_parser(parser) + parser.get_default('yaml_path').close() parser.set_defaults(yaml_path=resource_stream( 'gnes', '/'.join(('resources', 'config', 'indexer', 'default.yml')))) diff --git a/tests/test_preprocessor.py b/tests/test_preprocessor.py index a4ac0a6e..c180ffac 100644 --- a/tests/test_preprocessor.py +++ b/tests/test_preprocessor.py @@ -2,6 +2,7 @@ import unittest from gnes.cli.parser import set_preprocessor_service_parser, _set_client_parser +from gnes.composer.base import YamlComposer from gnes.proto import gnes_pb2 from gnes.service.grpc import ZmqClient from gnes.service.preprocessor import PreprocessorService @@ -15,12 +16,18 @@ def setUp(self): self.dirname = os.path.dirname(__file__) def test_preprocessor_service_empty(self): - args = set_preprocessor_service_parser().parse_args([]) + args = set_preprocessor_service_parser().parse_args([ + '--port_in', str(YamlComposer._get_random_port()), + '--port_out', str(YamlComposer._get_random_port()) + ]) with PreprocessorService(args): pass def test_preprocessor_service_echo(self): - args = set_preprocessor_service_parser().parse_args([]) + args = set_preprocessor_service_parser().parse_args([ + '--port_in', str(YamlComposer._get_random_port()), + '--port_out', str(YamlComposer._get_random_port()) + ]) c_args = _set_client_parser().parse_args([ '--port_in', str(args.port_out), '--port_out', str(args.port_in) @@ -37,7 +44,10 @@ def test_preprocessor_service_echo(self): print(r) def test_preprocessor_service_realdata(self): - args = set_preprocessor_service_parser().parse_args([]) + args = set_preprocessor_service_parser().parse_args([ + '--port_in', str(YamlComposer._get_random_port()), + '--port_out', str(YamlComposer._get_random_port()) + ]) c_args = _set_client_parser().parse_args([ '--port_in', str(args.port_out), '--port_out', str(args.port_in)