简体   繁体   English

当我尝试通过cmd运行python测试脚本时出现未找到模块错误

[英]Getting module not found error when i try to run my python test scripts through cmd

when i run my code with pycharm my code is getting executed but same thing if i try to do with the help of cmd i am getting the below error . 当我使用pycharm运行我的代码时,我的代码正在执行,但是如果我尝试在cmd的帮助下执行相同的操作,则会收到以下错误。 I am not sure why i am getting this error can any one please help me out . 我不确定为什么会收到此错误,任何人都可以帮助我。 The python version which i am using is 3.6.4 我正在使用的python版本是3.6.4

from unittest import TestLoader, TestSuite, TextTestRunner
from Test.TestSuite import HTMLTestRunner
from Test.Scripts.login_page import LoginPage
from Test.Scripts.register_page import Register
from Test.Scripts.category_page import CategoryPage
from Test.Scripts.Footer_page import Footer
from Test.Scripts.hamburger_page import HamburgerPage
from Test.Scripts.header_page import Header
from Test.Scripts.message_page import MessagePage
from Test.Scripts.new_topic_page import NewTopicPage
from Test.Scripts.profile_preference_page import ProfilePreferencePage
from Test.Scripts.search_page import SearchPage
from Test.Scripts.topic_page import TopicPage
from Test.Scripts.user_profile_links_page import UserProfilePage


if __name__ == "__main__":

 loader = TestLoader()

 suite = TestSuite((

    loader.loadTestsFromTestCase(LoginPage),
    loader.loadTestsFromTestCase(Register),
    loader.loadTestsFromTestCase(CategoryPage),
    loader.loadTestsFromTestCase(Footer),
    loader.loadTestsFromTestCase(HamburgerPage),
    loader.loadTestsFromTestCase(Header),
    loader.loadTestsFromTestCase(MessagePage),
    loader.loadTestsFromTestCase(NewTopicPage),
    loader.loadTestsFromTestCase(ProfilePreferencePage),
    loader.loadTestsFromTestCase(SearchPage),
    loader.loadTestsFromTestCase(TopicPage),
    loader.loadTestsFromTestCase(UserProfilePage)

    ))
#run test sequentially using simple TextTestRunner
runner = TextTestRunner(verbosity=1)
#runner.run(suite)

# open the report file
outfile = open("forum_page_test_results.html", "w")

# configure HTMLTestRunner options
runner = HTMLTestRunner.HTMLTestRunner(stream=outfile, title='Test report', description='Acceptance Tests')

# run the suite using HTMLTestRunner
runner.run(suite)

error : File "TestRunner.py", line 2, in from Test.TestSuite import HTMLTestRunner ModuleNotFoundError: No module named 'Test' 错误:来自Test.TestSuite导入HTMLTestRunner ModuleNotFoundError的文件“ TestRunner.py”,第2行,错误:没有名为“ Test”的模块

If the module that you are developing is named Test, you might need to add the directory containing this module to sys.path: 如果要开发的模块名为Test,则可能需要将包含该模块的目录添加到sys.path:

import sys
sys.path.append('/path/to/mod_directory')

See: adding directory to sys.path /PYTHONPATH 请参阅: 将目录添加到sys.path / PYTHONPATH

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Python-每当我尝试运行程序“找不到模块”时都会出错 - Python - Getting error whenever I try to run program “Module cannot be found” 当我尝试通过 python 脚本执行 shell 命令时出现错误“找不到模块” - I'm getting an error “module not found ” when I'm trying to execute shell commands through a python script 当我尝试在任何编辑器或cmd上运行Python脚本时,出现此错误 - When I try to run Python script on any editor or cmd I get this error 尝试通过解释器运行Python脚本时,为什么会出现“ ImportError:未命名模块”的提示? - Why do I get “ImportError: No module named” when I try to run my Python script via the Interpreter? 当我尝试运行我的 discord 机器人时,它告诉我一个模块错误 - when i try to run my discord bot it tells gives me a module error 当我在pycharm中运行我的代码时,它工作正常,但是当我尝试从服务器中运行相同的代码时,我得到了错误 - when i run my code in pycharm it is working fine but when i try to run the same code from server i am getting error 我尝试在Windows cmd上安装Flask,并且在安装MarkupSafe模块时收到UnicodeDecodeError - i try to install flask on my windows cmd and i got UnicodeDecodeError when installing MarkupSafe module 当我手动删除 Django 中的文件夹或文件并尝试运行项目时,我在已删除的同一模块上遇到错误? - When I delete a folder or a file in Django manually and try to run the project I'm getting error on the same module which I have deleted? python在通过CMD运行时表现不同 - python behaves differently when run through CMD 有没有办法通过windows cmd运行python脚本并在cmd中显示python操作和绘图 - is there any way to run python scripts through windows cmd and show python operation and plots in cmd
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM