mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 09:40:20 +00:00
Merge pull request #55535 from s0undt3ch/features/pytest-staged-26
[PyTest #26] Python 2.6 is no longer supported
This commit is contained in:
commit
0e5f8e8561
2 changed files with 15 additions and 77 deletions
|
@ -5,7 +5,6 @@ Integration tests for the docker_container states
|
|||
|
||||
# Import Python Libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import functools
|
||||
import random
|
||||
import string
|
||||
import sys
|
||||
|
@ -30,30 +29,19 @@ def _random_name(prefix=''):
|
|||
return ret
|
||||
|
||||
|
||||
def with_random_name(func):
|
||||
'''
|
||||
generate a randomized name for a container
|
||||
'''
|
||||
@functools.wraps(func)
|
||||
def wrapper(self, *args, **kwargs):
|
||||
name = _random_name(prefix='salt_')
|
||||
return func(self, _random_name(prefix='salt_test_'), *args, **kwargs)
|
||||
return wrapper
|
||||
|
||||
|
||||
@destructiveTest
|
||||
@skipIf(not salt.utils.path.which('dockerd'), 'Docker not installed')
|
||||
class DockerCallTestCase(ModuleCase, SaltReturnAssertsMixin):
|
||||
'''
|
||||
Test docker_container states
|
||||
'''
|
||||
@with_random_name
|
||||
def setUp(self, name): # pylint: disable=arguments-differ
|
||||
|
||||
def setUp(self):
|
||||
'''
|
||||
setup docker.call tests
|
||||
'''
|
||||
# Create temp dir
|
||||
self.random_name = name
|
||||
self.random_name = _random_name(prefix='salt_test_')
|
||||
self.image_tag = sys.version_info[0]
|
||||
|
||||
self.run_state('docker_image.present',
|
||||
|
|
|
@ -26,6 +26,18 @@ from __future__ import absolute_import, print_function, unicode_literals
|
|||
import os
|
||||
import sys
|
||||
import logging
|
||||
from unittest import (
|
||||
TestLoader as _TestLoader,
|
||||
TextTestRunner as _TextTestRunner,
|
||||
TestCase as _TestCase,
|
||||
expectedFailure,
|
||||
TestSuite as _TestSuite,
|
||||
skip,
|
||||
skipIf as _skipIf,
|
||||
TestResult,
|
||||
TextTestResult as _TextTestResult
|
||||
)
|
||||
from unittest.case import _id, SkipTest
|
||||
from salt.ext import six
|
||||
try:
|
||||
import psutil
|
||||
|
@ -51,68 +63,6 @@ Donec venenatis elementum arcu at rhoncus. Nunc pharetra erat in lacinia convall
|
|||
eu mauris sit amet convallis. Morbi vulputate vel odio non laoreet. Nullam in suscipit tellus.
|
||||
Sed quis posuere urna.'''
|
||||
|
||||
# support python < 2.7 via unittest2
|
||||
if sys.version_info < (2, 7):
|
||||
try:
|
||||
# pylint: disable=import-error
|
||||
from unittest2 import (
|
||||
TestLoader as __TestLoader,
|
||||
TextTestRunner as __TextTestRunner,
|
||||
TestCase as __TestCase,
|
||||
expectedFailure,
|
||||
TestSuite as __TestSuite,
|
||||
skip,
|
||||
skipIf as _skipIf,
|
||||
TestResult as _TestResult,
|
||||
TextTestResult as __TextTestResult
|
||||
)
|
||||
from unittest2.case import _id, SkipTest
|
||||
# pylint: enable=import-error
|
||||
|
||||
class NewStyleClassMixin(object):
|
||||
'''
|
||||
Simple new style class to make pylint shut up!
|
||||
|
||||
And also to avoid errors like:
|
||||
|
||||
'Cannot create a consistent method resolution order (MRO) for bases'
|
||||
'''
|
||||
|
||||
class _TestLoader(__TestLoader, NewStyleClassMixin):
|
||||
pass
|
||||
|
||||
class _TextTestRunner(__TextTestRunner, NewStyleClassMixin):
|
||||
pass
|
||||
|
||||
class _TestCase(__TestCase, NewStyleClassMixin):
|
||||
pass
|
||||
|
||||
class _TestSuite(__TestSuite, NewStyleClassMixin):
|
||||
pass
|
||||
|
||||
class TestResult(_TestResult, NewStyleClassMixin):
|
||||
pass
|
||||
|
||||
class _TextTestResult(__TextTestResult, NewStyleClassMixin):
|
||||
pass
|
||||
|
||||
except ImportError:
|
||||
raise SystemExit('You need to install unittest2 to run the salt tests')
|
||||
else:
|
||||
from unittest import (
|
||||
TestLoader as _TestLoader,
|
||||
TextTestRunner as _TextTestRunner,
|
||||
TestCase as _TestCase,
|
||||
expectedFailure,
|
||||
TestSuite as _TestSuite,
|
||||
skip,
|
||||
skipIf as _skipIf,
|
||||
TestResult,
|
||||
TextTestResult as _TextTestResult,
|
||||
SkipTest,
|
||||
)
|
||||
from unittest.case import _id, SkipTest
|
||||
|
||||
|
||||
class TestSuite(_TestSuite):
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue