Skip to content

Clean up remaining python 2 #257

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions pytest-profiling/tests/unit/test_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import importlib
import os.path
from unittest.mock import Mock, ANY, patch, sentinel, call

import pytest_profiling

Expand All @@ -14,12 +15,6 @@

from pytest_profiling import Profiling, pytest_addoption, pytest_configure

try:
from unittest.mock import Mock, ANY, patch, sentinel, call
except ImportError:
# python 2
from mock import Mock, ANY, patch, sentinel


def test_creates_prof_dir():
with patch("os.makedirs", side_effect=OSError) as makedirs:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import os.path
from pytest import raises
from unittest.mock import patch

try:
from unittest.mock import patch
except ImportError:
# python 2
from mock import patch
from pytest import raises


# patch out any changes you want to the Jenkins server here:
Expand Down
7 changes: 1 addition & 6 deletions pytest-server-fixtures/tests/integration/test_xvfb_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@
import time

from itertools import chain, repeat

try:
from unittest.mock import patch
except ImportError:
# python 2
from mock import patch
from unittest.mock import patch

import pytest
from pytest import raises
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
try:
from unittest.mock import sentinel, patch, Mock
except ImportError:
# python 2
from mock import sentinel, patch, Mock
from unittest.mock import sentinel, patch, Mock

from pytest_server_fixtures.serverclass.docker import DockerServer

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import pytest
from unittest.mock import sentinel, patch, Mock

try:
from unittest.mock import sentinel, patch, Mock
except ImportError:
# python 2
from mock import sentinel, patch, Mock
import pytest

from pytest_server_fixtures.serverclass.kubernetes import KubernetesServer


@pytest.mark.skip(reason="Need a way to run this test in Kubernetes")
@patch('pytest_server_fixtures.serverclass.docker.ServerClass.__init__')
def test_init(mock_init):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
try:
from unittest.mock import sentinel, patch, Mock
except ImportError:
# python 2
from mock import sentinel, patch, Mock
from unittest.mock import sentinel, patch, Mock

from pytest_server_fixtures import CONFIG
from pytest_server_fixtures.serverclass.thread import ThreadServer
Expand Down
6 changes: 1 addition & 5 deletions pytest-server-fixtures/tests/unit/test_server_unit.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
try:
from unittest.mock import create_autospec, sentinel, call, patch, Mock
except ImportError:
# python 2
from mock import create_autospec, sentinel, call, patch, Mock
from unittest.mock import create_autospec, sentinel, call, patch, Mock

from pytest_server_fixtures.base import TestServer as _TestServer # So that pytest doesnt think this is a test case

Expand Down
7 changes: 2 additions & 5 deletions pytest-server-fixtures/tests/unit/test_server_v2_unit.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
try:
from unittest.mock import create_autospec, sentinel, call, patch, Mock
except ImportError:
# python 2
from mock import create_autospec, sentinel, call, patch, Mock
from unittest.mock import create_autospec, sentinel, call, patch, Mock

from pytest_server_fixtures.base2 import TestServerV2 as _TestServerV2 # TODO: why as _TestServerV2?


def test_init():
with patch('pytest_shutil.workspace.Workspace.__init__', autospec=True) as init:
ts = _TestServerV2(cwd=sentinel.cwd,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# -*- coding: utf-8 -*-
try:
from unittest.mock import Mock
except ImportError:
from mock import Mock
from unittest.mock import Mock

from pytest_verbose_parametrize import pytest_generate_tests

Expand Down
6 changes: 1 addition & 5 deletions pytest-webdriver/tests/integration/test_integration.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
try:
from unittest.mock import Mock, sentinel, patch
except ImportError:
# python 2
from mock import Mock, sentinel, patch
from unittest.mock import Mock, sentinel, patch

import pytest
import selenium
Expand Down
6 changes: 1 addition & 5 deletions pytest-webdriver/tests/unit/test_webdriver.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
try:
from unittest.mock import Mock, sentinel, patch
except ImportError:
# python 2
from mock import Mock, sentinel, patch
from unittest.mock import Mock, sentinel, patch

import pytest
import selenium
Expand Down