diff --git a/tests/acceptance/cli_test.py b/tests/acceptance/cli_test.py index ee895b409..d0f7031f1 100644 --- a/tests/acceptance/cli_test.py +++ b/tests/acceptance/cli_test.py @@ -1090,8 +1090,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' @@ -1099,8 +1099,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' diff --git a/tests/integration/service_test.py b/tests/integration/service_test.py index cb6e5d318..734da5dfa 100644 --- a/tests/integration/service_test.py +++ b/tests/integration/service_test.py @@ -41,6 +41,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') @@ -989,7 +990,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 = { @@ -1093,6 +1094,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) diff --git a/tests/unit/cli_test.py b/tests/unit/cli_test.py index 317650cb5..fb0511f0a 100644 --- a/tests/unit/cli_test.py +++ b/tests/unit/cli_test.py @@ -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' ) diff --git a/tests/unit/config/config_test.py b/tests/unit/config/config_test.py index e5104f769..9303abaf1 100644 --- a/tests/unit/config/config_test.py +++ b/tests/unit/config/config_test.py @@ -59,6 +59,7 @@ def secret_sort(secrets): class ConfigTest(unittest.TestCase): + def test_load(self): service_dicts = config.load( build_config_details( @@ -1987,6 +1988,7 @@ class ConfigTest(unittest.TestCase): class NetworkModeTest(unittest.TestCase): + def test_network_mode_standard(self): config_data = config.load(build_config_details({ 'version': '2', @@ -2198,6 +2200,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' @@ -2295,10 +2298,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']) @@ -2443,6 +2447,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), @@ -2531,6 +2536,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'}, @@ -2561,6 +2567,7 @@ class MergeStringsOrListsTest(unittest.TestCase): class MergeLabelsTest(unittest.TestCase): + def test_empty(self): assert 'labels' not in config.merge_service_dicts({}, {}, DEFAULT_VERSION) @@ -2601,6 +2608,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 @@ -2643,6 +2651,7 @@ class MemoryOptionsTest(unittest.TestCase): class EnvTest(unittest.TestCase): + def test_parse_environment_as_list(self): environment = [ 'NORMAL=F1', @@ -2797,6 +2806,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') @@ -2988,9 +2998,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: @@ -3002,7 +3012,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): """ @@ -3234,7 +3244,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') @@ -3293,6 +3303,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" @@ -3319,6 +3330,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') @@ -3341,7 +3353,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( @@ -3349,11 +3361,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 = [