Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run python behave from python instead of command line

Is there any way to run python behave from within python and not via command line?

default usage: run behave command in base folder with features/steps

desired usage: call a function (or have a certain import) which executes the behave tests in a specified folder

like image 463
DreamFlasher Avatar asked Mar 03 '15 10:03

DreamFlasher


People also ask

How do you run and behave in Python?

Behave - Installation For Behave installation, we should have pip – the package installer for the Python language installed in our system. The pip is installed by default, if the Python version is greater than 2(upto 2.7. 9). We can also use the easy_install for the Behave installation.

How do you run a specific scenario in behave?

You can run a feature file by using -i or --include flags and then the name of the feature file. For more information check the documentation for command line arguments. There's a lot of useful information hidden in their appendix section. NOTE: At the time I'm writing this it won't work with Python 3.6 and Behave 1.2.

What is behave command?

Advertisements. Behave has a collection of command line arguments and it can also be outlined from the configuration files. The values set in the configuration files are used automatically, however, it can be overruled by the command line arguments.


1 Answers

Found the solution by working through the behave source code:

from behave.__main__ import main as behave_main
behave_main("path/to/specified/folder")

The main method of behave enumerates and processes all paths it finds in its arguments.

like image 70
DreamFlasher Avatar answered Nov 15 '22 16:11

DreamFlasher