ryneeverett / mkcodes

A command-line utility for pulling code blocks out of markdown files.
Apache License 2.0
15 stars 7 forks source link

simplify file write and make_directories #11

Closed ryneeverett closed 4 years ago

ryneeverett commented 4 years ago

@mattkatz, As appealing as this simplification is, I'm not sure it will work if we want to be able to support outputting a testable directory, because my understanding is that __init__.py's are still required for discovery of test packages. You can see this demonstrated in the test I propose in #10, which fails with this change.

mattkatz commented 4 years ago

Argh, very good point. Sadly https://bugs.python.org/issue23882 has comments on it from very recently as does https://bugs.python.org/issue35617

These are very specific to test discovery in the base unittest library. Other test libraries have caught up a bit. For example, if we do this:

mkcodes  --output tests/output/test_{name}.py --github tests/data
echo("pytest wants unique filenames for modules")
mv tests/output/nest/less/test_why.py tests/output/nest/less/test_test.py
pytest tests/output

We get

========================= test session starts =========================
platform darwin -- Python 3.6.5, pytest-6.0.1, py-1.9.0, pluggy-0.12.0

collected 2 items

tests/output/nest/less/test_test.py .                           [ 50%]
tests/output/nest/more/test_why.py .                            [100%]

========================== 2 passed in 0.06s ==========================

I hate to complicate mkcodes - maybe I can just touch init.py for each directory in the path.

mattkatz commented 4 years ago

see PR #12