How to use _get_doctest_paths method in autotest

Best Python code snippet using autotest_python

test.py

Source:test.py Github

copy

Full Screen

...16 _PRINT_AFTER = 'Ran %d tests from %s'17 def __init__(self, app_dir, app_module_name):18 self._app_dir = app_dir19 self._app_module_name = app_module_name20 def _get_doctest_paths(self):21 doctest_dir = os.path.join(self._app_dir, 'doctests')22 doctest_paths = [os.path.join(doctest_dir, filename) for filename23 in os.listdir(doctest_dir)24 if not filename.startswith('.')25 if not filename.endswith('~')]26 return sorted(doctest_paths)27 def _get_modules(self):28 modules = []29 module_names = [os.path.basename(filename)[:-3]30 for filename31 in glob.glob(os.path.join(self._app_dir, '*.py'))32 if '__init__' not in filename33 and 'test.py' not in filename]34 # TODO: use common.setup_modules.import_module()35 app_module = __import__(self._app_module_name, globals(), locals(),36 module_names)37 for module_name in module_names:38 modules.append(getattr(app_module, module_name))39 return modules40 def run_tests(self):41 """42 module_list is ignored - we're just required to have this signature as a43 Django test runner.44 """45 doctest_paths = self._get_doctest_paths()46 modules = self._get_modules()47 total_errors = 048 old_db = settings.DATABASES['default']['NAME']49 django.test.utils.setup_test_environment()50 connection.creation.create_test_db()51 try:52 for module in modules:53 failures, test_count = doctest.testmod(module)54 print self._PRINT_AFTER % (test_count, module.__name__)55 total_errors += failures56 for path in doctest_paths:57 failures, test_count = doctest.testfile(path,58 module_relative=False)59 print self._PRINT_AFTER % (test_count, path)...

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