Запуск вести себя в Pycharm не работает, но работает в командной строке bash - PullRequest
0 голосов
/ 27 июня 2019

У меня довольно раздражающая проблема, которую я не могу объяснить (или решить :), выполняя тесты Behave под Pycharm (версия 2018.1 build # PY-181.4203.547).

Я определил конфигурацию Behave run следующим образом:

enter image description here

Ничего особенного в этом virtualenv нет, кроме, возможно, версии с поведением, которая является 1.2.6:

(sanitycheck)$ pip freeze | grep behave
behave==1.2.6

Если я запускаю тест из pycharm при запуске вышеуказанной конфигурации, я получаю сообщение об ошибке:

Testing started at 12:37 ...
/home/fermin/src/virtualenvs/sanitycheck/bin/python2.7 /data/apps/pycharm-2017.3.4/helpers/pycharm/behave_runner.py
Supplied path: "/home/fermin/src/iotp-pqa/tests/features/TS04_pepflows/026_pep2cbv2_httpsnotifications.feature"
Primary path is to a file so using its directory
Trying base directory: /home/fermin/src/iotp-pqa/tests/features/TS04_pepflows
Trying base directory: /home/fermin/src/iotp-pqa/tests/features
Trying base directory: /home/fermin/src/iotp-pqa/tests
Traceback (most recent call last):
  File "/data/apps/pycharm-2017.3.4/helpers/pycharm/behave_runner.py", line 328, in <module>
    _BehaveRunner(my_config, base_dir, use_old_runner).run()
  File "/data/apps/pycharm-2017.3.4/helpers/pycharm/_bdd_utils.py", line 102, in run
    number_of_tests = self._get_number_of_tests()
  File "/data/apps/pycharm-2017.3.4/helpers/pycharm/_bdd_utils.py", line 221, in _get_number_of_tests
    for feature in self._get_features_to_run():
  File "/data/apps/pycharm-2017.3.4/helpers/pycharm/behave_runner.py", line 236, in _get_features_to_run
    self.__real_runner.run()
  File "/home/fermin/src/virtualenvs/sanitycheck/local/lib/python2.7/site-packages/behave/runner.py", line 804, in run
    return self.run_with_paths()
  File "/home/fermin/src/virtualenvs/sanitycheck/local/lib/python2.7/site-packages/behave/runner.py", line 809, in run_with_paths
    self.load_step_definitions()
  File "/home/fermin/src/virtualenvs/sanitycheck/local/lib/python2.7/site-packages/behave/runner.py", line 796, in load_step_definitions
    load_step_modules(step_paths)
  File "/home/fermin/src/virtualenvs/sanitycheck/local/lib/python2.7/site-packages/behave/runner_util.py", line 412, in load_step_modules
    exec_file(os.path.join(path, name), step_module_globals)
  File "/home/fermin/src/virtualenvs/sanitycheck/local/lib/python2.7/site-packages/behave/runner_util.py", line 386, in exec_file
    exec(code, globals_, locals_)
  File "../../../home/fermin/src/iotp-pqa/tests/steps/cep_steps.py", line 34, in <module>
    @step(u'I create a rule on id')
  File "/home/fermin/src/virtualenvs/sanitycheck/local/lib/python2.7/site-packages/behave/step_registry.py", line 92, in wrapper
    self.add_step_definition(step_type, step_text, func)
  File "/home/fermin/src/virtualenvs/sanitycheck/local/lib/python2.7/site-packages/behave/step_registry.py", line 58, in add_step_definition
    raise AmbiguousStep(message % (new_step, existing_step))
behave.step_registry.AmbiguousStep: @step('I create a rule on id') has already been defined in
  existing step @step('I create a rule on id') at tests/steps/cep_steps.py:34

Process finished with exit code 1

То есть проблема с дублированным определением шага. Однако этот шаг не дублируется, и фактически, если я запускаю приведенный выше тест из командной строки следующим образом, он работает.

(sanitycheck)$ behave tests/features/TS04_pepflows/026_pep2cbv2_httpsnotifications.feature
...
0 features passed, 1 failed, 0 skipped
0 scenarios passed, 1 failed, 0 skipped
12 steps passed, 1 failed, 3 skipped, 0 undefined
Took 0m21.965s

(ожидается, что тест не пройден, «1 не пройден» в порядке)

Более того, если я запускаю ту же команду, что Pycharm запускает (первые строки в журнале выше: /home/fermin/src/virtualenvs/sanitycheck/bin/python2.7 /data/apps/pycharm-2017.3.4/helpers/pycharm/behave_runner.py) из командной строки bash, она работает (хотя в этом случае она выполняет весь тест, а не только нужную мне особенность .feature ).

Кто-нибудь сталкивался с такой же ситуацией? Есть идеи, почему он работает из командной строки bash, а не из-под Pycharm? Как решить эту проблему?

Спасибо!

...