timrburnham / bom_open

Python file/stdio context manager which detects encoding
https://pypi.org/project/bom-open/
The Unlicense
3 stars 1 forks source link

Real stdin testing #17

Open jayvdb opened 5 years ago

jayvdb commented 5 years ago

In addition to the mock-ish stdin testing already merged, this needs very real tests of the python runtime, to cover real scenarios like various PYTHONIOENCODING and LANG/etc settings.

Ideally https://github.com/timrburnham/bom_open/issues/15 is done first, as the stranger real situations are typically on Windows.

fwiw, I've set up a rig to do this a long time ago for https://github.com/wikimedia/pywikibot.

The approach we took was to have very simple programs which printed out inputs. Then those programs are run with popen, and the output was checked to assert it was correct for a variety of inputs. The sample programs are fairly easy to understand:

https://github.com/wikimedia/pywikibot/tree/master/tests/pwb

The tests are harder to grapple with, and are unlikely to be copy-able, but maybe will be helpful to identify scenarios that need to be tested. Some/most? are in:

https://github.com/wikimedia/pywikibot/blob/master/tests/pwb_tests.py

jayvdb commented 5 years ago

@timrburnham, iirc you said somewhere that you had started on this. IMO this can be delayed until after a release. I think we have a fairly good set of features and asserts atm - a solid foundation.