模块设置不正确

2024-09-20 03:53:56 发布

您现在位置:Python中文网/ 问答频道 /正文

对python来说是个新手,但我觉得我把一切都安排好了。当我运行python -m unittest test.unit.test_oyez_case时,我得到AttributeError: 'module' object has no attribute 'test_oyez_case'

抱歉,这是一个常见的问题,没有一个回答对我有帮助

以下是我的文件结构:

├── README.md
└── test
    ├── __init__.py
    ├── __init__.pyc
    ├── integration
    │   └── __init__.py
    └── unit
        ├── __init__.py
        ├── __init__.pyc
        ├── mocks
        │   ├── __init__.py
        │   ├── __init__.pyc
        │   ├── responses.py
        │   └── responses.pyc
        ├── test_oyez_case.py
        └── test_oyez_case.pyc

下面是test/unit/test_oyez_case.py

import json
import unittest

import responses

from mocks import responses as api_responses
from puppy_scotus.oyez_case import OyezCase

class TestOyezCase(unittest.TestCase):
    . . .

if __name__ == '__main__':
     unittest.main()

Tags: frompytestimportinitmainunitunittest
1条回答
网友
1楼 · 发布于 2024-09-20 03:53:56

尝试使用类似python test_oyez_case.py的命令行运行它。可能是您的其他导入之一不正确。;-)

相关问题 更多 >