无法从提示符运行Python / Behave测试

时间:2018-02-09 20:02:15

标签: python python-behave

尝试从Windows提示符运行行为.feature测试时,我遇到导入错误:

C:\MyProject\Features> behave
    Exception ImportError: No module named Pages.SamplePage
    Traceback (most recent call last):
      File "C:/Python27/Lib/site-packages/behave/__main__.py", line 162, in <module>
        sys.exit(main())
      File "C:/Python27/Lib/site-packages/behave/__main__.py", line 109, in main
        failed = runner.run()
      File "C:\Python27\lib\site-packages\behave\runner.py", line 672, in run
        return self.run_with_paths()
      File "C:\Python27\lib\site-packages\behave\runner.py", line 678, in run_with_paths
        self.load_step_definitions()
      File "C:\Python27\lib\site-packages\behave\runner.py", line 658, in load_step_definitions
        exec_file(os.path.join(path, name), step_module_globals)
      File "C:\Python27\lib\site-packages\behave\runner.py", line 304, in exec_file
        exec(code, globals, locals)
      File "steps\SampleSteps.py", line 5, in <module>
        from Pages.SamplePage import SamplePage
    ImportError: No module named Pages.SamplePage

相同的测试从​​PyCharm / Run / Debug完美运行。但我想从提示符运行我的测试,以便将来从Jenkins执行我的套件......

我已经尝试将我的项目路径包含在Windows路径中,但它没有用。

这是我的项目结构:

- MyProject
  - Features
    - __init__.py
    - Environment.py
    - Sample
      - __init__.py
      - sample.feature
    - Steps
      - __init__.py
      - SampleSteps.py
  - Pages
    - __init__.py
    - SamplePage.py

0 个答案:

没有答案