Problem to run file. Feature in Pycharm

Asked

Viewed 379 times

2

I’m having trouble in my environment to run files .feature. I am creating a Behave + Selenium and every time I run my file .feature he makes the following mistake:

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 don’t know what to do.

1 answer

1

This error occurs only when trying to rotate the .feature passing the name of a specific scenario with the --name or -n. That’s why the re.LOCALE was deprecated from version 3.6 but not removed from the code snippet of the behave that selects the scenario by name, as reported here: https://github.com/behave/behave/issues/587

If using Python version 3.5 works, or if you prefer to fix behave lib at hand by removing the re.LOCALE, as stated 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))

for:

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.