运行imooc_case报错,Mac是就不能按照pywin32吗

来源:6-8 unittest和接口测试实战

慕后端7475696

2021-06-07

老师想问一下,运行代码报错,我百度看了一些帖子,说mac不支持pywin32,还有什么其他方法吗
import sys
import os
base_path = os.getcwd()
import unittest
sys.path.append(base_path)
import json
from untitledpython1.untitled.testcase.Base.base_request import request
host = 'http://www.imooc.com/'
class ImoocCase(unittest.TestCase):
def test_banner(self):
url = host + 'api3/getbanneradvertver2’
data = {
‘timestamp’: ‘1561269343481’,
‘uid’: ‘7213561’,
‘token’: ‘7ad09430cbaf927af642ab843ec374ef’,
‘type’: ‘1’,
‘marking’: ‘androidbanner’,
‘uuid’: ‘41b650ef846688193728ff7381eb6c1c’,
‘secrect’: ‘eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWUiOiI3MjEzNTYxIiwianRpIjoiM2I2NDg0NjQ2Nzk4NjI3NzU1YjRmZWE0ODliMDNmNmUiLCJkZXZpY2UiOiJtb2JpbGUifQ.EvGIFSHhij4lgEMdCtotFoTMtWSJLwVvridsoaWzdZY’
}
#mock_method = mock.Mock(return_value=get_value(‘api3/getbanneradvertver2’))
#request.run_main = mock_method
res = request.run_main(‘post’, url, data)
self.assertEqual(res[‘errorCode’], 1000)

if name == “main”:
unittest.main()
报错:
Testing started at 10:41 下午 …
/usr/local/bin/python3.8 /Applications/PyCharm.app/Contents/plugins/python/helpers/pycharm/_jb_pytest_runner.py --target imooc_case.py::ImoocCase.test_banner
Error processing line 7 of /Users/caihong/Library/Python/3.8/lib/python/site-packages/pywin32.pth:

Traceback (most recent call last):
File “/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site.py”, line 169, in addpackage
exec(line)
File “”, line 1, in
ModuleNotFoundError: No module named ‘pywin32_bootstrap’

Remainder of file ignored
Traceback (most recent call last):
File “/Applications/PyCharm.app/Contents/plugins/python/helpers/pycharm/_jb_pytest_runner.py”, line 4, in
import pytest
File “/Users/caihong/Library/Python/3.8/lib/python/site-packages/pytest/init.py”, line 7, in
from _pytest.assertion import register_assert_rewrite
File “/Users/caihong/Library/Python/3.8/lib/python/site-packages/_pytest/assertion/init.py”, line 10, in
from _pytest.assertion import rewrite
File “/Users/caihong/Library/Python/3.8/lib/python/site-packages/_pytest/assertion/rewrite.py”, line 36, in
from _pytest.config import Config
File “/Users/caihong/Library/Python/3.8/lib/python/site-packages/_pytest/config/init.py”, line 40, in
from .findpaths import determine_setup
File “/Users/caihong/Library/Python/3.8/lib/python/site-packages/_pytest/config/findpaths.py”, line 9, in
import iniconfig
ValueError: source code string cannot contain null bytes

Process finished with exit code 1

Empty suite

写回答

1回答

Mushishi

2021-06-09

ModuleNotFoundError: No module named ‘pywin32_bootstrap’

你看看哦  哈哈  对的 win32是windows  但是你这个pytest用不上。你是哪里干啥了

0
0

Python接口自动化测试框架实战 从设计到开发

接口自动化测试框架的设计与开发,并教你如何开发桩服务

1720 学习 · 831 问题

查看课程