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
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With