Commit 0be88490 authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

TEST: Remove use of six/backported mock

parent 95b43c48
......@@ -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
......
......@@ -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]
......
......@@ -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
......
......@@ -7,8 +7,8 @@
import os.path as op
import time
from unittest import mock
import mock
import pytest
import numpy as np
......
......@@ -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
......
......@@ -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
"""
......
......@@ -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]
......
......@@ -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
......
......@@ -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
......
......@@ -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]
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment