Replace assertEquals with assertEqual since the former is getting deprecated soon. Also, fix pep8 E309.

Signed-off-by: Milind Shakya <sh.milind@gmail.com>
This commit is contained in:
Milind Shakya 2016-06-02 16:27:47 -07:00
parent 17b219454f
commit 11a2eab549
4 changed files with 34 additions and 20 deletions

View File

@ -842,8 +842,8 @@ class CLITestCase(DockerClientTestCase):
self.assertEqual(len(self.project.containers()), 1)
stdout, stderr = self.dispatch(['exec', '-T', 'console', 'ls', '-1d', '/'])
self.assertEquals(stdout, "/\n")
self.assertEquals(stderr, "")
self.assertEqual(stdout, "/\n")
self.assertEqual(stderr, "")
def test_exec_custom_user(self):
self.base_dir = 'tests/fixtures/links-composefile'
@ -851,8 +851,8 @@ class CLITestCase(DockerClientTestCase):
self.assertEqual(len(self.project.containers()), 1)
stdout, stderr = self.dispatch(['exec', '-T', '--user=operator', 'console', 'whoami'])
self.assertEquals(stdout, "operator\n")
self.assertEquals(stderr, "")
self.assertEqual(stdout, "operator\n")
self.assertEqual(stderr, "")
def test_run_service_without_links(self):
self.base_dir = 'tests/fixtures/links-composefile'

View File

@ -39,6 +39,7 @@ def create_and_start_container(service, **override_options):
class ServiceTest(DockerClientTestCase):
def test_containers(self):
foo = self.create_service('foo')
bar = self.create_service('bar')
@ -940,7 +941,7 @@ class ServiceTest(DockerClientTestCase):
with mock.patch.object(self.client, '_version', '1.20'):
service = self.create_service('web')
service_config = service._get_container_host_config({})
self.assertEquals(service_config['NetworkMode'], 'default')
self.assertEqual(service_config['NetworkMode'], 'default')
def test_labels(self):
labels_dict = {
@ -1044,6 +1045,7 @@ def converge(service, strategy=ConvergenceStrategy.changed):
class ConfigHashTest(DockerClientTestCase):
def test_no_config_hash_when_one_off(self):
web = self.create_service('web')
container = web.create_container(one_off=True)

View File

@ -29,36 +29,36 @@ class CLITestCase(unittest.TestCase):
test_dir = py._path.local.LocalPath('tests/fixtures/simple-composefile')
with test_dir.as_cwd():
project_name = get_project_name('.')
self.assertEquals('simplecomposefile', project_name)
self.assertEqual('simplecomposefile', project_name)
def test_project_name_with_explicit_base_dir(self):
base_dir = 'tests/fixtures/simple-composefile'
project_name = get_project_name(base_dir)
self.assertEquals('simplecomposefile', project_name)
self.assertEqual('simplecomposefile', project_name)
def test_project_name_with_explicit_uppercase_base_dir(self):
base_dir = 'tests/fixtures/UpperCaseDir'
project_name = get_project_name(base_dir)
self.assertEquals('uppercasedir', project_name)
self.assertEqual('uppercasedir', project_name)
def test_project_name_with_explicit_project_name(self):
name = 'explicit-project-name'
project_name = get_project_name(None, project_name=name)
self.assertEquals('explicitprojectname', project_name)
self.assertEqual('explicitprojectname', project_name)
@mock.patch.dict(os.environ)
def test_project_name_from_environment_new_var(self):
name = 'namefromenv'
os.environ['COMPOSE_PROJECT_NAME'] = name
project_name = get_project_name(None)
self.assertEquals(project_name, name)
self.assertEqual(project_name, name)
def test_project_name_with_empty_environment_var(self):
base_dir = 'tests/fixtures/simple-composefile'
with mock.patch.dict(os.environ):
os.environ['COMPOSE_PROJECT_NAME'] = ''
project_name = get_project_name(base_dir)
self.assertEquals('simplecomposefile', project_name)
self.assertEqual('simplecomposefile', project_name)
@mock.patch.dict(os.environ)
def test_project_name_with_environment_file(self):
@ -158,7 +158,7 @@ class CLITestCase(unittest.TestCase):
'--workdir': None,
})
self.assertEquals(
self.assertEqual(
mock_client.create_host_config.call_args[1]['restart_policy']['Name'],
'always'
)

View File

@ -48,6 +48,7 @@ def service_sort(services):
class ConfigTest(unittest.TestCase):
def test_load(self):
service_dicts = config.load(
build_config_details(
@ -1384,6 +1385,7 @@ class ConfigTest(unittest.TestCase):
class NetworkModeTest(unittest.TestCase):
def test_network_mode_standard(self):
config_data = config.load(build_config_details({
'version': '2',
@ -1595,6 +1597,7 @@ class PortsTest(unittest.TestCase):
class InterpolationTest(unittest.TestCase):
@mock.patch.dict(os.environ)
def test_config_file_with_environment_file(self):
project_dir = 'tests/fixtures/default-env-file'
@ -1692,10 +1695,11 @@ class InterpolationTest(unittest.TestCase):
None,
)
).services[0]
self.assertEquals(service_dict['environment']['POSTGRES_PASSWORD'], '')
self.assertEqual(service_dict['environment']['POSTGRES_PASSWORD'], '')
class VolumeConfigTest(unittest.TestCase):
def test_no_binding(self):
d = make_service_dict('foo', {'build': '.', 'volumes': ['/data']}, working_dir='.')
self.assertEqual(d['volumes'], ['/data'])
@ -1840,6 +1844,7 @@ class MergeDevicesTest(unittest.TestCase, MergePathMappingTest):
class BuildOrImageMergeTest(unittest.TestCase):
def test_merge_build_or_image_no_override(self):
self.assertEqual(
config.merge_service_dicts({'build': '.'}, {}, V1),
@ -1928,6 +1933,7 @@ class MergeNetworksTest(unittest.TestCase, MergeListsTest):
class MergeStringsOrListsTest(unittest.TestCase):
def test_no_override(self):
service_dict = config.merge_service_dicts(
{'dns': '8.8.8.8'},
@ -1958,6 +1964,7 @@ class MergeStringsOrListsTest(unittest.TestCase):
class MergeLabelsTest(unittest.TestCase):
def test_empty(self):
assert 'labels' not in config.merge_service_dicts({}, {}, DEFAULT_VERSION)
@ -1998,6 +2005,7 @@ class MergeLabelsTest(unittest.TestCase):
class MemoryOptionsTest(unittest.TestCase):
def test_validation_fails_with_just_memswap_limit(self):
"""
When you set a 'memswap_limit' it is invalid config unless you also set
@ -2040,6 +2048,7 @@ class MemoryOptionsTest(unittest.TestCase):
class EnvTest(unittest.TestCase):
def test_parse_environment_as_list(self):
environment = [
'NORMAL=F1',
@ -2185,6 +2194,7 @@ def load_from_filename(filename):
class ExtendsTest(unittest.TestCase):
def test_extends(self):
service_dicts = load_from_filename('tests/fixtures/extends/docker-compose.yml')
@ -2376,9 +2386,9 @@ class ExtendsTest(unittest.TestCase):
)
).services
self.assertEquals(len(service), 1)
self.assertEqual(len(service), 1)
self.assertIsInstance(service[0], dict)
self.assertEquals(service[0]['command'], "/bin/true")
self.assertEqual(service[0]['command'], "/bin/true")
def test_extended_service_with_invalid_config(self):
with pytest.raises(ConfigurationError) as exc:
@ -2390,7 +2400,7 @@ class ExtendsTest(unittest.TestCase):
def test_extended_service_with_valid_config(self):
service = load_from_filename('tests/fixtures/extends/service-with-valid-composite-extends.yml')
self.assertEquals(service[0]['command'], "top")
self.assertEqual(service[0]['command'], "top")
def test_extends_file_defaults_to_self(self):
"""
@ -2622,7 +2632,7 @@ class ExtendsTest(unittest.TestCase):
""")
service = load_from_filename(str(tmpdir.join('docker-compose.yml')))
self.assertEquals(service[0]['command'], "top")
self.assertEqual(service[0]['command'], "top")
def test_extends_with_depends_on(self):
tmpdir = py.test.ensuretemp('test_extends_with_defined_version')
@ -2666,6 +2676,7 @@ class ExpandPathTest(unittest.TestCase):
class VolumePathTest(unittest.TestCase):
def test_split_path_mapping_with_windows_path(self):
host_path = "c:\\Users\\msamblanet\\Documents\\anvil\\connect\\config"
windows_volume_path = host_path + ":/opt/connect/config:ro"
@ -2685,6 +2696,7 @@ class VolumePathTest(unittest.TestCase):
@pytest.mark.xfail(IS_WINDOWS_PLATFORM, reason='paths use slash')
class BuildPathTest(unittest.TestCase):
def setUp(self):
self.abs_context_path = os.path.join(os.getcwd(), 'tests/fixtures/build-ctx')
@ -2707,7 +2719,7 @@ class BuildPathTest(unittest.TestCase):
{'build': relative_build_path},
working_dir='tests/fixtures/build-path'
)
self.assertEquals(service_dict['build'], self.abs_context_path)
self.assertEqual(service_dict['build'], self.abs_context_path)
def test_absolute_path(self):
service_dict = make_service_dict(
@ -2715,11 +2727,11 @@ class BuildPathTest(unittest.TestCase):
{'build': self.abs_context_path},
working_dir='tests/fixtures/build-path'
)
self.assertEquals(service_dict['build'], self.abs_context_path)
self.assertEqual(service_dict['build'], self.abs_context_path)
def test_from_file(self):
service_dict = load_from_filename('tests/fixtures/build-path/docker-compose.yml')
self.assertEquals(service_dict, [{'name': 'foo', 'build': {'context': self.abs_context_path}}])
self.assertEqual(service_dict, [{'name': 'foo', 'build': {'context': self.abs_context_path}}])
def test_valid_url_in_build_path(self):
valid_urls = [