|
15 | 15 | from xmlrunner.result import _XMLTestResult |
16 | 16 | import doctest |
17 | 17 | import tests.doctest_example |
18 | | -from six import StringIO, BytesIO, exec_ |
| 18 | +from io import StringIO, BytesIO |
19 | 19 | from tempfile import mkdtemp |
20 | 20 | from tempfile import mkstemp |
21 | 21 | from shutil import rmtree |
|
24 | 24 | from lxml import etree |
25 | 25 | import os |
26 | 26 | import os.path |
27 | | - |
28 | | -try: |
29 | | - from unittest import mock |
30 | | -except ImportError: |
31 | | - import mock |
| 27 | +from unittest import mock |
32 | 28 |
|
33 | 29 |
|
34 | 30 | def _load_schema(): |
@@ -114,7 +110,7 @@ def wrapper(*args, **kwargs): |
114 | 110 | return func(*args, **kwargs) |
115 | 111 | """ |
116 | 112 | evaldict = dict(func=f) |
117 | | - exec_(code, evaldict) |
| 113 | + exec(code, evaldict) |
118 | 114 | return evaldict['wrapper'] |
119 | 115 |
|
120 | 116 |
|
@@ -402,21 +398,13 @@ def _xmlrunner_non_ascii_failures(self, buffer=False): |
402 | 398 |
|
403 | 399 | # allow output non-ascii letters to stdout |
404 | 400 | orig_stdout = sys.stdout |
405 | | - if getattr(sys.stdout, 'buffer', None): |
406 | | - # Python3 |
407 | | - sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') |
408 | | - else: |
409 | | - # Python2 |
410 | | - import codecs |
411 | | - sys.stdout = codecs.getwriter("utf-8")(sys.stdout) |
| 401 | + sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') |
412 | 402 |
|
413 | 403 | try: |
414 | 404 | runner.run(suite) |
415 | 405 | finally: |
416 | | - if getattr(sys.stdout, 'buffer', None): |
417 | | - # Python3 |
418 | | - # Not to be closed when TextIOWrapper is disposed. |
419 | | - sys.stdout.detach() |
| 406 | + # Not to be closed when TextIOWrapper is disposed. |
| 407 | + sys.stdout.detach() |
420 | 408 | sys.stdout = orig_stdout |
421 | 409 | outdir.seek(0) |
422 | 410 | output = outdir.read() |
@@ -835,10 +823,7 @@ def test_test_program_fail_wo_buffer(self): |
835 | 823 | self.assertNotIn('should be printed', r[1].getvalue()) |
836 | 824 |
|
837 | 825 | def test_partialmethod(self): |
838 | | - try: |
839 | | - from functools import partialmethod |
840 | | - except ImportError: |
841 | | - raise unittest.SkipTest('functools.partialmethod is not available.') |
| 826 | + from functools import partialmethod |
842 | 827 | def test_partialmethod(test): |
843 | 828 | pass |
844 | 829 | class TestWithPartialmethod(unittest.TestCase): |
|
0 commit comments