Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Dev

Re: [Python-checkins] cpython: #14533: if a test has no test_main, use loadTestsFromModule.

 

 

Python dev RSS feed   Index | Next | Previous | View Threaded


tjreedy at udel

Apr 9, 2012, 10:34 AM

Post #1 of 4 (174 views)
Permalink
Re: [Python-checkins] cpython: #14533: if a test has no test_main, use loadTestsFromModule.

On 4/9/2012 9:13 AM, r.david.murray wrote:
> http://hg.python.org/cpython/rev/eff551437abd
> changeset: 76176:eff551437abd
> user: R David Murray<rdmurray [at] bitdance>
> date: Mon Apr 09 08:55:42 2012 -0400
> summary:
> #14533: if a test has no test_main, use loadTestsFromModule.
>
> This moves us further in the direction of using normal unittest facilities
> instead of specialized regrtest ones. Any test module that can be correctly
> run currently using 'python unittest -m test.test_xxx' can now be converted to
> use normal unittest test loading by simply deleting its test_main, thus no
> longer requiring manual maintenance of the list of tests to run.
...
> + if __name__ == '__main__':
> + unittest.main()
>
> - if __name__ == '__main__':
> - test_main()

Being on Windows, I sometimes run single tests interactively with

from test import test_xxx as t; t.test_main()

Should t.unittest.main(t.__name__) work as well?
Should this always work even if there is still a test_main?

tjr
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


anacrolix at gmail

Apr 9, 2012, 12:11 PM

Post #2 of 4 (145 views)
Permalink
Re: [Python-checkins] cpython: #14533: if a test has no test_main, use loadTestsFromModule. [In reply to]

On Apr 10, 2012 2:36 AM, "Terry Reedy" <tjreedy [at] udel> wrote:
>
>
> On 4/9/2012 9:13 AM, r.david.murray wrote:
>>
>> http://hg.python.org/cpython/rev/eff551437abd
>> changeset: 76176:eff551437abd
>> user: R David Murray<rdmurray [at] bitdance>
>> date: Mon Apr 09 08:55:42 2012 -0400
>> summary:
>> #14533: if a test has no test_main, use loadTestsFromModule.
>>
>> This moves us further in the direction of using normal unittest
facilities
>> instead of specialized regrtest ones. Any test module that can be
correctly
>> run currently using 'python unittest -m test.test_xxx' can now be
converted to
>> use normal unittest test loading by simply deleting its test_main, thus
no
>> longer requiring manual maintenance of the list of tests to run.
>
> ...
>>
>> + if __name__ == '__main__':
>> + unittest.main()
>>
>> - if __name__ == '__main__':
>> - test_main()
>
>
> Being on Windows, I sometimes run single tests interactively with
>
> from test import test_xxx as t; t.test_main()
>
> Should t.unittest.main(t.__name__) work as well?
> Should this always work even if there is still a test_main?
Both questions have the same answer. Yes, because this is how discovery
works.
>
> tjr
> _______________________________________________
> Python-Dev mailing list
> Python-Dev [at] python
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
http://mail.python.org/mailman/options/python-dev/anacrolix%40gmail.com


rdmurray at bitdance

Apr 9, 2012, 12:57 PM

Post #3 of 4 (145 views)
Permalink
Re: [Python-checkins] cpython: #14533: if a test has no test_main, use loadTestsFromModule. [In reply to]

On Mon, 09 Apr 2012 13:34:25 -0400, Terry Reedy <tjreedy [at] udel> wrote:
>
> On 4/9/2012 9:13 AM, r.david.murray wrote:
> > http://hg.python.org/cpython/rev/eff551437abd
> > changeset: 76176:eff551437abd
> > user: R David Murray<rdmurray [at] bitdance>
> > date: Mon Apr 09 08:55:42 2012 -0400
> > summary:
> > #14533: if a test has no test_main, use loadTestsFromModule.
> >
> > This moves us further in the direction of using normal unittest facilities
> > instead of specialized regrtest ones. Any test module that can be correctly
> > run currently using 'python unittest -m test.test_xxx' can now be converted to
> > use normal unittest test loading by simply deleting its test_main, thus no
> > longer requiring manual maintenance of the list of tests to run.
> ...
> > + if __name__ == '__main__':
> > + unittest.main()
> >
> > - if __name__ == '__main__':
> > - test_main()
>
> Being on Windows, I sometimes run single tests interactively with
>
> from test import test_xxx as t; t.test_main()
>
> Should t.unittest.main(t.__name__) work as well?

That will work.

t.unittest.main(t) will also work and is less typing.

> Should this always work even if there is still a test_main?

It will work if and only if the test can be run correctly via './python
-m unittest test.test_xxx'. Not all test files in Lib/test can be run that
way (though I at least am open to fixing ones that don't work).

--David
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


tjreedy at udel

Apr 9, 2012, 4:38 PM

Post #4 of 4 (143 views)
Permalink
Re: [Python-checkins] cpython: #14533: if a test has no test_main, use loadTestsFromModule. [In reply to]

On 4/9/2012 3:57 PM, R. David Murray wrote:
> On Mon, 09 Apr 2012 13:34:25 -0400, Terry Reedy<tjreedy [at] udel> wrote:

>> Should t.unittest.main(t.__name__) work as well?
>
> That will work.
>
> t.unittest.main(t) will also work and is less typing.

Good. The only doc for the parameter is "unittest.main(module='__main__',"
with no indication other than the name 'module' that both a module
object or a name is accepted (as with some file object or name interfaces).

>> Should this always work even if there is still a test_main?
>
> It will work if and only if the test can be run correctly via './python
> -m unittest test.test_xxx'. Not all test files in Lib/test can be run that
> way (though I at least am open to fixing ones that don't work).

One way to again run each would be nice. I will open an issue if I find
any laggards.

--
Terry Jan Reedy

_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com

Python dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.