Skip to content

Commit

Permalink
Remove Python 2 imports
Browse files Browse the repository at this point in the history
  • Loading branch information
jitseniesen committed Jul 1, 2022
1 parent ba8c6e3 commit 79322ed
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 39 deletions.
6 changes: 1 addition & 5 deletions spyder_unittest/backend/runnerbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,10 @@
import tempfile

# Third party imports
from importlib.util import find_spec as find_spec_or_loader
from qtpy.QtCore import (QObject, QProcess, QProcessEnvironment, QTextCodec,
Signal)

try:
from importlib.util import find_spec as find_spec_or_loader
except ImportError: # Python 2
from pkgutil import find_loader as find_spec_or_loader


# if generating coverage report, use this name for the TestResult
# it's here in case we can get coverage results from unittest too
Expand Down
6 changes: 1 addition & 5 deletions spyder_unittest/backend/tests/test_pytestrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import os
import os.path as osp
import sys
from unittest.mock import Mock

# Third party imports
import pytest
Expand All @@ -20,11 +21,6 @@
COV_TEST_NAME)
from spyder_unittest.widgets.configdialog import Config

try:
from unittest.mock import Mock
except ImportError:
from mock import Mock # Python 2


def test_pytestrunner_is_installed():
assert PyTestRunner(None).is_installed()
Expand Down
6 changes: 1 addition & 5 deletions spyder_unittest/backend/tests/test_pytestworker.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

# Standard library imports
import os
from unittest.mock import call, create_autospec, MagicMock, Mock

# Third party imports
import pytest
Expand All @@ -15,11 +16,6 @@
from spyder_unittest.backend.pytestworker import SpyderPlugin, main
from spyder_unittest.backend.zmqstream import ZmqStreamWriter

try:
from unittest.mock import call, create_autospec, MagicMock, Mock
except ImportError:
from mock import call, create_autospec, MagicMock, Mock # Python 2


class EmptyClass:
pass
Expand Down
6 changes: 1 addition & 5 deletions spyder_unittest/backend/tests/test_runnerbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

# Standard library imports
import os
from unittest.mock import Mock

# Third party imports
import pytest
Expand All @@ -15,11 +16,6 @@
from spyder_unittest.backend.runnerbase import RunnerBase
from spyder_unittest.widgets.configdialog import Config

try:
from unittest.mock import Mock
except ImportError:
from mock import Mock # Python 2


def test_runnerbase_with_nonexisting_module():
class FooRunner(RunnerBase):
Expand Down
6 changes: 1 addition & 5 deletions spyder_unittest/tests/test_unittestplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,12 @@
# Third party imports
import pytest
from spyder.plugins.projects.api import EmptyProject
from unittest.mock import MagicMock

# Local imports
from spyder_unittest.unittestplugin import UnitTestPlugin
from spyder_unittest.widgets.configdialog import Config

try:
from unittest.mock import MagicMock
except ImportError:
from mock import MagicMock # Python 2


class PluginForTesting(UnitTestPlugin):
CONF_FILE = False
Expand Down
5 changes: 1 addition & 4 deletions spyder_unittest/widgets/configdialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# Standard library imports
from collections import namedtuple
from os import getcwd
from pkgutil import find_loader as find_spec_or_loader
import os.path as osp

# Third party imports
Expand All @@ -23,10 +24,6 @@
from spyder.config.base import get_translation
from spyder.utils import icon_manager as ima

try:
from importlib.util import find_spec as find_spec_or_loader
except ImportError: # Python 2
from pkgutil import find_loader as find_spec_or_loader

try:
_ = get_translation('spyder_unittest')
Expand Down
6 changes: 1 addition & 5 deletions spyder_unittest/widgets/tests/test_datatree.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,14 @@
# Third party imports
from qtpy.QtCore import QModelIndex, QPoint, Qt
from qtpy.QtGui import QContextMenuEvent
from unittest.mock import Mock
import pytest

# Local imports
from spyder_unittest.backend.runnerbase import Category, TestResult
from spyder_unittest.widgets.datatree import (COLORS, COLORS_DARK,
TestDataModel, TestDataView)

try:
from unittest.mock import Mock
except ImportError:
from mock import Mock # Python 2


@pytest.fixture
def view_and_model(qtbot):
Expand Down
6 changes: 1 addition & 5 deletions spyder_unittest/widgets/tests/test_unittestgui.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# Standard library imports
import os
import sys
from unittest.mock import Mock

# Third party imports
from qtpy.QtCore import Qt, QProcess
Expand All @@ -19,11 +20,6 @@
from spyder_unittest.widgets.configdialog import Config
from spyder_unittest.widgets.unittestgui import UnitTestWidget

try:
from unittest.mock import Mock
except ImportError:
from mock import Mock # Python 2


@pytest.fixture
def widget(qtbot):
Expand Down

0 comments on commit 79322ed

Please sign in to comment.