diff --git a/requirements-dev.txt b/requirements-dev.txt index f905f2d2..2a39d29f 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,6 +1,6 @@ # testing pytest -mock +mock; python_version < 3.3 flexmock parameterized tox diff --git a/tests/support/mock.py b/tests/support/mock.py new file mode 100644 index 00000000..fa8cbde7 --- /dev/null +++ b/tests/support/mock.py @@ -0,0 +1,6 @@ +import sys + +if sys.version_info > (3, 3): + from unittest.mock import * +else: + from mock import * diff --git a/tests/test_dev_tools/test_make_scripts/test_list_of_created_scripts.py b/tests/test_dev_tools/test_make_scripts/test_list_of_created_scripts.py index 2e8b1cbe..89097025 100644 --- a/tests/test_dev_tools/test_make_scripts/test_list_of_created_scripts.py +++ b/tests/test_dev_tools/test_make_scripts/test_list_of_created_scripts.py @@ -1,4 +1,4 @@ -from mock import Mock +from tests.support.mock import Mock from tests.support.make_scripts import Scripts from tests.support.make_scripts import script_path_without_base_dir_for diff --git a/tests/test_dev_tools/test_make_scripts/test_make_script.py b/tests/test_dev_tools/test_make_scripts/test_make_script.py index a43545d7..f3667a57 100644 --- a/tests/test_dev_tools/test_make_scripts/test_make_script.py +++ b/tests/test_dev_tools/test_make_scripts/test_make_script.py @@ -1,7 +1,7 @@ from textwrap import dedent -import mock -from mock import Mock +from tests.support import mock +from tests.support.mock import Mock from tests.support.make_scripts import Scripts from tests.support.make_scripts import script_path_for @@ -43,5 +43,3 @@ def test_the_script_should_call_the_right_function_from_the_right_module(self): assert expected == contents, ("Expected:\n---\n%s---\n" "Actual :\n---\n%s---\n" % (expected, contents)) - - diff --git a/tests/test_empty/cmd/test_empty_cmd.py b/tests/test_empty/cmd/test_empty_cmd.py index 35d572b2..2dc0825f 100644 --- a/tests/test_empty/cmd/test_empty_cmd.py +++ b/tests/test_empty/cmd/test_empty_cmd.py @@ -2,7 +2,7 @@ import unittest from typing import cast -from mock import call +from tests.support.mock import Mock, call from six import StringIO from tests.support.fakes.stub_volume_of import StubVolumeOf @@ -14,7 +14,6 @@ from trashcli.fstab.volume_listing import VolumesListing from trashcli.lib.dir_reader import DirReader from trashcli.trash_dirs_scanner import TopTrashDirRules -from mock import Mock class TestTrashEmptyCmdFs(unittest.TestCase): def setUp(self): diff --git a/tests/test_empty/cmd/test_empty_cmd_fs.py b/tests/test_empty/cmd/test_empty_cmd_fs.py index 36202e2b..ec4bbf3d 100644 --- a/tests/test_empty/cmd/test_empty_cmd_fs.py +++ b/tests/test_empty/cmd/test_empty_cmd_fs.py @@ -2,7 +2,7 @@ import unittest import pytest -from mock import Mock +from tests.support.mock import Mock from six import StringIO from tests.support.fakes.stub_volume_of import StubVolumeOf diff --git a/tests/test_empty/cmd/test_empty_cmd_with_multiple_volumes_fs.py b/tests/test_empty/cmd/test_empty_cmd_with_multiple_volumes_fs.py index 1e2039e7..ac5961a6 100644 --- a/tests/test_empty/cmd/test_empty_cmd_with_multiple_volumes_fs.py +++ b/tests/test_empty/cmd/test_empty_cmd_with_multiple_volumes_fs.py @@ -2,7 +2,7 @@ import os import unittest -from mock import Mock +from tests.support.mock import Mock from six import StringIO from tests.support.fakes.stub_volume_of import StubVolumeOf diff --git a/tests/test_empty/components/test_clock.py b/tests/test_empty/components/test_clock.py index 13e388ce..b4e327ac 100644 --- a/tests/test_empty/components/test_clock.py +++ b/tests/test_empty/components/test_clock.py @@ -1,7 +1,7 @@ import datetime import unittest -from mock import Mock, call +from tests.support.mock import Mock, call from trashcli.empty.clock import Clock diff --git a/tests/test_empty/components/test_guard.py b/tests/test_empty/components/test_guard.py index 82e82db7..2afd49e9 100644 --- a/tests/test_empty/components/test_guard.py +++ b/tests/test_empty/components/test_guard.py @@ -1,6 +1,6 @@ import unittest -from mock import Mock, call +from tests.support.mock import Mock, call from trashcli.empty.guard import Guard, UserIntention diff --git a/tests/test_empty/components/test_user.py b/tests/test_empty/components/test_user.py index 424dda92..0fa2ad8b 100644 --- a/tests/test_empty/components/test_user.py +++ b/tests/test_empty/components/test_user.py @@ -1,6 +1,6 @@ import unittest -from mock import Mock, call +from tests.support.mock import Mock, call from trashcli.empty.user import User from trashcli.lib.my_input import HardCodedInput diff --git a/tests/test_put/components/test_trash_directories_finder.py b/tests/test_put/components/test_trash_directories_finder.py index 01417099..43fc8862 100644 --- a/tests/test_put/components/test_trash_directories_finder.py +++ b/tests/test_put/components/test_trash_directories_finder.py @@ -1,6 +1,6 @@ import unittest -from mock import Mock +from tests.support.mock import Mock from trashcli.put.core.candidate import Candidate from trashcli.put.core.check_type import NoCheck, TopTrashDirCheck diff --git a/tests/test_put/components/test_trash_put_reporter.py b/tests/test_put/components/test_trash_put_reporter.py index 6e41d424..8febeb69 100644 --- a/tests/test_put/components/test_trash_put_reporter.py +++ b/tests/test_put/components/test_trash_put_reporter.py @@ -1,4 +1,4 @@ -from mock import Mock +from tests.support.mock import Mock from six import StringIO from trashcli.put.describer import Describer diff --git a/tests/test_restore/cmd/test_listing_in_restore_cmd.py b/tests/test_restore/cmd/test_listing_in_restore_cmd.py index 895dedd6..254ca5d5 100644 --- a/tests/test_restore/cmd/test_listing_in_restore_cmd.py +++ b/tests/test_restore/cmd/test_listing_in_restore_cmd.py @@ -1,6 +1,6 @@ import unittest -from mock import Mock +from tests.support.mock import Mock from six import StringIO from trashcli.restore.file_system import FakeReadCwd diff --git a/tests/test_restore/cmd/test_restore2.py b/tests/test_restore/cmd/test_restore2.py index b4737d27..09d4c765 100644 --- a/tests/test_restore/cmd/test_restore2.py +++ b/tests/test_restore/cmd/test_restore2.py @@ -1,7 +1,7 @@ import datetime import unittest -from mock import Mock, call +from tests.support.mock import Mock, call from tests.support.restore.fake_restore_fs import FakeRestoreFs from tests.support.restore.restore_user import RestoreUser diff --git a/tests/test_restore/cmd/test_trashed_file_restore_integration.py b/tests/test_restore/cmd/test_trashed_file_restore_integration.py index e5f5794d..58ba62c3 100644 --- a/tests/test_restore/cmd/test_trashed_file_restore_integration.py +++ b/tests/test_restore/cmd/test_trashed_file_restore_integration.py @@ -1,7 +1,7 @@ import os import unittest -from mock import Mock +from tests.support.mock import Mock from six import StringIO from tests.support.files import make_empty_file diff --git a/tests/test_restore/components/collaborators/test_restore_asking_the_user.py b/tests/test_restore/components/collaborators/test_restore_asking_the_user.py index ddcfba5e..db291464 100644 --- a/tests/test_restore/components/collaborators/test_restore_asking_the_user.py +++ b/tests/test_restore/components/collaborators/test_restore_asking_the_user.py @@ -1,6 +1,6 @@ import unittest -from mock import Mock, call +from tests.support.mock import Mock, call from trashcli.lib.my_input import HardCodedInput from trashcli.restore.output_event import Quit diff --git a/tests/test_restore/components/collaborators/test_trash_directories2.py b/tests/test_restore/components/collaborators/test_trash_directories2.py index 55b45cb1..9969a187 100644 --- a/tests/test_restore/components/collaborators/test_trash_directories2.py +++ b/tests/test_restore/components/collaborators/test_trash_directories2.py @@ -1,7 +1,7 @@ import unittest import pytest -from mock import Mock, call +from tests.support.mock import Mock, call from tests.support.fakes.stub_volume_of import StubVolumeOf from trashcli.restore.trash_directories import TrashDirectories2 diff --git a/tests/test_restore/components/trashed_files/test_trashed_files_integration.py b/tests/test_restore/components/trashed_files/test_trashed_files_integration.py index ddbaf95a..73344cfd 100644 --- a/tests/test_restore/components/trashed_files/test_trashed_files_integration.py +++ b/tests/test_restore/components/trashed_files/test_trashed_files_integration.py @@ -1,7 +1,7 @@ import datetime import unittest -from mock import Mock +from tests.support.mock import Mock from tests.support.files import make_file, require_empty_dir from tests.support.dirs.remove_dir_if_exists import remove_dir_if_exists diff --git a/tests/test_rm/cmd/test_trash_rm.py b/tests/test_rm/cmd/test_trash_rm.py index 3da90ee1..6373be56 100644 --- a/tests/test_rm/cmd/test_trash_rm.py +++ b/tests/test_rm/cmd/test_trash_rm.py @@ -2,7 +2,7 @@ from six import StringIO -from mock import Mock +from tests.support.mock import Mock from tests.support.asserts import assert_starts_with from trashcli.rm.rm_cmd import RmCmd diff --git a/tests/test_trashcli_lib/test_parsing_trashinfo_contents.py b/tests/test_trashcli_lib/test_parsing_trashinfo_contents.py index 0e01da33..e6fd9563 100644 --- a/tests/test_trashcli_lib/test_parsing_trashinfo_contents.py +++ b/tests/test_trashcli_lib/test_parsing_trashinfo_contents.py @@ -2,7 +2,7 @@ import unittest from datetime import datetime -from mock import MagicMock +from tests.support.mock import MagicMock from trashcli.parse_trashinfo.parse_path import parse_path from trashcli.parse_trashinfo.parse_trashinfo import ParseTrashInfo diff --git a/tests/test_trashcli_lib/trash_dir_scanner/test_top_trash_dir_rules.py b/tests/test_trashcli_lib/trash_dir_scanner/test_top_trash_dir_rules.py index 4a0da1f9..72a058d8 100644 --- a/tests/test_trashcli_lib/trash_dir_scanner/test_top_trash_dir_rules.py +++ b/tests/test_trashcli_lib/trash_dir_scanner/test_top_trash_dir_rules.py @@ -1,6 +1,6 @@ import unittest -from mock import Mock, call +from tests.support.mock import Mock, call from trashcli.trash_dirs_scanner import ( TopTrashDirRules, top_trash_dir_does_not_exist, diff --git a/tests/test_trashcli_lib/trash_dir_scanner/test_trash_dir_scanner.py b/tests/test_trashcli_lib/trash_dir_scanner/test_trash_dir_scanner.py index f5eff341..488e205f 100644 --- a/tests/test_trashcli_lib/trash_dir_scanner/test_trash_dir_scanner.py +++ b/tests/test_trashcli_lib/trash_dir_scanner/test_trash_dir_scanner.py @@ -1,6 +1,6 @@ import unittest -from mock import Mock +from tests.support.mock import Mock from trashcli.fstab.volume_listing import VolumesListing from trashcli.lib.dir_checker import DirChecker