bskinn / stdio-mgr

Context manager for mocking/wrapping stdin/stdout/stderr
MIT License
14 stars 4 forks source link

Assertion helpers for `.getvalue()` #87

Open jayvdb opened 5 years ago

jayvdb commented 5 years ago

Like https://github.com/bskinn/stdio-mgr/issues/80 (Windows EOL vs Unix EOL) , the reason .getvalue exists is to be used in assertions. And https://github.com/bskinn/stdio-mgr/issues/80 exists because it is usually important for the precision of assertions to check most of the value, but allow some implementation/temporal/etc details to be ignored.

We could leave this to an external assertion library, however there are likely some other 'easy wins', similar to EOLs, where an internal helper can provide a common need, and can be easily achieved with the stdlib, or the helpers solve our own needs.

The one that comes to mind is a regex match, or some large text match, which could be used with https://github.com/bskinn/stdio-mgr/issues/11 to say "dump to the real streams if it doesnt match /this pattern/.

For implementation, this should be done after https://github.com/bskinn/stdio-mgr/issues/86 , so we have an abstract class to hang the helpers onto.

bskinn commented 5 years ago

This is probably application-specific enough that pushing it up to stdlib won't make sense...and we'll probably want our own custom methods on it anyways.

The one that comes to mind is a regex match, or some large text match, which could be used with #11 to say "dump to the real streams if it doesnt match /this pattern/.

This makes sense--only reproduce/push content out to the 'real' (e.g., prior to stdio-mgr) streams if it doesn't match what I expect.