尽管极度懒惰,我如何在Python中模拟IMAP服务器? [英] How do I mock an IMAP server in Python, despite extreme laziness?
问题描述
我很好奇,是否有一种简便的方法可以在Python中模拟IMAP服务器(例如imaplib
模块),而无需进行大量工作.
I'm curious to know if there is an easy way to mock an IMAP server (a la the imaplib
module) in Python, without doing a lot of work.
是否存在预先存在的解决方案?理想情况下,我可以连接到现有的IMAP服务器,进行转储,并使模拟服务器运行在真实的邮箱/电子邮件结构之外.
Is there a pre-existing solution? Ideally I could connect to the existing IMAP server, do a dump, and have the mock server run off the real mailbox/email structure.
有些背景变得懒惰:我有种讨厌的感觉,我正在编写的这个小脚本会随着时间的流逝而增长,并且会 like 创建一个适当的测试环境,但是考虑到它可能会 >不是随着时间的增长,我不想做很多工作来使模拟服务器运行.
Some background into the laziness: I have a nasty feeling that this small script I'm writing will grow over time and would like to create a proper testing environment, but given that it might not grow over time, I don't want to do much work to get the mock server running.
推荐答案
我发现上次尝试以扭曲的方式编写IMAP服务器非常容易.它带有对编写IMAP服务器的支持,您拥有极大的灵活性.
I found it quite easy to write an IMAP server in twisted last time I tried. It comes with support for writing IMAP servers and you have a huge amount of flexibility.
这篇关于尽管极度懒惰,我如何在Python中模拟IMAP服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!