简体   繁体   English

尝试运行的Python行为得到错误

[英]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. 我已经设置了python,selenium并按照应有的方式运行。 I'm running python scripts with selenium without an problem. 我用硒运行python脚本没有问题。 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. 我的python是3.5.2,硒是2.53.2,行为是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. 无论是尝试使用PyCharm IDE还是直接在命令提示符下运行它,都没有关系。 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 流程以退出代码1完成

Your traceback returns: 'IndentationError: unindent does not match any outer indentation level'. 您的回溯将返回:'IndentationError:unindent与任何外部缩进级别都不匹配'。

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? 您可以尝试将制表符重新格式化为4个空格吗?

As khelwood noted, the file you should take a look at is 'features\\environment.py' around line number 11. 正如khelwood指出的那样,您应该查看的文件是第11行附近的“ features \\ environment.py”。

This usually should solve this problem. 这通常应该解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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