python 单元测试 unittest

django 项目

/usr/bin/env bash -c "arch -x86_64 /Users/jimogangdan/PycharmProjects/data-exchange-platform/venv/bin/python -m unittest  -v app_scheduler_job/test.py

报错 ModuleNotFoundError: No module named 'data_exchange_platform'

应当前的目录不是工作目录

import sys
import os
import django

sys.path.insert(0, r"/Users/jimogangdan/PycharmProjects/data-exchange-platform")
os.environ['DJANGO_SETTINGS_MODULE'] = 'data_exchange_platform.settings'
django.setup()
from app_scheduler_job import day_every

if __name__ == '__main__':
   print(os.getcwd())

   day_every.execute_transformation()

posted @ 2023-05-19 16:28  vx_guanchaoguo0  阅读(8)  评论(0编辑  收藏  举报