Python Unitest模块与打字不兼容?
与设置一个简单的测试套件并存,我有src/main.py和src/tests.py。我遇到了这个错误。
File "main.py", line 26
def error(msg: str) -> int:
^
SyntaxError: invalid syntax
我的代码
from main import error
from typing import *
import unittest
class TestMainFunctions(unittest.TestCase):
def test_error():
result = error("e")
self.assertEqual(result, 0)
unittest.main()
有什么方法可以解决此问题吗?运行main.py时,error()函数正常工作。 Untiment模块是否与键入不兼容?如果是这样,我该如何解决?
Tying to set up a simple test suite, I have src/main.py and src/tests.py. I am getting this error.
File "main.py", line 26
def error(msg: str) -> int:
^
SyntaxError: invalid syntax
My code is
from main import error
from typing import *
import unittest
class TestMainFunctions(unittest.TestCase):
def test_error():
result = error("e")
self.assertEqual(result, 0)
unittest.main()
Is there any way to fix this? The error() function works fine when running main.py. Is the unittest module just not compatible with typing? If so, how do I get around this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论