Best Python code snippet using tempest_python
test_plugin.py
Source:test_plugin.py
...11 self.plugin_dir = plugins12 def tearDown(self):13 shutil.rmtree(self.plugin_dir)14 def test_plugin_is_discovered(self):15 self._create_manifest('some_plugin', self._create_manifest_json('some_plugin'))16 self.config.plugins.discover([self.plugin_dir])17 self.assertTrue('some_plugin' in self.config.plugins.available())18 def test_code_files_are_loaded_in_order(self):19 # given20 def create_python_file_add_stmt(number, filename):21 self._create_code_file('from mailpile.plugins.order import add\nadd(%d)' % number, path.join(order_plugin_path, filename))22 order_plugin_path = path.join(self.plugin_dir, 'order')23 os.mkdir(order_plugin_path)24 create_python_file_add_stmt(1, 'first.py')25 create_python_file_add_stmt(2, 'second.py')26 create_python_file_add_stmt(3, 'third.py')27 self._create_code_file('x = []\ndef add(value):\n\tx.append(value)\n', path.join(order_plugin_path, 'order.py'))28 manifest = self._create_manifest_json('order')29 manifest['code']['python'] = ['order.py', 'first.py', 'second.py', 'third.py']30 self._create_manifest('order', manifest)31 #when32 self.config.plugins.discover([self.plugin_dir])33 try:34 self.mp.plugins_load('order')35 from mailpile.plugins.order import x36 #then37 self.assertEqual([1, 2, 3], x)38 finally:39 self.mp.plugins_disable('order')40 def _create_manifest(self, name, json_data):41 order_plugin = os.path.join(self.plugin_dir, name)42 if not os.path.exists(order_plugin):43 os.mkdir(order_plugin)44 manifest_file = os.path.join(order_plugin, 'manifest.json')45 with open(manifest_file, 'w') as fp:46 json.dump(json_data, fp)47 def _create_manifest_json(self, name):48 doc = dict()49 doc['name'] = name50 doc['author'] = 'Some Author'51 doc['code'] = {52 'python': [],53 'javascript': [],54 'css': []...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!