[issue11468] Improve unittest basic example in the doc

2015-03-24 Thread Ezio Melotti

Ezio Melotti added the comment:

I tweaked the wording a bit, added a link to the section about setUp/tearDown, 
and applied it on all the 3 branches.
Thanks for the patch Florian!

--
resolution:  - fixed
stage: patch review - resolved
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11468
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11468] Improve unittest basic example in the doc

2015-03-24 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 4a2a5fddbab3 by Ezio Melotti in branch '2.7':
#11468: improve unittest basic example.  Initial patch by Florian Preinstorfer.
https://hg.python.org/cpython/rev/4a2a5fddbab3

New changeset 010e33b37feb by Ezio Melotti in branch '3.4':
#11468: improve unittest basic example.  Initial patch by Florian Preinstorfer.
https://hg.python.org/cpython/rev/010e33b37feb

New changeset d6791e4026f1 by Ezio Melotti in branch 'default':
#11468: merge with 3.4.
https://hg.python.org/cpython/rev/d6791e4026f1

--
nosy: +python-dev

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11468
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11468] Improve unittest basic example in the doc

2015-03-19 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Yes, go ahead an apply this patch.

--
assignee: rhettinger - ezio.melotti

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11468
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11468] Improve unittest basic example in the doc

2015-03-18 Thread Ezio Melotti

Ezio Melotti added the comment:

Raymond, in the meanwhile can the proposed patch be applied?
I don't think it's necessary to show that you need to import a module in order 
to test its functions.  Using modules also has the disadvantage that people 
might not know what result to expect if they are not familiar with the 
functions of that module (e.g. the only functions that return True/False in the 
math module seem to be isfinite/isnan/isinf), whereas everyone should know 
basic string methods.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11468
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11468] Improve unittest basic example in the doc

2014-05-27 Thread Berker Peksag

Changes by Berker Peksag berker.pek...@gmail.com:


--
versions: +Python 3.5 -Python 3.3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11468
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11468] Improve unittest basic example in the doc

2014-05-27 Thread Zachary Ware

Changes by Zachary Ware zachary.w...@gmail.com:


--
nosy: +zach.ware

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11468
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11468] Improve unittest basic example in the doc

2014-05-27 Thread Raymond Hettinger

Raymond Hettinger added the comment:

FWIW, I'm going to test some other module (math or somesuch) rather than the 
built-in string methods.  The normal use of unittest is to import both the 
unittest module and the module under test.  I want to show that pattern (which 
is somewhat different from doctests where the tests are typically in the same 
file as the code being tested).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11468
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11468] Improve unittest basic example in the doc

2013-05-28 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


--
nosy:  -serhiy.storchaka
stage: commit review - patch review
versions: +Python 3.4 -Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11468
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11468] Improve unittest basic example in the doc

2012-12-24 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I think `self.assertRaises(TypeError, s.split, 2)` looks simpler. In any case 
two examples for assertRaises needed, simple inlined and more complicated use 
as context manager.

--
nosy: +serhiy.storchaka

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11468
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11468] Improve unittest basic example in the doc

2012-12-24 Thread Ezio Melotti

Ezio Melotti added the comment:

Given that this is a basic example, it's not necessary to introduce both the 
forms of assertRaises.
I personally find the context manager form more readable, and I prefer it to 
the regular one even if it takes two lines instead of one.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11468
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11468] Improve unittest basic example in the doc

2012-10-26 Thread Berker Peksag

Changes by Berker Peksag berker.pek...@gmail.com:


--
nosy:  -berker.peksag

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11468
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11468] Improve unittest basic example in the doc

2011-12-12 Thread Berker Peksag

Changes by Berker Peksag berker.pek...@gmail.com:


--
nosy: +berkerpeksag

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11468
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11468] Improve unittest basic example in the doc

2011-12-12 Thread Raymond Hettinger

Raymond Hettinger raymond.hettin...@gmail.com added the comment:

I'll be updating this example shortly, but it is intentional that it include 
only assertEqual, assertTrue, and assertRaises.  Those three are the minimum 
necessary to get up and running (which is the whole point of the BASIC example).

--
assignee: docs@python - rhettinger

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11468
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11468] Improve unittest basic example in the doc

2011-12-12 Thread Ezio Melotti

Ezio Melotti ezio.melo...@gmail.com added the comment:

The patch includes only assertEqual, assertTrue, and assertRaises and, except a 
s/functions/methods/ in the first line, looks good to me.

--
stage: needs patch - commit review
versions:  -Python 3.1

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11468
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11468] Improve unittest basic example in the doc

2011-12-12 Thread Raymond Hettinger

Raymond Hettinger raymond.hettin...@gmail.com added the comment:

Ezio, please leave this one for me.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11468
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11468] Improve unittest basic example in the doc

2011-07-18 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

I think there’s value in accepting the current patch as really basic example, 
and then see if the section about setting up and tearing down also has a very 
simple example.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11468
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11468] Improve unittest basic example in the doc

2011-07-17 Thread Senthil Kumaran

Senthil Kumaran sent...@uthcode.com added the comment:

I would be +1 if the basic example also highlights setUp and tearDown methods. 
Those are useful ones for a new comer to know via an example snippet and not 
just with explanation.

--
nosy: +orsenthil

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11468
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11468] Improve unittest basic example in the doc

2011-07-05 Thread Florian Preinstorfer

Florian Preinstorfer nbl...@archlinux.us added the comment:

I tried to implement the improvements suggested by Ezio Melotti and updated the 
documentation accordingly.

--
keywords: +patch
nosy: +notizblock
Added file: http://bugs.python.org/file22576/issue-11468.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11468
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11468] Improve unittest basic example in the doc

2011-03-12 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

LGTM.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11468
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11468] Improve unittest basic example in the doc

2011-03-11 Thread Ezio Melotti

New submission from Ezio Melotti ezio.melo...@gmail.com:

The current example[0] uses assertTrue(element in self.seq) but it would be 
better to use assertIn instead.  The whole example could be changed to 
something simpler that uses only the assertTrue/assertEqual/assertRaises 
methods correctly, e.g.:

import unittest

class TestStringMethods(unittest.TestCase):

def test_upper(self):
self.assertEqual('foo'.upper(), 'FOO')

def test_isupper(self):
self.assertTrue('FOO'.isupper())
self.assertFalse('Foo'.isupper())

def test_split(self):
s = 'hello world'
self.assertEqual(s.split(), ['hello', 'world'])
# check that s.split fails when the separator is not a string
with self.assertRaises(TypeError):
s.split(2)

if __name__ == '__main__':
unittest.main()

[0]: http://docs.python.org/py3k/library/unittest.html#basic-example

--
assignee: docs@python
components: Documentation
keywords: easy
messages: 130598
nosy: docs@python, eric.araujo, ezio.melotti, michael.foord, ncoghlan, 
rhettinger
priority: low
severity: normal
stage: needs patch
status: open
title: Improve unittest basic example in the doc
type: feature request
versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11468
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com