[issue16312] New command line option supported by unittest.main() for running initialization code before tests

2017-06-20 Thread Никита Конин

Changes by Никита Конин :


--
nosy: +Никита Конин

___
Python tracker 

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



[issue16312] New command line option supported by unittest.main() for running initialization code before tests

2012-11-14 Thread Piotr Dobrogost

Piotr Dobrogost added the comment:

 But I think Piotr's use case is when you download some new library (...)

Yes, indeed.

--

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



[issue16312] New command line option supported by unittest.main() for running initialization code before tests

2012-10-29 Thread Michael Foord

Michael Foord added the comment:

Is this logging specific issue an actual problem or a theoretical problem? It's 
not a problem I've ever seen (myself), nor the one the issue was opened for.

--

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



[issue16312] New command line option supported by unittest.main() for running initialization code before tests

2012-10-29 Thread Vinay Sajip

Vinay Sajip added the comment:

Not an actual problem (for me), and although the issue was opened for more 
general functionality, logging is the only specific use case that was actually 
cited.

--

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



[issue16312] New command line option supported by unittest.main() for running initialization code before tests

2012-10-28 Thread Vinay Sajip

Vinay Sajip added the comment:

Is there any common use case other than logging? For example, logging could be 
covered by an additional command-line argument for unittest.main(), e.g.

--logconfig /path/to/logging-config.json

which would cause unittest.main() to load the JSON in the specified file 
(expected to be a suitable dict) and pass it to logging.config.dictConfig().

That would handle a perhaps not uncommon use case without the user having to 
write any code, but rather just provide a suitable logging configuration.

--
nosy: +vinay.sajip

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



[issue16312] New command line option supported by unittest.main() for running initialization code before tests

2012-10-28 Thread Piotr Dobrogost

Piotr Dobrogost added the comment:

@Vinay
I don't see other use cases but maybe guys behind py.test, where there is such 
a feature could come up with other use cases.
The solution with passing config dict in a new command line parameter seems to 
be enough as long as logging is concerned. However it's not as versatile as 
custom initialization code of course.

--

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



[issue16312] New command line option supported by unittest.main() for running initialization code before tests

2012-10-28 Thread Michael Foord

Michael Foord added the comment:

I always solve the logging problem with test-development-production 
configuratins and ensuring that running tests imports the logging setup. I've 
never wanted / needed to configure logging from the command line.

--

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



[issue16312] New command line option supported by unittest.main() for running initialization code before tests

2012-10-28 Thread Vinay Sajip

Vinay Sajip added the comment:

@Michael: When unit testing one's own projects, I agree with you. But I think 
Piotr's use case is when you download some new library from PyPI or clone it 
from GitHub/BitBucket/etc., and you want to run tests on that code without 
changing any of it, as you're just exploring at this point. Now ideally you'd 
just be able to do e.g.

python setup.py test --logconfig filename.json

or, if it isn't set up to do that, at least look for a test folder with scripts 
that have 'if __name__ == __main__: unittest.main()', which I can then run. 
In either of these cases, even if the library I'm testing uses logging, I can't 
readily make use of it to look at DEBUG messages, say, unless I write some code 
(not much code, I grant you).

Of course, once you get to the point where you've decided to use that library 
in your project, you would integrate its logging setup with the logging setup 
of your own code, in your tests.

--

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



[issue16312] New command line option supported by unittest.main() for running initialization code before tests

2012-10-27 Thread Piotr Dobrogost

Piotr Dobrogost added the comment:

@Chris

The example given by Holger Krekel (http://stackoverflow.com/a/13094042/95735) 
showing how it can be done with pytest is exactly the thing I had in mind. It 
would be good to have this feature incorporated into unittest.

@Michael

I guess checking this flag must be protected by a lock in case test cases are 
run in parallel. If so wouldn't this be kind of a bottleneck? Is this flag 
necessary? Can't we just assume that initialization code had already run when 
any testcase runs?

There's interesting question how would initialization code be run in case of 
auto discovery. In the simplest form it would be run just once before all 
modules with tests are run. But it would be interesting to allow running 
initialization per test module. To support this unittest should somehow pass 
name of test module to be executed to initialization code. Alternatively there 
could be some special named init files which would be run before running test 
modules.

--

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



[issue16312] New command line option supported by unittest.main() for running initialization code before tests

2012-10-27 Thread Michael Foord

Michael Foord added the comment:

@piotr
Yes, protecting the set up with a lock would be easy, although unittest doesn't 
directly support running tests in parallel anyway.

--

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



[issue16312] New command line option supported by unittest.main() for running initialization code before tests

2012-10-26 Thread Ezio Melotti

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


--
nosy: +ezio.melotti, michael.foord

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



[issue16312] New command line option supported by unittest.main() for running initialization code before tests

2012-10-26 Thread Chris Jerdonek

Chris Jerdonek added the comment:

Can you give an example of what you would like the API to look like (i.e. what 
you would like to be able to type from the command-line if, say, configuring 
logging as in the SO post)?

I'm not sure I understand why a wrapper script isn't a good enough solution, as 
described in the accepted answer on SO.

--
nosy: +chris.jerdonek

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



[issue16312] New command line option supported by unittest.main() for running initialization code before tests

2012-10-26 Thread Michael Foord

Michael Foord added the comment:

I would do this with a module level (global) flag as to whether the initial set 
up has been done and a BaseTestCase class that checks this flag and calls a set 
up function if it hasn't been done yet (and then sets the flag).

--

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



[issue16312] New command line option supported by unittest.main() for running initialization code before tests

2012-10-26 Thread Michael Foord

Changes by Michael Foord mich...@voidspace.org.uk:


--
assignee:  - michael.foord

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



[issue16312] New command line option supported by unittest.main() for running initialization code before tests

2012-10-24 Thread Piotr Dobrogost

New submission from Piotr Dobrogost:

When running tests bundled with a library it would be useful to be able to run 
some initialization code before tests are being run so that one can configure 
options pertaining to logging for example.

For this reason it would be useful to have a new command line option handled by 
unittest.main() for running custom Python module before running tests.

See http://stackoverflow.com/q/8607767/95735

--
components: Library (Lib)
messages: 173699
nosy: piotr.dobrogost
priority: normal
severity: normal
status: open
title: New command line option supported by unittest.main() for running 
initialization code before tests
type: enhancement
versions: Python 3.4, Python 3.5

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