diff --git a/twisted/python/runtime.py b/twisted/python/runtime.py
index da078bf..c54a0c3 100644
|
a
|
b
|
|
| 9 | 9 | import time |
| 10 | 10 | import imp |
| 11 | 11 | |
| | 12 | from twisted.python import compat |
| | 13 | |
| 12 | 14 | |
| 13 | 15 | |
| 14 | 16 | def shortPythonVersion(): |
| … |
… |
|
| 73 | 75 | def isWinNT(self): |
| 74 | 76 | """Are we running in Windows NT?""" |
| 75 | 77 | if self.getType() == 'win32': |
| 76 | | import _winreg |
| | 78 | # Python 3.x changed this module's name. |
| | 79 | winreg = None |
| | 80 | if compat._PY3: |
| | 81 | import winreg as winreg |
| | 82 | else: |
| | 83 | import _winreg as winreg |
| 77 | 84 | try: |
| 78 | | k = _winreg.OpenKeyEx( |
| 79 | | _winreg.HKEY_LOCAL_MACHINE, |
| | 85 | k = winreg.OpenKeyEx( |
| | 86 | winreg.HKEY_LOCAL_MACHINE, |
| 80 | 87 | r'Software\Microsoft\Windows NT\CurrentVersion') |
| 81 | | _winreg.QueryValueEx(k, 'SystemRoot') |
| | 88 | winreg.QueryValueEx(k, 'SystemRoot') |
| 82 | 89 | return 1 |
| 83 | 90 | except WindowsError: |
| 84 | 91 | return 0 |
| … |
… |
|
| 113 | 120 | return self._platform.startswith("linux") |
| 114 | 121 | |
| 115 | 122 | |
| | 123 | # Python 3.x changed this module's name. |
| | 124 | _thread_module_name = "_thread" if compat._PY3 else "thread" |
| 116 | 125 | def supportsThreads(self): |
| 117 | 126 | """Can threads be created? |
| 118 | 127 | """ |
| 119 | 128 | try: |
| 120 | | return imp.find_module('thread')[0] is None |
| | 129 | return imp.find_module(self._thread_module_name)[0] is None |
| 121 | 130 | except ImportError: |
| 122 | 131 | return False |
| 123 | 132 | |
diff --git a/twisted/python/test/test_runtime.py b/twisted/python/test/test_runtime.py
index 4c94fb5..5646fe4 100644
|
a
|
b
|
|
| 6 | 6 | """ |
| 7 | 7 | |
| 8 | 8 | import sys |
| | 9 | from unittest import TestCase |
| 9 | 10 | |
| 10 | 11 | from twisted.python.runtime import Platform, shortPythonVersion |
| 11 | | from twisted.trial.unittest import TestCase |
| | 12 | ## from twisted.trial.unittest import TestCase |
| | 13 | |
| | 14 | # TODO: Once trial is ported to Python 3.x these tests should start using it |
| | 15 | # again. Until then, use the standard Python unittesting framework. |
| | 16 | # To do this, uncomment the line above that imports TestCase from trial, and |
| | 17 | # delete the line that imports TestCase from unittest. |
| | 18 | # Ticket #5919 |
| 12 | 19 | |
| 13 | 20 | |
| 14 | 21 | |
| … |
… |
|
| 64 | 71 | self.assertTrue(sys.platform.startswith("linux")) |
| 65 | 72 | |
| 66 | 73 | |
| | 74 | def test_isWinNT(self): |
| | 75 | """ |
| | 76 | L{Platform.isWinNT}'s can return only C{0} or C{1} and can not |
| | 77 | return C{1} if L{Platform.getType} is not C{"win32"}. |
| | 78 | """ |
| | 79 | platform = Platform() |
| | 80 | isWinNT = platform.isWinNT() |
| | 81 | self.assertIn(isWinNT, (0, 1)) |
| | 82 | if platform.getType() != "win32": |
| | 83 | self.assertEqual(isWinNT, 0) |
| | 84 | |
| | 85 | |
| 67 | 86 | |
| 68 | 87 | class ForeignPlatformTests(TestCase): |
| 69 | 88 | """ |