You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use of "behave --format=json" fails with reference to undefined method:
Traceback (most recent call last):
File "C:\Python27\lib\runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "C:\Python27\lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "C:\Python27\lib\site-packages\behave-1.1.0-py2.7.egg\behave\__main__.py", line 116, in <module>
main()
File "C:\Python27\lib\site-packages\behave-1.1.0-py2.7.egg\behave\__main__.py", line 90, in main
failed = runner.run()
File "C:\Python27\lib\site-packages\behave-1.1.0-py2.7.egg\behave\runner.py", line 419, in run
self.run_with_paths()
File "C:\Python27\lib\site-packages\behave-1.1.0-py2.7.egg\behave\runner.py", line 444, in run_with_paths
failed = feature.run(self)
File "C:\Python27\lib\site-packages\behave-1.1.0-py2.7.egg\behave\model.py", line 238, in run
failed = scenario.run(runner)
File "C:\Python27\lib\site-packages\behave-1.1.0-py2.7.egg\behave\model.py", line 431, in run
runner.formatter.step(step)
File "C:\Python27\lib\site-packages\behave-1.1.0-py2.7.egg\behave\formatter\json.py", line 50, in step
element['steps'].append(step.to_dict())
AttributeError: 'dict' object has no attribute 'to_dict'
This is because the Scenario model object is being modified by the JSONFormatter in the step() method, since it is the last element returned by _feature_element():
def step(self, step):
element = self._feature_element()
if 'steps' not in element:
element['steps'] = []
element['steps'].append(step.to_dict())
So the Step gets converted to a dict and added to the Scenario, which causes Scenario.run to call the formatter with this added dict as if it were another step.
Activity
quantoid commentedon Aug 16, 2012
This is because the Scenario model object is being modified by the JSONFormatter in the step() method, since it is the last element returned by _feature_element():
So the Step gets converted to a dict and added to the Scenario, which causes Scenario.run to call the formatter with this added dict as if it were another step.