简体   繁体   中英

Python trying to run behave get errors

I'm trying to use behave to run selenium tests but I'm stuck at start of that idea. I've setup python, selenium and behave as it should be. I'm running python scripts with selenium without an problem. My problems starts when I try to run them with behave. My python is 3.5.2, selenium is 2.53.2 and behave is 1.2.5. When I try to run any feature file I get errors bellow. It doesn't matter if I try to run it with PyCharm IDE or directly from command prompt. Does any one have a clue what is wrong or what I do wrong?

Errors:

Traceback (most recent call last):
  File "C:\Program Files (x86)\JetBrains\PyCharm 4.0.5\helpers\pycharm\behave_runner.py", line 269, in <module>
_BehaveRunner(my_config, base_dir).run()
  File "C:\Program Files (x86)\JetBrains\PyCharm 4.0.5\helpers\pycharm\_bdd_utils.py", line 92, in run
number_of_tests = self._get_number_of_tests()
  File "C:\Program Files (x86)\JetBrains\PyCharm 4.0.5\helpers\pycharm\_bdd_utils.py", line 206, in _get_number_of_tests
for feature in self._get_features_to_run():
  File "C:\Program Files (x86)\JetBrains\PyCharm 4.0.5\helpers\pycharm\behave_runner.py", line 209, in _get_features_to_run
self.__real_runner.run()
  File "C:\Python35\lib\site-packages\behave-1.2.5-py3.5.egg\behave\runner.py", line 672, in run
  File "C:\Python35\lib\site-packages\behave-1.2.5-py3.5.egg\behave\runner.py", line 677, in run_with_paths
  File "C:\Program Files (x86)\JetBrains\PyCharm 4.0.5\helpers\pycharm\behave_runner.py", line 92, in load_hooks
super(_RunnerWrapper, self).load_hooks(filename)
  File "C:\Python35\lib\site-packages\behave-1.2.5-py3.5.egg\behave\runner.py", line 631, in load_hooks
  File "C:\Python35\lib\site-packages\behave-1.2.5-py3.5.egg\behave\runner.py", line 303, in exec_file
  File "features\environment.py", line 11
print("Before scenario\n")
                         ^
IndentationError: unindent does not match any outer indentation level

Process finished with exit code 1

Your traceback returns: 'IndentationError: unindent does not match any outer indentation level'.

This is usually an indicator that your tab/spaces of your indentation level is incorrect.
Could you try to reformat the file tabbing to 4 spaces?

As khelwood noted, the file you should take a look at is 'features\\environment.py' around line number 11.

This usually should solve this problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM