且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Python中的单元测试

更新时间:2023-12-04 08:46:28

在文章< 11 ********************** @ o13g2000cwo.googlegroups .com&gt ;,

" rhat" &LT; FA ******* @ gmail.com&GT;写道:
In article <11**********************@o13g2000cwo.googlegroups .com>,
"rhat" <fa*******@gmail.com> wrote:
大家好,我最近在读一些关于Python单元测试的文章
[1] [2],但我是有点困惑:我在哪里开始使用
这个?我试着谷歌搜索unittest但是我找到的只是已经使用它的项目的旧链接,以及较旧的(如文章所述)PyUnit项目。我很抱歉,如果这是一个明显的问题,或者已经得到解答的问题,但是单元测试听起来很有趣,而且我不知道从哪里开始。

Ryan Kaulakis
Hi Everyone,
I''ve recently been reading some articles about unit-testing in Python
[1] [2], but I am a bit confused: where do I go to get started with
this? I tried googling for "unittest" but all I''ve found are some old
links to projects that already use it, and the older (as the articles
put it) PyUnit project. I''m sorry if this is a obvious question or one
that has already been answered, but unit-testing sounds interesting and
I''m not sure where to start.

Thanks,
Ryan Kaulakis




PyUnit确实是我用的。它包含在当前的发行版中,如

" unittest"模块。


模块文档并不完美(特别是当涉及到大的

图片时),但是有一个很好的教程
http://diveintopython.org/unit_testing/index.html


一旦你了解它是如何工作的,那么

的使用真的很简单。它还有一个优势,是不同语言(Junit,C ++单位等)的一系列X-unit

包中的一个,它们都有

同一组织(针对特定语言的津贴

要求)。这意味着一旦你学会了一个,你就有了一个大脑袋

开始学习另一个。



PyUnit is indeed what I use. It''s included in current distributions as the
"unittest" module.

The module docs aren''t perfect (especially when it comes to the big
picture), but there''s a good tutorial at
http://diveintopython.org/unit_testing/index.html

Once you get your head around how it works, it''s really quite simple to
use. It also has the advantage of being one of a series of "X-unit"
packages for different languages (Junit, C++Unit, etc) which all have the
same organization (with allowances made for language-specific
requirements). This means once you''ve learned one, you''ve got a big head
start one learning another one.


整齐的原始海报显示为一个潜在的网络钓鱼者,在gmail中有一个很好的

大红色警告。


由于一些时髦的标题伪造。
>
不要给他们你的SSN。 :)


我有一个相关的问题。什么是PyDoc?我看到它出现了很多

搜索单元测试和python,但我从来没有找到

找出原因。

也许我现在就会这样做。


2005年2月10日星期四21:34:06 -0500,Roy Smith< ro*@panix.com>写道:
Neat the original poster shows up as a potential Phisher with a nice
big red warning in gmail.

Due to some funky header fakedness.

Don''t give them your SSN. :)

I have a related question. What is PyDoc? I see it come up alot in
searches for Unit testing and python, but I''ve never gotten around to
finding out why.
Maybe I''ll do that now.

On Thu, 10 Feb 2005 21:34:06 -0500, Roy Smith <ro*@panix.com> wrote:
在文章< 11 ********************** @ o13g2000cwo.googlegroups .com>,
; RHAT&QUOT; &LT; FA ******* @ gmail.com&GT;写道:
In article <11**********************@o13g2000cwo.googlegroups .com>,
"rhat" <fa*******@gmail.com> wrote:
大家好,我最近在读一些关于Python单元测试的文章
[1] [2],但我是有点困惑:我在哪里开始使用
这个?我试着谷歌搜索unittest但是我找到的只是已经使用它的项目的旧链接,以及较旧的(如文章所述)PyUnit项目。我很抱歉,如果这是一个明显的问题,或者已经得到解答的问题,但是单元测试听起来很有趣,而且我不知道从哪里开始。

Ryan Kaulakis
Hi Everyone,
I''ve recently been reading some articles about unit-testing in Python
[1] [2], but I am a bit confused: where do I go to get started with
this? I tried googling for "unittest" but all I''ve found are some old
links to projects that already use it, and the older (as the articles
put it) PyUnit project. I''m sorry if this is a obvious question or one
that has already been answered, but unit-testing sounds interesting and
I''m not sure where to start.

Thanks,
Ryan Kaulakis



PyUnit确实是我用的。它包含在当前的发行版中作为
unittest。模块。

模块文档并不完美(特别是当涉及到大图片时),但有一个很好的教程
http://diveintopython.org/unit_testing/index.html

一旦你了解它是如何工作的,它的使用真的很简单。它还具有作为一系列用于不同语言(Junit,C ++单元等)的X-unit包之一的优点,它们都具有相同的组织(具有许可)针对特定语言的要求)。这意味着一旦你学会了一个,你就会有一个大脑袋开始学习另一个。
-
http://mail.python.org/mailman/listinfo/python-list

>
-

Thomas G. Willis
http:/ / paperbackmusic.net


是的,你知道我只会询问有关测试驱动开发的问题

基础知识,希望能够获得你的个人信息,以便我可以在Molodovian blackmarket上卖掉它。我不是一个网络钓鱼者,我是一个非常懒惰的人,他懒得去挖掘他自己的答案。 ;)


感谢您的帮助Roy,我不确定

unittest和pyunit之间有什么区别。

- | 2 \ | / -\ | \ | |< / - \ | _ || _ / - \ |< 15(我的

超级秘密的超级网络钓鱼别名,这恰好是我的实际情况

名字)


PS:是的,我也很担心为什么gmail允许我注册

" fakeadmin"作为登录。当然可以开始很好的对话。

= P

Yeah, you know I only ask questions about Test-driven development
basics in hopes of obtaining your personal information, so that I can
sell it on the Molodovian blackmarket. I''m not a "Phisher", I''m a
comp-sci major who''s too lazy to dig around for his own answers. ;)

Thanks for your help Roy, I wasn''t sure what the difference between
unittest and pyunit were.
--|2 \| /-\ |\| |</-\|_||_/-\|<15 (the uber-l33t version of my
supersecret "phishing" alias which just so happens to be my actual
name)

PS: Yeah, I too am plerplexed as to why gmail allowed me to register
"fakeadmin" as a login. Sure makes a good conversation started though.
=P