Problem to execute .feature file in PyCharm

1

I'm having trouble in my environment to run .feature files. I'm creating a Behave + Selenium and every time I run my file .feature it gives the following error:

C:\Python\Python36-32\python.exe "C:\Program Files\JetBrains\PyCharm 2017.2.1\helpers\pycharm\behave_runner.py"
Testing started at 2:12 PM ...
Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm 2017.2.1\helpers\pycharm\behave_runner.py", line 281, in <module>
    my_config = configuration.Configuration(command_args=command_args)
  File "C:\Python\Python36-32\lib\site-packages\behave\configuration.py", line 601, in __init__
    self.name_re = self.build_name_re(self.name)
  File "C:\Python\Python36-32\lib\site-packages\behave\configuration.py", line 665, in build_name_re
    return re.compile(pattern, flags=(re.UNICODE | re.LOCALE))
  File "C:\Python\Python36-32\lib\re.py", line 233, in compile
    return _compile(pattern, flags)
  File "C:\Python\Python36-32\lib\re.py", line 301, in _compile
    p = sre_compile.compile(pattern, flags)
  File "C:\Python\Python36-32\lib\sre_compile.py", line 562, in compile
    p = sre_parse.parse(p, flags)
  File "C:\Python\Python36-32\lib\sre_parse.py", line 865, in parse
    p.pattern.flags = fix_flags(str, p.pattern.flags)
  File "C:\Python\Python36-32\lib\sre_parse.py", line 832, in fix_flags
    raise ValueError("cannot use LOCALE flag with a str pattern")
ValueError: cannot use LOCALE flag with a str pattern

But I am able to run .py files normally. I know the error is environment, but I do not know what to do.

    
asked by anonymous 04.09.2017 / 23:16

1 answer

0

This error occurs only when trying to run .feature by passing the name of a specific scenario with --name or -n . This is because re.LOCALE has been deprecated since version 3.6 but has not been removed from the behave code snippet that selects the scenario by name, as can be seen reported here: link

If using Python version 3.5 works, or if you prefer to fix the behave lib by hand by removing re.LOCALE , as indicated in that bug fix , edit the file C:\Program Files (x86)\Python36-32\Lib\site-packages\behave\configuration.py

Change the line:

return re.compile(pattern, flags=(re.UNICODE | re.LOCALE))

by:

return re.compile(pattern, flags=re.UNICODE)
    
26.09.2017 / 15:47