How to use merged_options method in yandex-tank

Best Python code snippet using yandex-tank

options_test.py

Source:options_test.py Github

copy

Full Screen

1# Copyright 2018 The TensorFlow Authors. All Rights Reserved.2#3# Licensed under the Apache License, Version 2.0 (the "License");4# you may not use this file except in compliance with the License.5# You may obtain a copy of the License at6#7# http://www.apache.org/licenses/LICENSE-2.08#9# Unless required by applicable law or agreed to in writing, software10# distributed under the License is distributed on an "AS IS" BASIS,11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12# See the License for the specific language governing permissions and13# limitations under the License.14# ==============================================================================15"""Tests for dataset options utilities."""16from __future__ import absolute_import17from __future__ import division18from __future__ import print_function19from tensorflow.python.data.util import options20from tensorflow.python.platform import test21class _TestOptions(options.OptionsBase):22 x = options.create_option(23 name="x",24 ty=int,25 docstring="the answer to everything",26 default_factory=lambda: 42)27 y = options.create_option(28 name="y", ty=float, docstring="a tasty pie", default_factory=lambda: 3.14)29class _NestedTestOptions(options.OptionsBase):30 opts = options.create_option(31 name="opts", ty=_TestOptions, docstring="nested options")32class OptionsTest(test.TestCase):33 def testDocumentation(self):34 self.assertEqual(_TestOptions.x.__doc__, "the answer to everything")35 self.assertEqual(_TestOptions.y.__doc__, "a tasty pie")36 def testCreateOption(self):37 opts = _TestOptions()38 self.assertEqual(opts.x, 42)39 self.assertEqual(opts.y, 3.14)40 self.assertIsInstance(opts.x, int)41 self.assertIsInstance(opts.y, float)42 opts.x = 043 self.assertEqual(opts.x, 0)44 with self.assertRaises(TypeError):45 opts.x = 3.1446 opts.y = 0.047 self.assertEqual(opts.y, 0.0)48 with self.assertRaises(TypeError):49 opts.y = 4250 def testMergeOptions(self):51 options1, options2 = _TestOptions(), _TestOptions()52 with self.assertRaises(ValueError):53 options.merge_options()54 merged_options = options.merge_options(options1, options2)55 self.assertEqual(merged_options.x, 42)56 self.assertEqual(merged_options.y, 3.14)57 options1.x = 058 options2.y = 0.059 merged_options = options.merge_options(options1, options2)60 self.assertEqual(merged_options.x, 0)61 self.assertEqual(merged_options.y, 0.0)62 def testMergeNestedOptions(self):63 options1, options2 = _NestedTestOptions(), _NestedTestOptions()64 merged_options = options.merge_options(options1, options2)65 self.assertEqual(merged_options.opts, None)66 options1.opts = _TestOptions()67 merged_options = options.merge_options(options1, options2)68 self.assertEqual(merged_options.opts, _TestOptions())69 options2.opts = _TestOptions()70 merged_options = options.merge_options(options1, options2)71 self.assertEqual(merged_options.opts, _TestOptions())72 options1.opts.x = 073 options2.opts.y = 0.074 merged_options = options.merge_options(options1, options2)75 self.assertEqual(merged_options.opts.x, 0)76 self.assertEqual(merged_options.opts.y, 0.0)77 def testMergeOptionsInvalid(self):78 with self.assertRaises(TypeError):79 options.merge_options(0)80 options1, options2 = _TestOptions(), _NestedTestOptions()81 with self.assertRaises(TypeError):82 options.merge_options(options1, options2)83 def testNoSpuriousAttrs(self):84 test_options = _TestOptions()85 with self.assertRaises(AttributeError):86 test_options.wrong_attr = True87 with self.assertRaises(AttributeError):88 _ = test_options.wrong_attr89if __name__ == "__main__":...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run yandex-tank automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful