How to use _generate_test_sources method in Slash

Best Python code snippet using slash

loader.py

Source:loader.py Github

copy

Full Screen

...41 self._cached_matchers = None42 return self._cached_matchers43 def get_runnables(self, paths, prepend_interactive=False):44 assert context.session is not None45 sources = self._generate_repeats(self._generate_test_sources(paths))46 returned = self._collect(sources)47 self._duplicate_funcs |= self._local_config.duplicate_funcs48 for (path, name, line) in sorted(self._duplicate_funcs):49 _logger.warning('Duplicate function definition, File: {}, Name: {}, Line: {}', path, name, line)50 if prepend_interactive:51 returned.insert(0, generate_interactive_test())52 for index, test in enumerate(returned):53 test.__slash__.parallel_index = index54 hooks.tests_loaded(tests=returned) # pylint: disable=no-member55 returned.sort(key=lambda test: (56 test.__slash__.repeat_all_index, test.__slash__.get_sort_key()57 ))58 for test in returned:59 if test.__slash__.id is not None:60 raise SlashInternalError('Slash ID of {!r} should be None, but is {}'.format(test, test.__slash__.id))61 test.__slash__.allocate_id()62 return returned63 def _generate_repeats(self, tests):64 returned = []65 repeat_each = config.root.run.repeat_each66 for test in tests:67 for i in range(repeat_each * repeat_marker.get_value(test.get_test_function(), 1)):68 returned.append(test.clone() if i else test)69 num_tests = len(returned)70 for i in range(config.root.run.repeat_all - 1):71 for test in itertools.islice(returned, 0, num_tests):72 clone = test.clone()73 clone.__slash__.repeat_all_index = i + 174 returned.append(clone)75 return returned76 def _collect(self, iterator):77 returned = []78 context.reporter.report_collection_start()79 try:80 for x in iterator:81 returned.append(x)82 context.reporter.report_test_collected(returned, x)83 finally:84 context.reporter.report_collection_end(returned)85 context.session.increment_total_num_tests(len(returned))86 return returned87 def _generate_test_sources(self, thing, matcher=None):88 if isinstance(thing, tuple):89 assert len(thing) == 2, '_generate_test_sources on tuples requires a tuple of (loadable_obj, matcher)'90 iterator = self._generate_test_sources(thing[0], matcher=thing[1])91 elif isinstance(thing, (list, GeneratorType, itertools.chain)):92 iterator = itertools.chain.from_iterable(self._generate_test_sources(x) for x in thing)93 elif isinstance(thing, str):94 iterator = self._iter_test_address(thing)95 elif isinstance(thing, RunnableTest):96 iterator = [thing]97 elif isinstance(thing, ResumedTestData):98 iterator = self._iter_test_resume(thing)99 elif not isinstance(thing, RunnableTestFactory):100 thing = self._get_runnable_test_factory(thing)101 iterator = thing.generate_tests(fixture_store=context.session.fixture_store)102 return (t for t in iterator if matcher is None or matcher.matches(t.__slash__))103 def _iter_test_resume(self, resume_state):104 for test in self._iter_path(resume_state.file_name):105 if self._is_excluded(test):106 continue...

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