How to use make_formatters method in Behave

Best Python code snippet using behave

test_formatter.py

Source:test_formatter.py Github

copy

Full Screen

...81 self._line += 182 return self._line83 def _formatter(self, file, config):84 stream_opener = StreamOpener(stream=file)85 f = make_formatters(config, [stream_opener])[0]86 f.uri('<string>')87 return f88 def _feature(self, keyword=u'k\xe9yword', name=u'name', tags=[u'spam', u'ham'],89 location=u'location', description=[u'description'], scenarios=[],90 background=None):91 line = self.line92 tags = [Tag(name, line) for name in tags]93 return Feature('<string>', line, keyword, name, tags=tags,94 description=description, scenarios=scenarios,95 background=background)96 def _scenario(self, keyword=u'k\xe9yword', name=u'name', tags=[], steps=[]):97 line = self.line98 tags = [Tag(name, line) for name in tags]99 return Scenario('<string>', line, keyword, name, tags=tags, steps=steps)100 def _step(self, keyword=u'k\xe9yword', step_type='given', name=u'name',101 text=None, table=None):102 line = self.line103 return Step('<string>', line, keyword, step_type, name, text=text,104 table=table)105 def _match(self, arguments=None):106 def dummy():107 pass108 return Match(dummy, arguments)109 def test_feature(self):110 # this test does not actually check the result of the formatting; it111 # just exists to make sure that formatting doesn't explode in the face of112 # unicode and stuff113 p = self._formatter(_tf(), self.config)114 f = self._feature()115 p.feature(f)116 def test_scenario(self):117 p = self._formatter(_tf(), self.config)118 f = self._feature()119 p.feature(f)120 s = self._scenario()121 p.scenario(s)122 def test_step(self):123 p = self._formatter(_tf(), self.config)124 f = self._feature()125 p.feature(f)126 s = self._scenario()127 p.scenario(s)128 s = self._step()129 p.step(s)130 p.match(self._match([]))131 s.status = u'passed'132 p.result(s)133class TestPretty(FormatterTests):134 formatter_name = 'pretty'135class TestPlain(FormatterTests):136 formatter_name = 'plain'137class TestJson(FormatterTests):138 formatter_name = 'json'139class TestTagsCount(FormatterTests):140 formatter_name = 'tags'141 def test_tag_counts(self):142 p = self._formatter(_tf(), self.config)143 s = self._scenario(tags=[u'ham', u'foo'])144 f = self._feature(scenarios=[s]) # feature.tags= ham, spam145 p.feature(f)146 p.scenario(s)147 eq_(p.tag_counts, {'ham': [ f, s ], 'spam': [ f ], 'foo': [ s ]})148class MultipleFormattersTests(FormatterTests):149 formatters = []150 def setUp(self):151 self.config = Mock()152 self.config.color = True153 self.config.outputs = [ StreamOpener(stream=sys.stdout)154 for i in self.formatters ]155 self.config.format = self.formatters156 def _formatters(self, file, config):157 stream_opener = StreamOpener(stream=file)158 fs = make_formatters(config, [stream_opener])159 for f in fs:160 f.uri('<string>')161 return fs162 def test_feature(self):163 # this test does not actually check the result of the formatting; it164 # just exists to make sure that formatting doesn't explode in the face of165 # unicode and stuff166 ps = self._formatters(_tf(), self.config)167 f = self._feature()168 for p in ps:169 p.feature(f)170 def test_scenario(self):171 ps = self._formatters(_tf(), self.config)172 f = self._feature()...

Full Screen

Full Screen

formatters.py

Source:formatters.py Github

copy

Full Screen

...24 _registry.register_as(name, formatter_class)25def register(formatter_class):26 register_as(formatter_class, formatter_class.name)27def get_formatter(config, stream_openers):28 warnings.warn("Use make_formatters() instead",29 DeprecationWarning, stacklevel=2)30 return _registry.make_formatters(config, stream_openers)31# -----------------------------------------------------------------------------32# SETUP:33# -----------------------------------------------------------------------------34def setup_formatters():35 warnings.warn("Use behave.formatter._builtins instead",36 DeprecationWarning, stacklevel=2)37 from behave.formatter import _builtins38 _builtins.setup_formatters()39# -----------------------------------------------------------------------------40# MODULE-INIT:41# -----------------------------------------------------------------------------...

Full Screen

Full Screen

behave_steps.py

Source:behave_steps.py Github

copy

Full Screen

...25 config = Configuration(command_args=cmd)26 result_tmp_dir = mkdtemp(dir=os.environ.get('TEST_TMP', None))27 stream_opener = StreamOpener(filename=result_tmp_dir)28 model_runner = ModelRunner(config, [context.feature_definition])29 model_runner.formatters = make_formatters(config, [stream_opener])30 model_runner.formatters[0].listener.fixture_context.enter()31 model_runner.hooks = getattr(context, 'globals', dict())32 model_runner.run()33 model_runner.formatters[0].listener.__del__()34 context.allure_report = AllureReport(result_tmp_dir)35 behave_tread = threading.Thread(target=run, args=(context,), kwargs=kwargs)36 behave_tread.start()...

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