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 ...@@ -20,11 +20,9 @@ import os.path as op
import numpy as np import numpy as np
import nibabel as nib import nibabel as nib
from six import StringIO from io import StringIO
from unittest import mock
try: from unittest import mock
except ImportError: import mock
import fsl.data.image as fslimage import fsl.data.image as fslimage
from fsl.utils.tempdir import tempdir from fsl.utils.tempdir import tempdir
......
...@@ -9,11 +9,10 @@ import gc ...@@ -9,11 +9,10 @@ import gc
import time import time
import threading import threading
import random import random
import importlib
from six.moves import reload_module
import pytest import pytest
import mock from unittest import mock
import fsl.utils.idle as idle import fsl.utils.idle as idle
from fsl.utils.platform import platform as fslplatform from fsl.utils.platform import platform as fslplatform
...@@ -428,7 +427,7 @@ def test_idle_alwaysQueue4(): ...@@ -428,7 +427,7 @@ def test_idle_alwaysQueue4():
with pytest.raises(ImportError): with pytest.raises(ImportError):
import wx import wx
reload_module(fsl.utils.platform) importlib.reload(fsl.utils.platform)
assert called[0] assert called[0]
......
...@@ -32,11 +32,7 @@ from fsl.utils.tempdir import tempdir ...@@ -32,11 +32,7 @@ from fsl.utils.tempdir import tempdir
from . import make_random_image from . import make_random_image
from . import make_dummy_file from . import make_dummy_file
try: from unittest import mock
from unittest import mock
except ImportError:
import mock
try: try:
import indexed_gzip as igzip import indexed_gzip as igzip
......
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
import os.path as op import os.path as op
import time import time
from unittest import mock
import mock
import pytest import pytest
import numpy as np import numpy as np
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
# #
import collections import collections
import six
import numpy as np import numpy as np
...@@ -44,7 +43,7 @@ def test_memoize(): ...@@ -44,7 +43,7 @@ def test_memoize():
assert timesCalled[0] == 6 assert timesCalled[0] == 6
# Unicode arg # Unicode arg
s = six.u('\u25B2') s = '\u25B2'
assert memoized(s) == s * 5 assert memoized(s) == s * 5
assert timesCalled[0] == 7 assert timesCalled[0] == 7
assert memoized(s) == s * 5 assert memoized(s) == s * 5
...@@ -146,7 +145,7 @@ def test_memoizeMD5(): ...@@ -146,7 +145,7 @@ def test_memoizeMD5():
assert timesCalled[0] == 6 assert timesCalled[0] == 6
# Unicode arg (and return value) # Unicode arg (and return value)
s = six.u('\u25B2') s = '\u25B2'
assert memoized(s) == s * 5 assert memoized(s) == s * 5
assert timesCalled[0] == 7 assert timesCalled[0] == 7
assert memoized(s) == s * 5 assert memoized(s) == s * 5
......
...@@ -6,15 +6,14 @@ ...@@ -6,15 +6,14 @@
# #
import os import os
import gc import gc
import os.path as op import os.path as op
import sys import sys
import shutil import shutil
import tempfile import tempfile
import pytest import pytest
from unittest import mock
import mock
import fsl.utils.platform as fslplatform import fsl.utils.platform as fslplatform
...@@ -216,7 +215,7 @@ def test_detect_ssh(): ...@@ -216,7 +215,7 @@ def test_detect_ssh():
def test_fslwsl(): def test_fslwsl():
""" """
Note that ``Platform.fsldir`` requires the directory in ``FSLDIR`` to exist and 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 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 here is whether ``Platform.fslwsl`` recognizes a WSL ``FSLDIR`` string
""" """
......
...@@ -11,12 +11,8 @@ import os ...@@ -11,12 +11,8 @@ import os
import shutil import shutil
import textwrap import textwrap
# python 3 from unittest import mock
try: from unittest import mock
# python 2
except ImportError: import mock
import six
import pytest import pytest
import fsl.utils.tempdir as tempdir import fsl.utils.tempdir as tempdir
...@@ -273,7 +269,7 @@ def test_runfsl(): ...@@ -273,7 +269,7 @@ def test_runfsl():
def mock_submit(cmd, **kwargs): def mock_submit(cmd, **kwargs):
if isinstance(cmd, six.string_types): if isinstance(cmd, str):
name = cmd.split()[0] name = cmd.split()[0]
else: else:
name = cmd[0] name = cmd[0]
......
...@@ -12,12 +12,7 @@ import pickle ...@@ -12,12 +12,7 @@ import pickle
import textwrap import textwrap
import tempfile import tempfile
# python 3 import unittest.mock as mock
try:
import unittest.mock as mock
# python 2
except:
import mock
import pytest import pytest
......
...@@ -6,8 +6,6 @@ ...@@ -6,8 +6,6 @@
# #
from __future__ import division
import random import random
import glob import glob
import os.path as op import os.path as op
...@@ -15,8 +13,6 @@ import itertools as it ...@@ -15,8 +13,6 @@ import itertools as it
import numpy as np import numpy as np
import numpy.linalg as npla import numpy.linalg as npla
import six
import pytest import pytest
import fsl.transform.affine as affine import fsl.transform.affine as affine
...@@ -39,8 +35,7 @@ def readlines(filename): ...@@ -39,8 +35,7 @@ def readlines(filename):
# #
# Pass it [bytes, bytes, ...], and it works # Pass it [bytes, bytes, ...], and it works
# fine. # fine.
if six.PY3: lines = [l.encode('ascii') for l in lines]
lines = [l.encode('ascii') for l in lines]
return lines return lines
......
...@@ -11,10 +11,8 @@ import shlex ...@@ -11,10 +11,8 @@ import shlex
import pathlib import pathlib
import textwrap import textwrap
try: from unittest import mock from unittest import mock
except ImportError: import mock
import six
import pytest import pytest
import numpy as np import numpy as np
...@@ -317,7 +315,7 @@ def test_fileOrThing_sequence(): ...@@ -317,7 +315,7 @@ def test_fileOrThing_sequence():
@wutils.fileOrArray('arrs', 'out') @wutils.fileOrArray('arrs', 'out')
def func(arrs, out): def func(arrs, out):
if isinstance(arrs, six.string_types): if isinstance(arrs, str):
arrs = [arrs] arrs = [arrs]
arrs = [np.loadtxt(a) for a in 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