watchdog
tricks to automatically run tests.¶watchdog
contains a command line tools to define watch events using a yaml file.
Use pytest
to demonstrate the technique.
!watchmedo tricks tricks.yml
commands = """pytest"""
Ignore some of the by products of the notebook.
print(commands)
tricks = """tricks:
- watchdog.tricks.ShellCommandTrick:
patterns:
- "*/*.ipynb"
ignore_patterns:
- '*/.~*.ipynb'
- '*/.ipynb_checkpoints*'
shell_command: >
{}
""".format(commands)
Write the tricks file to disk if it doesn't exist.
if __name__ == '__main__':
from IPython import get_ipython
path = __import__('pathlib').Path('tricks.yml')
if not path.exists(): path.write_text(tricks)