Skip to content
New issue

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

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

Already on GitHub? # to your account

Use unittest.mock where possible #850

Merged
merged 1 commit into from
Jan 26, 2022
Merged
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
5 changes: 4 additions & 1 deletion test/test_rosdep_alpine.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@

import os
import traceback
from mock import Mock, patch
try:
from unittest.mock import Mock, patch
except ImportError:
from mock import Mock, patch

import rospkg.os_detect

Expand Down
5 changes: 4 additions & 1 deletion test/test_rosdep_arch.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@

import os
import traceback
from mock import Mock, patch
try:
from unittest.mock import Mock, patch
except ImportError:
from mock import Mock, patch


def get_test_dir():
Expand Down
5 changes: 4 additions & 1 deletion test/test_rosdep_cygwin.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@

import os
import traceback
from mock import patch
try:
from unittest.mock import patch
except ImportError:
from mock import patch


def get_test_dir():
Expand Down
5 changes: 4 additions & 1 deletion test/test_rosdep_debian.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@

import os
import traceback
from mock import Mock, patch, call
try:
from unittest.mock import Mock, patch, call
except ImportError:
from mock import Mock, patch, call


def get_test_dir():
Expand Down
5 changes: 4 additions & 1 deletion test/test_rosdep_freebsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@

import os
import traceback
from mock import patch, Mock
try:
from unittest.mock import patch, Mock
except ImportError:
from mock import patch, Mock


def get_test_dir():
Expand Down
5 changes: 4 additions & 1 deletion test/test_rosdep_gem.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@

import os
import traceback
from mock import Mock, patch
try:
from unittest.mock import Mock, patch
except ImportError:
from mock import Mock, patch


def get_test_dir():
Expand Down
5 changes: 4 additions & 1 deletion test/test_rosdep_gentoo.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@

import os
import traceback
from mock import Mock, patch
try:
from unittest.mock import Mock, patch
except ImportError:
from mock import Mock, patch

import rospkg.os_detect

Expand Down
7 changes: 4 additions & 3 deletions test/test_rosdep_installers.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@
from __future__ import print_function

from contextlib import contextmanager
from mock import patch
try:
from unittest.mock import Mock, patch
except ImportError:
from mock import Mock, patch
import os
import sys
try:
Expand Down Expand Up @@ -117,7 +120,6 @@ def test_InstallerContext_os_version_and_name():
context.set_os_override(*val)
assert val == context.get_os_name_and_version()

from mock import Mock
os_detect_mock = Mock(spec=OsDetect)
os_detect_mock.get_name.return_value = 'fakeos'
os_detect_mock.get_version.return_value = 'fakeos-version'
Expand Down Expand Up @@ -559,7 +561,6 @@ def get_packages_to_install(*args):
assert 'apt' in str(e)

# annoying mock to test generally impossible error condition
from mock import Mock
lookup = Mock(spec=RosdepLookup)
lookup.resolve_all.return_value = ([('bad-key', ['stuff'])], [])

Expand Down
5 changes: 4 additions & 1 deletion test/test_rosdep_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

from mock import Mock
try:
from unittest.mock import Mock
except ImportError:
from mock import Mock


def test_RosdepLoader():
Expand Down
6 changes: 4 additions & 2 deletions test/test_rosdep_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@

import unittest

from mock import patch
from mock import DEFAULT
try:
from unittest.mock import DEFAULT, patch
except ImportError:
from mock import DEFAULT, patch

from rosdep2 import main
from rosdep2.ament_packages import AMENT_PREFIX_PATH_ENV_VAR
Expand Down
5 changes: 4 additions & 1 deletion test/test_rosdep_npm.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@

import os
import traceback
from mock import Mock, patch
try:
from unittest.mock import Mock, patch
except ImportError:
from mock import Mock, patch


def get_test_dir():
Expand Down
5 changes: 4 additions & 1 deletion test/test_rosdep_opensuse.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@

import os
import traceback
from mock import patch
try:
from unittest.mock import patch
except ImportError:
from mock import patch


def get_test_dir():
Expand Down
7 changes: 4 additions & 3 deletions test/test_rosdep_osx.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@
import os
import traceback

from mock import call
from mock import Mock
from mock import patch
try:
from unittest.mock import call, Mock, patch
except ImportError:
from mock import call, Mock, patch


def get_test_dir():
Expand Down
5 changes: 4 additions & 1 deletion test/test_rosdep_pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
import os
import sys
import traceback
from mock import Mock, patch
try:
from unittest.mock import Mock, patch
except ImportError:
from mock import Mock, patch


def get_test_dir():
Expand Down
5 changes: 4 additions & 1 deletion test/test_rosdep_redhat.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@

import os
import traceback
from mock import patch, Mock
try:
from unittest.mock import patch, Mock
except ImportError:
from mock import patch, Mock


def get_test_dir():
Expand Down
5 changes: 4 additions & 1 deletion test/test_rosdep_rospkg_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
import os
import yaml

from mock import Mock
try:
from unittest.mock import Mock
except ImportError:
from mock import Mock
from rospkg import RosPack, RosStack


Expand Down
5 changes: 4 additions & 1 deletion test/test_rosdep_slackware.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@

import os
import traceback
from mock import Mock, patch
try:
from unittest.mock import Mock, patch
except ImportError:
from mock import Mock, patch

import rospkg.os_detect

Expand Down