[英]How to run django tests in a pre-commit hook
I'm stuck on how to simply run my django tests in a pre-commit hook.我被困在如何在预提交钩子中简单地运行我的 django 测试。 I will eventually put them in the push stage, but I'm just trying to get them to run first.我最终会将它们置于推送阶段,但我只是想让它们先运行。 It's trying to loop over my tests, but the tests object is a NoneType object.它试图循环我的测试,但测试对象是一个 NoneType 对象。 Works fine outside of this hook.在这个钩子之外工作正常。 I'm sure this is obvious to someone.我相信这对某人来说是显而易见的。 Thanks.谢谢。
This is my test hook.这是我的测试钩子。
repo: local
hooks:
- id: tests
name: run tests
always_run: true
entry: python manage.py test
language: system
types: [python]
Edit: I have since realised it's not a good idea to run backend tests on commits or pushes.编辑:从那以后,我意识到对提交或推送运行后端测试不是一个好主意。 Should only be running hooks to clean up code on git hooks.应该只运行钩子来清理 git 钩子上的代码。
I had the same issue now but it works fine with this:我现在遇到了同样的问题,但它可以正常工作:
repos:
- repo: local
hooks:
- id: django-test
name: django-test
entry: python manage.py test
always_run: true
pass_filenames: false
language: system
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.