Python BDD framework Behave has the following code in its runner.py
with open(filename) as f:
# -- FIX issue #80: exec(f.read(), globals, locals)
# try:
filename2 = os.path.relpath(filename, os.getcwd())
code = compile(f.read(), filename2, 'exec')
As you can see, no charset is provided to open
. According to its documentation, locale.getpreferredencoding
is used for such cases.
But on Windows this function always return one-byte charset (so called "charset for non-unicode programs"). It is Windows-1252 for latin, Windows-1251 for Cyrillic etc.
So,UTF-8 py file is always broken.
My question is how can I use non-ascii step definitions with Behave on Windows if want to stay out of 1-byte charset?