Support @ValidatesRunner(RunnableOnService) in Python [1/2]
Project: http://git-wip-us.apache.org/repos/asf/incubator-beam/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-beam/commit/cc706608 Tree: http://git-wip-us.apache.org/repos/asf/incubator-beam/tree/cc706608 Diff: http://git-wip-us.apache.org/repos/asf/incubator-beam/diff/cc706608 Branch: refs/heads/python-sdk Commit: cc706608b281c3beeebd2487084946c06bc83f30 Parents: 9060f83 Author: Mark Liu <mark...@markliu-macbookpro.roam.corp.google.com> Authored: Thu Nov 17 09:53:01 2016 -0800 Committer: Thomas Groh <tg...@google.com> Committed: Tue Nov 22 10:11:22 2016 -0800 ---------------------------------------------------------------------- sdks/python/setup.py | 4 ++++ sdks/python/test_config.py | 44 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/cc706608/sdks/python/setup.py ---------------------------------------------------------------------- diff --git a/sdks/python/setup.py b/sdks/python/setup.py index 1299bbf..525f59c 100644 --- a/sdks/python/setup.py +++ b/sdks/python/setup.py @@ -137,4 +137,8 @@ setuptools.setup( ], license='Apache License, Version 2.0', keywords=PACKAGE_KEYWORDS, + entry_points={ + 'nose.plugins.0.10': [ + 'beam_test_plugin = test_config:BeamTestPlugin' + ]} ) http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/cc706608/sdks/python/test_config.py ---------------------------------------------------------------------- diff --git a/sdks/python/test_config.py b/sdks/python/test_config.py new file mode 100644 index 0000000..bde2795 --- /dev/null +++ b/sdks/python/test_config.py @@ -0,0 +1,44 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Test configurations for nose + +This module contains nose plugin hooks that configures Beam tests which +includes ValidatesRunner test and E2E integration test. + +""" + +from nose.plugins import Plugin + + +class BeamTestPlugin(Plugin): + """A nose plugin for Beam testing that registers command line options + + This plugin is registered through setuptools in entry_points. + """ + + def options(self, parser, env): + """Add '--test-pipeline-options' to command line option to avoid + unrecognized option error thrown by nose. + + The value of this option will be processed by TestPipeline and used to + build customized pipeline for ValidatesRunner tests. + """ + parser.add_option('--test-pipeline-options', + action='store', + type=str, + help='providing pipeline options to run tests on runner')