diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-08-16 09:56:42 +0200 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-08-16 09:56:42 +0200 |
| commit | 688678e7c091e4549777d8cc47e8984d5e672976 (patch) | |
| tree | 0c2dd36a5270fabc67fb7c723c93abfba2f7abb4 | |
| parent | e98cb05edf87eebf939a680066822c16f1257f44 (diff) | |
[py3] Avoided relying on 2.x-only internals
in LiveServerTestCase.
| -rw-r--r-- | django/test/testcases.py | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/django/test/testcases.py b/django/test/testcases.py index bdd85d71c3..0e33ef082a 100644 --- a/django/test/testcases.py +++ b/django/test/testcases.py @@ -917,23 +917,26 @@ class QuietWSGIRequestHandler(WSGIRequestHandler): pass -class _ImprovedEvent(threading._Event): - """ - Does the same as `threading.Event` except it overrides the wait() method - with some code borrowed from Python 2.7 to return the set state of the - event (see: http://hg.python.org/cpython/rev/b5aa8aa78c0f/). This allows - to know whether the wait() method exited normally or because of the - timeout. This class can be removed when Django supports only Python >= 2.7. - """ +if sys.version_info >= (2, 6, 0): + _ImprovedEvent = threading._Event +else: + class _ImprovedEvent(threading._Event): + """ + Does the same as `threading.Event` except it overrides the wait() method + with some code borrowed from Python 2.7 to return the set state of the + event (see: http://hg.python.org/cpython/rev/b5aa8aa78c0f/). This allows + to know whether the wait() method exited normally or because of the + timeout. This class can be removed when Django supports only Python >= 2.7. + """ - def wait(self, timeout=None): - self._Event__cond.acquire() - try: - if not self._Event__flag: - self._Event__cond.wait(timeout) - return self._Event__flag - finally: - self._Event__cond.release() + def wait(self, timeout=None): + self._Event__cond.acquire() + try: + if not self._Event__flag: + self._Event__cond.wait(timeout) + return self._Event__flag + finally: + self._Event__cond.release() class StoppableWSGIServer(WSGIServer): |
