behave test runner will not start from PyCharm
When running the behave test from PyCharm, I get the following error message:
Testing started at 09.30 ...
/***/project/venv/bin/python "/***/user/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-P/ch-0/173.4301.16/PyCharm.app/Contents/helpers/pycharm/behave_runner.py"
Traceback (most recent call last):
File "/***/user/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-P/ch-0/173.4301.16/PyCharm.app/Contents/helpers/pycharm/behave_runner.py", line 285, in <module>
my_config = configuration.Configuration(command_args=command_args)
File "/***/project/venv/lib/python3.6/site-packages/behave/configuration.py", line 601, in __init__
self.name_re = self.build_name_re(self.name)
File "/***/project/venv/lib/python3.6/site-packages/behave/configuration.py", line 665, in build_name_re
return re.compile(pattern, flags=(re.UNICODE | re.LOCALE))
File "/***/project/venv/lib/python3.6/re.py", line 233, in compile
return _compile(pattern, flags)
File "/***/project/venv/lib/python3.6/re.py", line 301, in _compile
p = sre_compile.compile(pattern, flags)
File "/***/project/venv/lib/python3.6/sre_compile.py", line 562, in compile
p = sre_parse.parse(p, flags)
File "/***/project/venv/lib/python3.6/sre_parse.py", line 866, in parse
p.pattern.flags = fix_flags(str, p.pattern.flags)
File "/***/project/venv/lib/python3.6/sre_parse.py", line 833, in fix_flags
raise ValueError("cannot use LOCALE flag with a str pattern")
ValueError: cannot use LOCALE flag with a str pattern
Process finished with exit code 1
However, when I run behave from the command prompt, it works.
This happens under PyCharm 2017.3.3 (Professional Edition)
Build #PY-173.4301.16, built on January 11, 2018
Licensed to Bouvet Norge AS / Sindre Nistad
Subscription is active until November 1, 2018
JRE: 1.8.0_152-release-1024-b11 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.12.6
and Python 3.6.1
Please sign in to leave a comment.
Anand Desai did you configure it as covered here:
https://www.jetbrains.com/help/pycharm/running-behave-django.html
?
Also, check Django is configured in "File | Settings | Languages & Frameworks | Django".
By the way, 2.0 is unsupported. Better to update it to 2.2
I get the same issue . I upgraded from community to pro only so as not to have to run a large test suite and now find I cannot run them . It must be in the config as the error does not mention my code . But for the life of me I cant find what I have wrong
It seem to have been a problem with behave 1.2.5 and python 3.6.x. It has been documented on stack overflow (though I don't remember where exactly (sorry)).
Anyhow, I managed to get around the problem by using behave 1.2.6-dev0 instead (essentially the latest from behave's master branch). I hope that might solve your problem as well.
Hello.
There was an error with 1.2.6dev0 but it is already fixed in latest master: https://youtrack.jetbrains.com/issue/PY-22104
Which version do you use?
I am using 1.2.5 installed via pipenv .
Works for me also . This will save me hours over a week . Thanks a lot.
I am using Python 3.7.5 with Pycharm 19.3 and Django 2.0.10. I have getting an error while running Behave tests : django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
I had this tests working and then something went wrong. I have been trying to debug it for last 2 days but no luck. I have behave 1.2.6 installed in my Virtual Environment. Anyone can help?
Based on my 48 hours investigations on this topic, it seems that issue is with PyCharm somehow corrupting metadata. So i could eliminate the error by getting latest from source control. However, I have managed to figure out how to corrupt metadata.
This issue can be reproduced as following:
1. Get latest from Source Control. Choose your virtual environment (in my case it is Python 3.6)
2. Run your django project. In my case it is running on port 8000
3. Right click on feature file and run it in debug mode. This time it works fine
4. Go to command line & try to run behave using following command : python3 manage.py behave
5. When I do this, it fails with following error "RuntimeError: setup_test_environment() was already called and can't be called again without first calling teardown test environment()."
6. Now if I try to right click on feature file and invoke behave_runner using Pycharm, it keeps failing and gives me the same error as above. My matadata is corrupted and I can only fix it by re-initializing my project in PyCharm.
I am hoping that someone from Pycharm will read my comments and provide support for BDD. It is important to be able to run this at command line as I am keen to integrate BDD with Jenkins and I am concerned that I won't be able to debug or test it in my local environment before putting it on build server.