Django manage.py : Is it possible to pass command line argument (for unit testing)

前端 未结 5 2226
Happy的楠姐
Happy的楠姐 2021-02-18 13:46

Is it possible to pass command line arguments to Django\'s manage.py script, specifically for unit tests? i.e. if I do something like

manage.py test         


        
5条回答
  •  清酒与你
    2021-02-18 14:22

    i'm using environment variables workaround in my project (works in unix-like shells only)

    berry$ myvar=myval ./manage.py test 
    

    in your module read this value using

    os.environ.get('myvar')
    

提交回复
热议问题