Skip to content

Commit

Permalink
use unittest.mock instead of mock package on py >= 3.4; see https://c…
Browse files Browse the repository at this point in the history
  • Loading branch information
jantman committed Jun 21, 2015
1 parent 19cdf68 commit 3ea80f4
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 9 deletions.
12 changes: 11 additions & 1 deletion awslimitchecker/tests/services/test_autoscaling.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,20 @@
################################################################################
"""

from mock import Mock, patch, call
import sys
from boto.ec2.autoscale import AutoScaleConnection
from awslimitchecker.services.autoscaling import _AutoscalingService

# https://code.google.com/p/mock/issues/detail?id=249
# py>=3.4 should use unittest.mock not the mock package on pypi
if (
sys.version_info[0] < 3 or
sys.version_info[0] == 3 and sys.version_info[1] < 4
):
from mock import patch, call, Mock, DEFAULT
else:
from unittest.mock import patch, call, Mock, DEFAULT


class Test_AutoscalingService(object):

Expand Down
11 changes: 10 additions & 1 deletion awslimitchecker/tests/services/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,22 @@
################################################################################
"""

from mock import Mock, patch, call
from awslimitchecker.services.base import _AwsService
from awslimitchecker.services import _services
from awslimitchecker.limit import AwsLimit
import pytest
import sys

# https://code.google.com/p/mock/issues/detail?id=249
# py>=3.4 should use unittest.mock not the mock package on pypi
if (
sys.version_info[0] < 3 or
sys.version_info[0] == 3 and sys.version_info[1] < 4
):
from mock import patch, call, Mock, DEFAULT
else:
from unittest.mock import patch, call, Mock, DEFAULT


class AwsServiceTester(_AwsService):
"""class to test non-abstract methods on base class"""
Expand Down
12 changes: 11 additions & 1 deletion awslimitchecker/tests/services/test_ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
################################################################################
"""

from mock import Mock, patch, call, DEFAULT
import sys
from boto.ec2.connection import EC2Connection
from boto.ec2.instance import Instance, Reservation
from boto.ec2.reservedinstance import ReservedInstance
Expand All @@ -48,6 +48,16 @@
from awslimitchecker.services.ec2 import _Ec2Service
from awslimitchecker.limit import AwsLimit

# https://code.google.com/p/mock/issues/detail?id=249
# py>=3.4 should use unittest.mock not the mock package on pypi
if (
sys.version_info[0] < 3 or
sys.version_info[0] == 3 and sys.version_info[1] < 4
):
from mock import patch, call, Mock, DEFAULT
else:
from unittest.mock import patch, call, Mock, DEFAULT


class Test_Ec2Service(object):

Expand Down
12 changes: 11 additions & 1 deletion awslimitchecker/tests/services/test_newservice.py.example
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,20 @@ Jason Antman <jason@jasonantman.com> <http://www.jasonantman.com>
################################################################################
"""

from mock import Mock, patch, call
import sys
from boto.XXnewserviceXX.connection import XXNewServiceXXConnection
from awslimitchecker.services.XXnewserviceXX import _XXNewServiceXXService

# https://code.google.com/p/mock/issues/detail?id=249
# py>=3.4 should use unittest.mock not the mock package on pypi
if (
sys.version_info[0] < 3 or
sys.version_info[0] == 3 and sys.version_info[1] < 4
):
from mock import patch, call, Mock, DEFAULT
else:
from unittest.mock import patch, call, Mock, DEFAULT


class Test_XXNewServiceXXService(object):

Expand Down
12 changes: 11 additions & 1 deletion awslimitchecker/tests/services/test_vpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
################################################################################
"""

from mock import Mock, patch, call
import sys

from boto.vpc import VPCConnection
from boto.vpc.vpc import VPC
Expand All @@ -47,6 +47,16 @@

from awslimitchecker.services.vpc import _VpcService

# https://code.google.com/p/mock/issues/detail?id=249
# py>=3.4 should use unittest.mock not the mock package on pypi
if (
sys.version_info[0] < 3 or
sys.version_info[0] == 3 and sys.version_info[1] < 4
):
from mock import patch, call, Mock, DEFAULT
else:
from unittest.mock import patch, call, Mock, DEFAULT


class Test_VpcService(object):

Expand Down
14 changes: 13 additions & 1 deletion awslimitchecker/tests/test_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
################################################################################
"""

from mock import Mock, patch, call, DEFAULT
import sys

from awslimitchecker.services.base import _AwsService
from awslimitchecker.checker import AwsLimitChecker
from awslimitchecker.version import _get_version, _get_project_url
Expand All @@ -46,6 +47,17 @@
from .support import sample_limits


# https://code.google.com/p/mock/issues/detail?id=249
# py>=3.4 should use unittest.mock not the mock package on pypi
if (
sys.version_info[0] < 3 or
sys.version_info[0] == 3 and sys.version_info[1] < 4
):
from mock import patch, call, Mock, DEFAULT
else:
from unittest.mock import patch, call, Mock, DEFAULT


class TestAwsLimitChecker(object):

def setup(self):
Expand Down
11 changes: 10 additions & 1 deletion awslimitchecker/tests/test_limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,21 @@
################################################################################
"""

from mock import Mock, patch, call
import pytest
import sys
from awslimitchecker.limit import AwsLimit, AwsLimitUsage
from awslimitchecker.services.base import _AwsService

# https://code.google.com/p/mock/issues/detail?id=249
# py>=3.4 should use unittest.mock not the mock package on pypi
if (
sys.version_info[0] < 3 or
sys.version_info[0] == 3 and sys.version_info[1] < 4
):
from mock import patch, call, Mock, DEFAULT
else:
from unittest.mock import patch, call, Mock, DEFAULT


class TestAwsLimit(object):

Expand Down
11 changes: 10 additions & 1 deletion awslimitchecker/tests/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import sys
import logging
import json
from mock import patch, call, Mock
import termcolor

from awslimitchecker.runner import Runner, console_entry_point
Expand All @@ -52,6 +51,16 @@
from awslimitchecker.utils import StoreKeyValuePair
from .support import sample_limits

# https://code.google.com/p/mock/issues/detail?id=249
# py>=3.4 should use unittest.mock not the mock package on pypi
if (
sys.version_info[0] < 3 or
sys.version_info[0] == 3 and sys.version_info[1] < 4
):
from mock import patch, call, Mock, DEFAULT
else:
from unittest.mock import patch, call, Mock, DEFAULT


def red(s):
return termcolor.colored(s, 'red')
Expand Down
12 changes: 11 additions & 1 deletion awslimitchecker/tests/test_trustedadvisor.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,22 @@
##############################################################################
"""

from mock import patch, Mock, call
import sys
from boto.support.layer1 import SupportConnection
from boto.regioninfo import RegionInfo
from awslimitchecker.trustedadvisor import TrustedAdvisor
from awslimitchecker.services.base import _AwsService

# https://code.google.com/p/mock/issues/detail?id=249
# py>=3.4 should use unittest.mock not the mock package on pypi
if (
sys.version_info[0] < 3 or
sys.version_info[0] == 3 and sys.version_info[1] < 4
):
from mock import patch, call, Mock, DEFAULT
else:
from unittest.mock import patch, call, Mock, DEFAULT


pb = 'awslimitchecker.trustedadvisor.TrustedAdvisor'

Expand Down

0 comments on commit 3ea80f4

Please sign in to comment.