|
12 | 12 | from comtypes.gen import Scripting
|
13 | 13 |
|
14 | 14 |
|
15 |
| -if sys.version_info >= (3, 0): |
16 |
| - text_type = str |
17 |
| -else: |
18 |
| - text_type = unicode |
19 |
| - |
20 |
| - |
21 |
| -# HACK: Prefer to use `contextlib.redirect_stdout`, but it's New in version 3.4 |
22 |
| -@contextlib.contextmanager |
23 |
| -def silence_stdout(): |
24 |
| - old_target = sys.stdout |
25 |
| - try: |
26 |
| - with open(os.devnull, "w") as new_target: |
27 |
| - sys.stdout = new_target |
28 |
| - yield new_target |
29 |
| - finally: |
30 |
| - sys.stdout = old_target |
31 |
| - |
32 |
| - |
33 | 15 | class Test_GetModule(ut.TestCase):
|
34 | 16 | def test_tlib_string(self):
|
35 | 17 | mod = comtypes.client.GetModule("scrrun.dll")
|
@@ -140,7 +122,6 @@ def test_clsid(self):
|
140 | 122 |
|
141 | 123 | def test_clsid_string(self):
|
142 | 124 | # create from string clsid
|
143 |
| - comtypes.client.CreateObject(text_type(Scripting.Dictionary._reg_clsid_)) |
144 | 125 | comtypes.client.CreateObject(str(Scripting.Dictionary._reg_clsid_))
|
145 | 126 |
|
146 | 127 | def test_remote(self):
|
@@ -267,9 +248,8 @@ def test_returns_other_than_enum_members(self):
|
267 | 248 | # float (Constant c_float)
|
268 | 249 | self.assertEqual(consts.Speech_Default_Weight, sapi.Speech_Default_Weight)
|
269 | 250 |
|
270 |
| - @ut.skipUnless(sys.version_info >= (3, 0), "Some words are not in Python2 keywords") |
271 | 251 | def test_munged_definitions(self):
|
272 |
| - with silence_stdout(): # supress warnings |
| 252 | + with contextlib.redirect_stdout(None): # supress warnings |
273 | 253 | MSVidCtlLib = comtypes.client.GetModule("msvidctl.dll")
|
274 | 254 | consts = comtypes.client.Constants("msvidctl.dll")
|
275 | 255 | # `None` is a Python3 keyword.
|
|
0 commit comments