解决pytest运行时报错ModuleNotFoundError

封装代码后通过pytest运行时报错模块没找到错误。

导入模块前面加上这2句话解决 No modlue name ‘模块名‘的报错。

import os,sys

sys.path.append(os.getcwd())            #告诉pytest运行前先检索当前路径

报错原因pytest运行时没有检索当前目录自己导入的模块。

报错截图:

原文地址:https://www.cnblogs.com/xiamaojjie/p/11515708.html

时间: 2024-08-05 12:01:34

解决pytest运行时报错ModuleNotFoundError的相关文章

Android 运行时报错Error running app: Instant Run requires 'Tools | Android | Enable ADB integration' to be enabled. 的解决办法

解决方法:在菜单栏,Tools->Android->Enable ADB integration勾选就可以了. Android 运行时报错Error running app: Instant Run requires 'Tools | Android | Enable ADB integration' to be enabled. 的解决办法

解决BeautifulSoup库运行时报错问题

解决BeautifulSoup库运行时报错问题 运行BeautifulSoup库时可能出现下面的错误,具体错误消息为:To get rid of this warning, change this: BeautifulSoup([your markup]) to this: BeautifulSoup([your markup], "html.parser") 2.修改方法: 根据提示,将初始化,soup=BeautifulSoup(doc)修改为soup=BeautifulSoup(

python运行时报错can't find '__main__' module in 'xxx' 的解决办法

刚开始学习python,想要使用pycharm来编辑和运行程序,所以就安装了下pycharm ,写了个简单的代码决定运行下,结果出现如下错误: 度娘找了一番,解决了问题,发现错误主要因为在这里 没有运行的成功的原因就是这里没有选择*.py 文件. 选择目标文件夹当动中的 *.py 文件. python运行时报错can't find '__main__' module in 'xxx' 的解决办法 原文地址:https://www.cnblogs.com/dcx-1993/p/10306327.h

关于在centos下安装python3.7.0以上版本时报错ModuleNotFoundError: No module named '_ctypes'的解决办法

3.7版本需要一个新的包libffi-devel,安装此包之后再次进行编译安装即可. #yum install libffi-devel -y#make install若在安装前移除了/usr/bin下python的文件链接依赖,此时yum无法正常使用,需要自己下载相关软件包安装,为节省读者时间,放上链接 #wget http://mirror.centos.org/centos/7/os/x86_64/Packages/libffi-devel-3.0.13-18.el7.x86_64.rpm

解决连接mysql时报错"Can't connect to local MySQL server through socket '/tmp/mysql.sock'"

命令行连接mysql时,报了“Can't connect to local MySQL server through socket '/tmp/mysql.sock'”的错误:用Navicat连接是报62号错误. 首先确定我本机是装了mysql的 尝试用安全模式启动mysql,命令行执行: /usr/local/bin/mysqld_safe 完了之后运行mysql,成功了. 解决连接mysql时报错"Can't connect to local MySQL server through soc

坑:pytest 运行报错unknown hook 'pytest_namespace' in plugin <module 'allure.pytest_plugin'

右键运行pytest run时报错,原因是pytest版本过高导致的.有时候会遇到在自己本机没问题,拉取服务器代码下来后就出问题了,所以把pytest版本改低就可以,亲测有效,希望对你有帮助 完整报错信息如下: plugins: allure-adaptor-1.7.10, forked-1.0.2, html-1.20.0, metadata-1.8.0, xdist-1.29.0 collected 17 items / 1 errors / 16 selected INTERNALERRO

如何解决登录OneDrive时报错Error 0x8004de40导致无法登陆?

如何解决登录OneDrive时报错Error 0x8004de40导致无法登陆? ?Lander Zhang 专注外企按需IT基础架构运维服务,IT Helpdesk 实战培训践行者博客:https://blog.51cto.com/lander IT Helpdesk 工程师实战培训课程:https://edu.51cto.com/lecturer/733218.html轻松进外企:IT Helpdesk工程师实战自学之路:https://blog.51cto.com/lander/24130

如何解决部署SFB时报错End Error Message from rewrite_2.0_rt?

如何解决部署SFB时报错End Error Message from rewrite_2.0_rtw_x64.msi? ?Lander Zhang 专注外企按需IT运维服务,IT Helpdesk 实战培训践行者博客:https://blog.51cto.com/lander IT Helpdesk 工程师实战培训课程:https://edu.51cto.com/lecturer/733218.html轻松进外企:IT Helpdesk工程师实战自学之路:https://blog.51cto.c

python 脚本运行时报错: AttributeError: 'module' object has no attribute ***

最近在编写Python脚本过程中遇到一个问题比较奇怪:Python脚本完全正常没问题,但执行总报错"AttributeError: 'module' object has no attribute 'xxx'".这其实是.pyc文件存在问题. 问题定位: 查看import库的源文件,发现源文件存在且没有错误,同时存在源文件的.pyc文件 问题解决方法: 1. 命名py脚本时,不要与python预留字,模块名等相同 2. 删除该库的.pyc文件(因为py脚本每次运行时均会生成.pyc文件