How to use test_add_patch method in tempest

Best Python code snippet using tempest_python

test_patchwork.py

Source:test_patchwork.py Github

copy

Full Screen

...90 test_value_extra = set(["b@example.com"])91 self.testobj.merge_email_addr_set(test_value_extra)92 expected_set = set([list(test_value)[0], list(test_value_extra)[0]])93 self.assertSetEqual(expected_set, self.testobj.email_addr_set)94 def test_add_patch(self):95 """Ensure new patches are appended to the patch list."""96 # Patch list should be empty97 self.assertEqual([], self.testobj.patch_list)98 # Add a patch and check99 self.testobj.add_patch('patch1')100 self.assertEqual(['patch1'], self.testobj.patch_list)101 # Add a second patch and check102 self.testobj.add_patch('patch2')103 self.assertEqual(['patch1', 'patch2'], self.testobj.patch_list)104 def test_is_empty(self):105 """Ensure that is_empty() can check if patch_list is empty."""106 # Patch list should be empty before adding patches107 self.assertTrue(self.testobj.is_empty())108 # Add a patch and test...

Full Screen

Full Screen

test__plot_helpers.py

Source:test__plot_helpers.py Github

copy

Full Screen

1# Licensed under the Apache License, Version 2.0 (the "License");2# you may not use this file except in compliance with the License.3# You may obtain a copy of the License at4#5# https://www.apache.org/licenses/LICENSE-2.06#7# Unless required by applicable law or agreed to in writing, software8# distributed under the License is distributed on an "AS IS" BASIS,9# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.10# See the License for the specific language governing permissions and11# limitations under the License.12import functools13import sys14import unittest15import unittest.mock16import numpy as np17from tests.unit import utils18def run_fake_modules(modules, func):19 existing = {}20 for name, mod_obj in modules.items():21 if name in sys.modules: # pragma: NO COVER22 existing[name] = sys.modules.pop(name)23 sys.modules[name] = mod_obj24 try:25 return func()26 finally:27 for name in modules.keys():28 sys.modules.pop(name)29 if name in existing: # pragma: NO COVER30 sys.modules[name] = existing[name]31class Test_new_axis(unittest.TestCase):32 @staticmethod33 def _call_function_under_test():34 from bezier import _plot_helpers35 return _plot_helpers.new_axis()36 def test_it(self):37 figure = unittest.mock.Mock(spec=["gca"])38 figure.gca.return_value = unittest.mock.sentinel.ax39 plt = unittest.mock.Mock(spec=["figure"])40 plt.figure.return_value = figure41 matplotlib = unittest.mock.Mock(pyplot=plt, spec=["pyplot"])42 modules = {"matplotlib": matplotlib, "matplotlib.pyplot": plt}43 result = run_fake_modules(modules, self._call_function_under_test)44 self.assertIs(result, unittest.mock.sentinel.ax)45 # Verify mocks.46 plt.figure.assert_called_once_with()47 figure.gca.assert_called_once_with()48class Test_add_plot_boundary(unittest.TestCase):49 @staticmethod50 def _call_function_under_test(ax, **kwargs):51 from bezier import _plot_helpers52 return _plot_helpers.add_plot_boundary(ax, **kwargs)53 def _helper(self, **kwargs):54 line = unittest.mock.Mock(spec=["get_xydata"])55 line.get_xydata.return_value = np.asfortranarray(56 [[-1.0, -1.0], [1.0, 1.0]]57 )58 ax = unittest.mock.Mock(59 lines=[line], spec=["lines", "set_xlim", "set_ylim"]60 )61 self.assertIsNone(self._call_function_under_test(ax, **kwargs))62 padding = kwargs.get("padding", 0.125)63 ax.set_xlim.assert_called_once_with(-1.0 - padding, 1.0 + padding)64 ax.set_ylim.assert_called_once_with(-1.0 - padding, 1.0 + padding)65 def test_default(self):66 self._helper()67 def test_with_padding(self):68 self._helper(padding=0.5)69class Test_add_patch(utils.NumPyTestCase):70 @staticmethod71 def _call_function_under_test(72 ax, color, pts_per_edge, *edges, alpha=0.62573 ):74 from bezier import _plot_helpers75 return _plot_helpers.add_patch(76 ax, color, pts_per_edge, *edges, alpha=alpha77 )78 def _path_val(self, path, expected_transpose):79 self.assertEqual(path.Path.call_count, 1)80 call = path.Path.mock_calls[0]81 _, positional, keyword = call82 self.assertEqual(keyword, {})83 self.assertEqual(len(positional), 1)84 self.assertEqual(positional[0].T, expected_transpose)85 def _plot_check(self, ax, expected, color):86 self.assertEqual(ax.plot.call_count, 1)87 call = ax.plot.mock_calls[0]88 utils.check_plot_call(self, call, expected, color=color)89 @staticmethod90 def _get_info(nodes):91 from bezier import triangle as triangle_mod92 triangle = triangle_mod.Triangle(nodes, 1, copy=False)93 edges = triangle._get_edges()94 expected = np.empty((2, 7), order="F")95 expected[:, 0] = 0.5 * (nodes[:, 0] + nodes[:, 1])96 expected[:, 1] = nodes[:, 1]97 expected[:, 2] = 0.5 * (nodes[:, 1] + nodes[:, 2])98 expected[:, 3] = nodes[:, 2]99 expected[:, 4] = 0.5 * (nodes[:, 2] + nodes[:, 0])100 expected[:, 5] = nodes[:, 0]101 expected[:, 6] = expected[:, 0]102 return expected, edges103 def test_it(self):104 # Set-up input values.105 color = (0.25, 0.5, 0.75)106 pts_per_edge = 3107 nodes = np.asfortranarray([[0.0, 1.0, 2.0], [1.0, 3.0, 6.0]])108 expected_transpose, edges = self._get_info(nodes)109 # Set-up mocks (quite a lot).110 patches = unittest.mock.Mock(spec=["PathPatch"])111 path = unittest.mock.Mock(spec=["Path"])112 matplotlib = unittest.mock.Mock(113 patches=patches, path=path, spec=["patches", "path"]114 )115 ax = unittest.mock.Mock(spec=["add_patch", "plot"])116 line = unittest.mock.Mock(spec=["get_color"])117 line.get_color.return_value = color118 ax.plot.return_value = (line,)119 # Run the code with fake modules.120 modules = {121 "matplotlib": matplotlib,122 "matplotlib.patches": patches,123 "matplotlib.path": path,124 }125 func = functools.partial(126 self._call_function_under_test,127 ax,128 color,129 pts_per_edge,130 *edges,131 alpha=0.5132 )133 result = run_fake_modules(modules, func)134 self.assertIsNone(result)135 # Verify mocks (quite a lot).136 self._path_val(path, expected_transpose)137 patches.PathPatch.assert_called_once_with(138 path.Path.return_value,139 facecolor=color,140 edgecolor=color,141 alpha=0.5,142 )143 ax.add_patch.assert_called_once_with(patches.PathPatch.return_value)144 line.get_color.assert_called_once_with()...

Full Screen

Full Screen

test_environment.py

Source:test_environment.py Github

copy

Full Screen

...1011 def test_instance(self):12 self.assertIsNotNone(self.env)1314 def test_add_patch(self):15 self.env.add_patch()16 self.assertIsNotNone(self.env.children)17 self.assertTrue(len(self.env.children) > 0)18 self.assertIsNotNone(self.env.children[0])1920 def test_patch_location(self):21 for i in range(100):22 x, y = self.env.patch_location(10.0)23 self.assertTrue((x >= 0.0) and (x <= self.env.length))24 self.assertTrue(y >= 0.0 and y <= self.env.width)2526 def test_create_patches(self):27 self.env.children = []28 self.env.create_patches() ...

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 tempest 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