How to use _run_unittest method in avocado

Best Python code snippet using avocado_python

test_runner.py

Source:test_runner.py Github

copy

Full Screen

...111 for name in frappe.db.sql_list("select name from `tab%s`" % doctype):112 frappe.delete_doc(doctype, name, force=True)113 make_test_records(doctype, verbose=verbose, force=force)114 modules.append(importlib.import_module(test_module))115 return _run_unittest(modules, verbose=verbose, tests=tests, profile=profile)116def run_tests_for_module(module, verbose=False, tests=(), profile=False):117 module = importlib.import_module(module)118 if hasattr(module, "test_dependencies"):119 for doctype in module.test_dependencies:120 make_test_records(doctype, verbose=verbose)121 return _run_unittest(module, verbose=verbose, tests=tests, profile=profile)122def run_setup_wizard_ui_test(app=None, verbose=False, profile=False):123 '''Run setup wizard UI test using test_test_runner'''124 frappe.flags.run_setup_wizard_ui_test = 1125 return run_ui_tests(app=app, test=None, verbose=verbose, profile=profile)126def run_ui_tests(app=None, test=None, test_list=None, verbose=False, profile=False):127 '''Run a single unit test for UI using test_test_runner'''128 module = importlib.import_module('frappe.tests.ui.test_test_runner')129 frappe.flags.ui_test_app = app130 if test_list:131 frappe.flags.ui_test_list = test_list132 else:133 frappe.flags.ui_test_path = test134 return _run_unittest(module, verbose=verbose, tests=(), profile=profile)135def _run_unittest(modules, verbose=False, tests=(), profile=False):136 test_suite = unittest.TestSuite()137 if not isinstance(modules, (list, tuple)):138 modules = [modules]139 for module in modules:140 module_test_cases = unittest.TestLoader().loadTestsFromModule(module)141 if tests:142 for each in module_test_cases:143 for test_case in each.__dict__["_tests"]:144 if test_case.__dict__["_testMethodName"] in tests:145 test_suite.addTest(test_case)146 else:147 test_suite.addTest(module_test_cases)148 if profile:149 pr = cProfile.Profile()...

Full Screen

Full Screen

py_test.py

Source:py_test.py Github

copy

Full Screen

...17 )18 [ ]*\( # open paren marks the end of the class name19''', re.VERBOSE)20def run_python_tests(external=0):21 _run_unittest("%", external, verbose=True)22def run_single_test_method(external):23 '''24 Runs the single test method currently under the text cursor25 '''26 if vim.current.buffer.name is None:27 print 'Not a file'28 return29 current_file = relpath(vim.current.buffer.name)30 current_line_no = vim.current.window.cursor[0] - 131# vim.command('silent wall')32 # find the names of the test method and the test class under the cursor33 line, method = _find_prior_matching_line(current_line_no, test_method_re)34 if method is None:35 vim.command("""call RedBar("Can't find test method")""")36 return37 _, klass = _find_prior_matching_line(line, test_class_re)38 if klass is None:39 vim.command("""call RedBar("Can't find test class")""")40 return41 # create command of the form42 # nosetests -s package1.package2.module.class.method43 #module = _filename_to_module(current_file)44 dotted_method_name = '%s:%s.%s' % (current_file, klass, method)45 _run_unittest(dotted_method_name, external, verbose=True)46def run_single_test_class(external):47 '''48 Runs the single test class currently under the text cursor49 '''50 if vim.current.buffer.name is None:51 print 'Not a file'52 return53 current_file = relpath(vim.current.buffer.name)54 current_line_no = vim.current.window.cursor[0] - 155 # find the names of the test class under the cursor56 _, klass = _find_prior_matching_line(current_line_no, test_class_re)57 if klass is None:58 vim.command("""call RedBar("Can't find test class")""")59 return60 # create command of the form61 # nosetests -s package1.package2.module.class62 dotted_method_name = '%s:%s' % (current_file, klass)63 _run_unittest(dotted_method_name, external, verbose=True)64def _filename_to_module(filename):65 pathname = splitext( splitdrive(filename)[1] )[0]66 return pathname.replace(sep, '.')67def _run_unittest(test, external, verbose=False):68 # create command of the form69 # nosetests test.py:class.method70 # and run asynchronously71 verbose_flag = '-s' if verbose else ''72 #command = 'python -m unittest %s%s' % (verbose_flag, test,)73 command = 'nosetests -x %s %s' % (verbose_flag, test,)74 #print command75 vim.command("silent compiler pyunit")76 vim.command("call RunCommand('%s', %d)" % (command, external))77def _find_prior_matching_line(line_number, pattern):78 '''79 Starting at given line number and working upwards towards start of file,80 look for first line which matches the given regex pattern. Return line81 number and match group 1. (e.g. method name or class name extracted from...

Full Screen

Full Screen

python_unittest.py

Source:python_unittest.py Github

copy

Full Screen

...33import os34class PythonUnittest(tu.TestResultCollector):35 def setUp(self):36 self._shm_leak_detector = shm_util.ShmLeakDetector()37 def _run_unittest(self, model_name):38 with grpcclient.InferenceServerClient("localhost:8001") as client:39 # No input is required40 result = client.infer(model_name, [], client_timeout=120)41 output0 = result.as_numpy('OUTPUT0')42 # The model returns 1 if the tests were sucessfully passed.43 # Otherwise, it will return 0.44 self.assertEqual(output0, [1])45 def test_python_unittest(self):46 model_name = os.environ['MODEL_NAME']47 if model_name == 'bls' or model_name == 'bls_memory' or model_name == 'bls_memory_async':48 # For these tests, the memory region size will be grown. Because of49 # this we need to use the shared memory probe only on the later50 # call so that the probe can detect the leak correctly.51 self._run_unittest(model_name)52 # [FIXME] See DLIS-368453 self._run_unittest(model_name)54 with self._shm_leak_detector.Probe() as shm_probe:55 self._run_unittest(model_name)56 else:57 with self._shm_leak_detector.Probe() as shm_probe:58 self._run_unittest(model_name)59if __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 avocado 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