dev_appserver.py starts a local deployement of my appengine service. I want to run my tests on behave on this local service. I want to start the server within my tests first. How to run the dev_appsrrver.py app.yaml command in my behave feature file in the start ?
I have tried subprocess.run("python","dev_appserver.py") but it says couldnt find the file dev_appserver.py. I'm trying on windows.
When you're attempting to launch executables using subprocess
methods typically you're not getting by default the same environment (execution path and current working directory) you're getting yourself in a shell/terminal. Which means you may need to reference files (both executables and regular files) using full paths in the list of arguments you pass to those methods.
Since the subprocess.run()
execution complaints about the dev_appserver.py
location it means it's finding python OK (you may still want to check that's it's the 2.7 version) and you need to provide the full path for dev_appserver.py
, which depends on your OS and the SDK you use. On Linux, for example (sorry, I'm not a windows guy), the path is:
<GAE_SDK_dir>/dev_appserver.py
if using the GAE SDK<gcloud_SDK_dir>/bin/dev_appserver.py
if using the gcloud SDKYou'll most likely need to pass the path to your GAE app's app.yaml
file, too - as an argument to dev_appserver.py
, otherwise you'll see it complain about inability to locate the app or its files (or just having things run badly - if the app.yaml
file isn't specified dev_appserver.py
attempt to auto-detect it and that doesn't work in all cases). I'd avoid complications and just specify the app.yaml
file(s).
Also note that the subprocess.run()
args should be a list. Something like this:
subprocess.run(['python', '<sdk_path_to>/dev_appserver.py', '<app_path_to>/app.yaml'])
See also appcfg.py not working in command line - the post is about a different executable, but the answers are equally applicable to dev_appserver.py
.