pytest-cookies icon indicating copy to clipboard operation
pytest-cookies copied to clipboard

Pytest-cookies fails on Windows (YAML config erroneous)

Open pakal opened this issue 2 years ago • 2 comments

The YAML config is built by simple string formatting in https://github.com/hackebrot/pytest-cookies/blob/master/src/pytest_cookies/plugin.py

But since on Windows, filepaths use backslashes, this makes an invalid YAML file with wrong escape sequences :

while scanning a double-quoted scalar
  in "C:\Users\Pascal\AppData\Local\Temp\pytest-of-Pascal\pytest-67\user_dir0\config", line 2, column 20
expected escape sequence of 8 hexadecimal numbers, but found 's'
  in "C:\Users\Pascal\AppData\Local\Temp\pytest-of-Pascal\pytest-67\user_dir0\config", line 2, column 25

So this config should be dumped with a proper YAML parser.

For some reason, all works with old cookiecutter==1.7.2, probably the parser it uses is different

pakal avatar Jun 15 '22 14:06 pakal

Simplest solution that avoids adding dependencies is to dump the config as JSON, since YAML is a superset of JSON.

jamesmyatt avatar Jul 04 '22 16:07 jamesmyatt

I think this is an issue with poyo, which is used by cookiecutter < 2.

jamesmyatt avatar Jul 04 '22 21:07 jamesmyatt

I'm experiencing this as well when running the pyramid-cookiecutter-starter tests on windows. Is there a workaround I can use?

mmerickel avatar Dec 29 '22 23:12 mmerickel

Try my fork as described in https://github.com/hackebrot/pytest-cookies/issues/41

jamesmyatt avatar Dec 30 '22 01:12 jamesmyatt

Thanks, the fork is working for me. The failure versus the success with the patch.

mmerickel avatar Dec 30 '22 17:12 mmerickel