[issue19950] Document that unittest.TestCase.__init__ is called once per test

2018-05-18 Thread Gregory P. Smith

Change by Gregory P. Smith :


--
resolution:  -> fixed
stage: patch review -> commit review
status: open -> closed

___
Python tracker 

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



[issue19950] Document that unittest.TestCase.__init__ is called once per test

2018-05-18 Thread Gregory P. Smith

Gregory P. Smith  added the comment:


New changeset 436972e295f5057fe7cdd7312f543c2fa884705d by Gregory P. Smith 
(Miss Islington (bot)) in branch '3.7':
bpo-19950: Clarify unittest TestCase instance use. (GH-6875) (GH-6938)
https://github.com/python/cpython/commit/436972e295f5057fe7cdd7312f543c2fa884705d


--

___
Python tracker 

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



[issue19950] Document that unittest.TestCase.__init__ is called once per test

2018-05-18 Thread Gregory P. Smith

Gregory P. Smith  added the comment:


New changeset a5f33a899f6450de96f5e4cd154de4486d50bdd7 by Gregory P. Smith 
(Miss Islington (bot)) in branch '3.6':
bpo-19950: Clarify unittest TestCase instance use. (GH-6875) (GH-6939)
https://github.com/python/cpython/commit/a5f33a899f6450de96f5e4cd154de4486d50bdd7


--

___
Python tracker 

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



[issue19950] Document that unittest.TestCase.__init__ is called once per test

2018-05-17 Thread miss-islington

Change by miss-islington :


--
pull_requests: +6608

___
Python tracker 

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



[issue19950] Document that unittest.TestCase.__init__ is called once per test

2018-05-17 Thread Gregory P. Smith

Gregory P. Smith  added the comment:


New changeset dff46758f267ad6c13096c69c4e1dee17f9969aa by Gregory P. Smith in 
branch 'master':
bpo-19950: Clarify unittest TestCase instance use. (GH-6875)
https://github.com/python/cpython/commit/dff46758f267ad6c13096c69c4e1dee17f9969aa


--
nosy: +gregory.p.smith

___
Python tracker 

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



[issue19950] Document that unittest.TestCase.__init__ is called once per test

2018-05-17 Thread miss-islington

Change by miss-islington :


--
pull_requests: +6609

___
Python tracker 

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



[issue19950] Document that unittest.TestCase.__init__ is called once per test

2018-05-15 Thread Gregory P. Smith

Change by Gregory P. Smith :


--
keywords: +patch
pull_requests: +6548
stage: needs patch -> patch review

___
Python tracker 

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



[issue19950] Document that unittest.TestCase.__init__ is called once per test

2018-04-25 Thread Cheryl Sabella

Change by Cheryl Sabella :


--
keywords: +easy -patch
stage:  -> needs patch
versions: +Python 3.7, Python 3.8 -Python 3.4

___
Python tracker 

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



[issue19950] Document that unittest.TestCase.__init__ is called once per test

2014-04-27 Thread Claudiu.Popa

Claudiu.Popa added the comment:

In Python 3 docs there is a hint in the documentation for `loadTestsFromModule`:

This method searches module for classes derived from TestCase and creates an 
instance of the class for each test method defined for the class.

The phrase with a fixture per test from Python 2 docs is gone though. It would 
be nice if the same explanation from loadTestsFromModule could be applied to 
TestCase documentation.

--

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



[issue19950] Document that unittest.TestCase.__init__ is called once per test

2014-02-15 Thread Ezio Melotti

Changes by Ezio Melotti ezio.melo...@gmail.com:


--
nosy: +ezio.melotti

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



[issue19950] Document that unittest.TestCase.__init__ is called once per test

2013-12-11 Thread Claudiu.Popa

Claudiu.Popa added the comment:

How about the following:

Each instance of the TestCase will only be used to run a single test method 
from it, so a new instance is created for each test method.


It replaces `fixture` with `instance` and it emphasizes that the called method 
belongs to that particular TestCase instance.

--

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



[issue19950] Document that unittest.TestCase.__init__ is called once per test

2013-12-10 Thread Claudiu.Popa

New submission from Claudiu.Popa:

I was surprised that in the following __init__ is actually called once per test 
function, although nothing in documentation implied so.

a.py
--

import unittest

class A(unittest.TestCase):
   def __init__(self, *args, **kwargs):
   print('called only once!')
   super().__init__(*args, **kwargs)

   def test(self):
   self.assertEqual(1, 1)
 
   def test2(self):
   self.assertEqual(2, 2)

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

$ python a.py
called only once!
called only once!
..
--
Ran 2 tests in 0.001s

OK



The attached patch adds a note regarding this behaviour for the TestCase class.

--
assignee: docs@python
components: Documentation
files: unittest_init.patch
keywords: patch
messages: 205864
nosy: Claudiu.Popa, docs@python, michael.foord
priority: normal
severity: normal
status: open
title: Document that unittest.TestCase.__init__ is called once per test
type: enhancement
versions: Python 3.4
Added file: http://bugs.python.org/file33086/unittest_init.patch

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



[issue19950] Document that unittest.TestCase.__init__ is called once per test

2013-12-10 Thread R. David Murray

R. David Murray added the comment:

I'm guessing it is that a new TestCase instance is instantiated each time an 
individual test is run.  I don't know that this is part of the API, though, so 
I'm not sure how it should be documented.

--
nosy: +r.david.murray

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



[issue19950] Document that unittest.TestCase.__init__ is called once per test

2013-12-10 Thread Ned Batchelder

Ned Batchelder added the comment:

This sentence seems to cover it: Each instance of the TestCase will only be 
used to run a single test method, so a new fixture is created for each test.  
from http://docs.python.org/2/library/unittest.html

The word fixture here is being used oddly, but that's the sentence.

--
nosy: +nedbat

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



[issue19950] Document that unittest.TestCase.__init__ is called once per test

2013-12-10 Thread Claudiu.Popa

Claudiu.Popa added the comment:

Each instance of the TestCase will only be used to run a single test method, 
so a new fixture is created for each test.

Yes, this seems to be, but it is not clear what fixture means in this context 
(as in the preparation needed to perform one or *more* tests?). Perhaps 
enhancing the message a little will suffice.

--

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



[issue19950] Document that unittest.TestCase.__init__ is called once per test

2013-12-10 Thread Michael Foord

Michael Foord added the comment:

I'd be happy with a doc change from fixture to instance (or maybe add 
instance in parentheses). I'd rather a simple change than making the 
documentation much longer.

The reason for a separate instance per test is for test isolation. Each test 
can create and modify instance attributes without them affecting other tests 
from the same class.

--

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