diff --git a/tests/__init__.py b/tests/__init__.py index 24587392fc29de81bea199cb8e991b6012cba22e..58e6d23beda36a3c4cf2ce61046c54310173d5e8 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -20,11 +20,9 @@ import os.path as op import numpy as np import nibabel as nib -from six import StringIO +from io import StringIO - -try: from unittest import mock -except ImportError: import mock +from unittest import mock import fsl.data.image as fslimage from fsl.utils.tempdir import tempdir diff --git a/tests/test_idle.py b/tests/test_idle.py index edf0ecb171b54fe382d233c5c69a49ae77b57f1c..6ceb010bb91aa36ce642d1b3034f5655d7bc58c8 100644 --- a/tests/test_idle.py +++ b/tests/test_idle.py @@ -9,11 +9,10 @@ import gc import time import threading import random - -from six.moves import reload_module +import importlib import pytest -import mock +from unittest import mock import fsl.utils.idle as idle from fsl.utils.platform import platform as fslplatform @@ -428,7 +427,7 @@ def test_idle_alwaysQueue4(): with pytest.raises(ImportError): import wx - reload_module(fsl.utils.platform) + importlib.reload(fsl.utils.platform) assert called[0] diff --git a/tests/test_image.py b/tests/test_image.py index 8085cb92cf55b04a8c337c816b3e3fa23716ba30..34a5482ce8f63a7d66ed83d881f9a575680a55ab 100644 --- a/tests/test_image.py +++ b/tests/test_image.py @@ -32,11 +32,7 @@ from fsl.utils.tempdir import tempdir from . import make_random_image from . import make_dummy_file -try: - from unittest import mock -except ImportError: - import mock - +from unittest import mock try: import indexed_gzip as igzip diff --git a/tests/test_image_advanced.py b/tests/test_image_advanced.py index fd7f64359d9bc071b33689ff95a8697170c247d0..1f1aed8a2ba827836314f61709e3a0316e41616f 100644 --- a/tests/test_image_advanced.py +++ b/tests/test_image_advanced.py @@ -7,8 +7,8 @@ import os.path as op import time +from unittest import mock -import mock import pytest import numpy as np diff --git a/tests/test_memoize.py b/tests/test_memoize.py index 386674659b4a9af2648dadf445efd1a84a170f37..30844884d4695c040e82c11af2db7295118d1a17 100644 --- a/tests/test_memoize.py +++ b/tests/test_memoize.py @@ -6,7 +6,6 @@ # import collections -import six import numpy as np @@ -44,7 +43,7 @@ def test_memoize(): assert timesCalled[0] == 6 # Unicode arg - s = six.u('\u25B2') + s = '\u25B2' assert memoized(s) == s * 5 assert timesCalled[0] == 7 assert memoized(s) == s * 5 @@ -146,7 +145,7 @@ def test_memoizeMD5(): assert timesCalled[0] == 6 # Unicode arg (and return value) - s = six.u('\u25B2') + s = '\u25B2' assert memoized(s) == s * 5 assert timesCalled[0] == 7 assert memoized(s) == s * 5 diff --git a/tests/test_platform.py b/tests/test_platform.py index 9024bec8262658dd419c48ef288f2d4af2a75c8c..a38408175e438447570a75b9c0115e9da3f1d927 100644 --- a/tests/test_platform.py +++ b/tests/test_platform.py @@ -6,15 +6,14 @@ # -import os -import gc -import os.path as op -import sys -import shutil -import tempfile -import pytest - -import mock +import os +import gc +import os.path as op +import sys +import shutil +import tempfile +import pytest +from unittest import mock import fsl.utils.platform as fslplatform @@ -216,7 +215,7 @@ def test_detect_ssh(): def test_fslwsl(): """ Note that ``Platform.fsldir`` requires the directory in ``FSLDIR`` to exist and - sets ``FSLDIR`` to ``None`` if it doesn't. So we create a ``Platform`` first + sets ``FSLDIR`` to ``None`` if it doesn't. So we create a ``Platform`` first and then overwrite ``FSLDIR``. This is a bit of a hack but the logic we are testing here is whether ``Platform.fslwsl`` recognizes a WSL ``FSLDIR`` string """ diff --git a/tests/test_run.py b/tests/test_run.py index 7308b849c72f6f82afd00eb417c4d479b58d0f30..287ccd6432c4d98223f23712dda1da2c1bf668c2 100644 --- a/tests/test_run.py +++ b/tests/test_run.py @@ -11,12 +11,8 @@ import os import shutil import textwrap -# python 3 -try: from unittest import mock -# python 2 -except ImportError: import mock +from unittest import mock -import six import pytest import fsl.utils.tempdir as tempdir @@ -273,7 +269,7 @@ def test_runfsl(): def mock_submit(cmd, **kwargs): - if isinstance(cmd, six.string_types): + if isinstance(cmd, str): name = cmd.split()[0] else: name = cmd[0] diff --git a/tests/test_settings.py b/tests/test_settings.py index b17b1b87ab8e7ed747d2c2d0dd56d4e13053737a..fc0ca9edf7f90c0f5051d09c8e30a59319aae6c4 100644 --- a/tests/test_settings.py +++ b/tests/test_settings.py @@ -12,12 +12,7 @@ import pickle import textwrap import tempfile -# python 3 -try: - import unittest.mock as mock -# python 2 -except: - import mock +import unittest.mock as mock import pytest diff --git a/tests/test_transform/test_affine.py b/tests/test_transform/test_affine.py index f1dceb61312c7f05f97c9d871dc8a4a0ae95f492..e686080fc7040983b61047ce207f8d0fcb1966b2 100644 --- a/tests/test_transform/test_affine.py +++ b/tests/test_transform/test_affine.py @@ -6,8 +6,6 @@ # -from __future__ import division - import random import glob import os.path as op @@ -15,8 +13,6 @@ import itertools as it import numpy as np import numpy.linalg as npla -import six - import pytest import fsl.transform.affine as affine @@ -39,8 +35,7 @@ def readlines(filename): # # Pass it [bytes, bytes, ...], and it works # fine. - if six.PY3: - lines = [l.encode('ascii') for l in lines] + lines = [l.encode('ascii') for l in lines] return lines diff --git a/tests/test_wrappers/test_wrapperutils.py b/tests/test_wrappers/test_wrapperutils.py index 9bddb5c6b97e7ba6b9b78690c579fc3011aada81..f8a9d0dd4baa98f47003bf1846a92652f8e270bd 100644 --- a/tests/test_wrappers/test_wrapperutils.py +++ b/tests/test_wrappers/test_wrapperutils.py @@ -11,10 +11,8 @@ import shlex import pathlib import textwrap -try: from unittest import mock -except ImportError: import mock +from unittest import mock -import six import pytest import numpy as np @@ -317,7 +315,7 @@ def test_fileOrThing_sequence(): @wutils.fileOrArray('arrs', 'out') def func(arrs, out): - if isinstance(arrs, six.string_types): + if isinstance(arrs, str): arrs = [arrs] arrs = [np.loadtxt(a) for a in arrs]