should tests be thread-safe?

Hi, May tests expect that unless they themselves start a thread then there are no threads to worry about? I see that some old tests are not thread-safe and I have not found it to be explicitly mentioned in the devguide. I've written a test for http://bugs.python.org/issue21332 that is known to be non-thread-safe. Is it acceptable for new tests? -- akira

On 10 May 2014 06:53, "akira" <4kir4.1i@gmail.com> wrote:
Hi,
May tests expect that unless they themselves start a thread then there
are no threads to worry about?
I see that some old tests are not thread-safe and I have not found it to
be explicitly mentioned in the devguide.
I've written a test for http://bugs.python.org/issue21332 that is known
to be non-thread-safe. Is it acceptable for new tests? Thread safety is desirable, but not mandatory, since there is some process global state (e.g. the import system and the sys module in general) that the tests sometimes need to manipulate. Cheers, Nick.
-- akira _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe:
https://mail.python.org/mailman/options/python-dev/ncoghlan%40gmail.com

If you need a well defined environement, run your test in a subprocess. Depending on the random function, your test may be run with more threads. On BSD, it changes for example which thread receives a signal. Importing the tkinter module creates a "hidden" C thread for the Tk loop. Victor

Victor Stinner <victor.stinner@gmail.com> writes:
If you need a well defined environement, run your test in a subprocess. Depending on the random function, your test may be run with more threads. On BSD, it changes for example which thread receives a signal. Importing the tkinter module creates a "hidden" C thread for the Tk loop.
Does it mean that non-thread-safe tests can't be run using a GUI test runner that is implemented using tkinter? -- akira
participants (4)
-
akira
-
Akira Li
-
Nick Coghlan
-
Victor Stinner