Skip to content

Conversation

@Danipulok
Copy link

Summary

Hey here!
Thank you very much for the library, it is really useful and helpful

This PR fixes how pytest-examples works on Windows with sane (utf-8) default

Motivation

I'm using pytest-examples library in a small library I will release, and noticed that on Windows I get errors when try to run tests in docs with emojis
Windows has a thing where if you don't specify encoding, the default regional encoding is used, which is never utf-8

Traceback in my project, where I use pytest-examples with current code:

FAILED tests/test_docs.py::test_docs_examples[docs\\lax.md:9-22] - UnicodeEncodeError: 'charmap' codec can't encode character '\u2713' in position 237: character maps to <undefined>

Result of a test I have added in this PR with current code:

self = <encodings.cp1252.IncrementalEncoder object at 0x0000023B17AF9BB0>
input = "print('🚀 ✓')\r\n#> 🚀 ✓\r\n", final = False

    def encode(self, input, final=False):
>       return codecs.charmap_encode(input,self.errors,encoding_table)[0]
E       UnicodeEncodeError: 'charmap' codec can't encode character '\U0001f680' in position 7: character maps to <undefined>

..\..\..\..\..\Roaming\uv\python\cpython-3.14.0-windows-x86_64-none\Lib\encodings\cp1252.py:19: UnicodeEncodeError

@Danipulok
Copy link
Author

Good day, @samuelcolvin!
I know you are really busy and have a lot to do, but is there any way this PR would get merged?
I tested in on Windows with all possible ways and added a test that failed on Windows before my PR
I really like the library and IMHO this would be helpful to a lot of developers on Windows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant