Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support PyYAML up to 5.x version #6623

Merged
merged 1 commit into from
Jan 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ paramiko==2.6.0
pypiwin32==219; sys_platform == 'win32' and python_version < '3.6'
pypiwin32==223; sys_platform == 'win32' and python_version >= '3.6'
PySocks==1.7.1
PyYAML==4.2b1
PyYAML==5.3
requests==2.22.0
six==1.12.0
subprocess32==3.5.4; python_version < '3.2'
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def find_version(*file_paths):
install_requires = [
'cached-property >= 1.2.0, < 2',
'docopt >= 0.6.1, < 1',
'PyYAML >= 3.10, < 5',
'PyYAML >= 3.10, < 6',
'requests >= 2.20.0, < 3',
'texttable >= 0.9.0, < 2',
'websocket-client >= 0.32.0, < 1',
Expand Down
28 changes: 14 additions & 14 deletions tests/acceptance/cli_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def test_config_default(self):
# assert there are no python objects encoded in the output
assert '!!' not in result.stdout

output = yaml.load(result.stdout)
output = yaml.safe_load(result.stdout)
expected = {
'version': '2.0',
'volumes': {'data': {'driver': 'local'}},
Expand All @@ -294,7 +294,7 @@ def test_config_default(self):
def test_config_restart(self):
self.base_dir = 'tests/fixtures/restart'
result = self.dispatch(['config'])
assert yaml.load(result.stdout) == {
assert yaml.safe_load(result.stdout) == {
'version': '2.0',
'services': {
'never': {
Expand Down Expand Up @@ -323,7 +323,7 @@ def test_config_restart(self):
def test_config_external_network(self):
self.base_dir = 'tests/fixtures/networks'
result = self.dispatch(['-f', 'external-networks.yml', 'config'])
json_result = yaml.load(result.stdout)
json_result = yaml.safe_load(result.stdout)
assert 'networks' in json_result
assert json_result['networks'] == {
'networks_foo': {
Expand All @@ -337,7 +337,7 @@ def test_config_external_network(self):
def test_config_with_dot_env(self):
self.base_dir = 'tests/fixtures/default-env-file'
result = self.dispatch(['config'])
json_result = yaml.load(result.stdout)
json_result = yaml.safe_load(result.stdout)
assert json_result == {
'services': {
'web': {
Expand All @@ -352,7 +352,7 @@ def test_config_with_dot_env(self):
def test_config_with_env_file(self):
self.base_dir = 'tests/fixtures/default-env-file'
result = self.dispatch(['--env-file', '.env2', 'config'])
json_result = yaml.load(result.stdout)
json_result = yaml.safe_load(result.stdout)
assert json_result == {
'services': {
'web': {
Expand All @@ -367,7 +367,7 @@ def test_config_with_env_file(self):
def test_config_with_dot_env_and_override_dir(self):
self.base_dir = 'tests/fixtures/default-env-file'
result = self.dispatch(['--project-directory', 'alt/', 'config'])
json_result = yaml.load(result.stdout)
json_result = yaml.safe_load(result.stdout)
assert json_result == {
'services': {
'web': {
Expand All @@ -382,7 +382,7 @@ def test_config_with_dot_env_and_override_dir(self):
def test_config_external_volume_v2(self):
self.base_dir = 'tests/fixtures/volumes'
result = self.dispatch(['-f', 'external-volumes-v2.yml', 'config'])
json_result = yaml.load(result.stdout)
json_result = yaml.safe_load(result.stdout)
assert 'volumes' in json_result
assert json_result['volumes'] == {
'foo': {
Expand All @@ -398,7 +398,7 @@ def test_config_external_volume_v2(self):
def test_config_external_volume_v2_x(self):
self.base_dir = 'tests/fixtures/volumes'
result = self.dispatch(['-f', 'external-volumes-v2-x.yml', 'config'])
json_result = yaml.load(result.stdout)
json_result = yaml.safe_load(result.stdout)
assert 'volumes' in json_result
assert json_result['volumes'] == {
'foo': {
Expand All @@ -414,7 +414,7 @@ def test_config_external_volume_v2_x(self):
def test_config_external_volume_v3_x(self):
self.base_dir = 'tests/fixtures/volumes'
result = self.dispatch(['-f', 'external-volumes-v3-x.yml', 'config'])
json_result = yaml.load(result.stdout)
json_result = yaml.safe_load(result.stdout)
assert 'volumes' in json_result
assert json_result['volumes'] == {
'foo': {
Expand All @@ -430,7 +430,7 @@ def test_config_external_volume_v3_x(self):
def test_config_external_volume_v3_4(self):
self.base_dir = 'tests/fixtures/volumes'
result = self.dispatch(['-f', 'external-volumes-v3-4.yml', 'config'])
json_result = yaml.load(result.stdout)
json_result = yaml.safe_load(result.stdout)
assert 'volumes' in json_result
assert json_result['volumes'] == {
'foo': {
Expand All @@ -446,7 +446,7 @@ def test_config_external_volume_v3_4(self):
def test_config_external_network_v3_5(self):
self.base_dir = 'tests/fixtures/networks'
result = self.dispatch(['-f', 'external-networks-v3-5.yml', 'config'])
json_result = yaml.load(result.stdout)
json_result = yaml.safe_load(result.stdout)
assert 'networks' in json_result
assert json_result['networks'] == {
'foo': {
Expand All @@ -462,7 +462,7 @@ def test_config_external_network_v3_5(self):
def test_config_v1(self):
self.base_dir = 'tests/fixtures/v1-config'
result = self.dispatch(['config'])
assert yaml.load(result.stdout) == {
assert yaml.safe_load(result.stdout) == {
'version': '2.1',
'services': {
'net': {
Expand All @@ -487,7 +487,7 @@ def test_config_v3(self):
self.base_dir = 'tests/fixtures/v3-full'
result = self.dispatch(['config'])

assert yaml.load(result.stdout) == {
assert yaml.safe_load(result.stdout) == {
'version': '3.5',
'volumes': {
'foobar': {
Expand Down Expand Up @@ -564,7 +564,7 @@ def test_config_compatibility_mode(self):
self.base_dir = 'tests/fixtures/compatibility-mode'
result = self.dispatch(['--compatibility', 'config'])

assert yaml.load(result.stdout) == {
assert yaml.safe_load(result.stdout) == {
'version': '2.3',
'volumes': {'foo': {'driver': 'default'}},
'networks': {'bar': {}},
Expand Down
20 changes: 10 additions & 10 deletions tests/unit/config/config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5060,7 +5060,7 @@ def test_healthcheck(self):
})
)

serialized_config = yaml.load(serialize_config(config_dict))
serialized_config = yaml.safe_load(serialize_config(config_dict))
serialized_service = serialized_config['services']['test']

assert serialized_service['healthcheck'] == {
Expand All @@ -5087,7 +5087,7 @@ def test_disable(self):
})
)

serialized_config = yaml.load(serialize_config(config_dict))
serialized_config = yaml.safe_load(serialize_config(config_dict))
serialized_service = serialized_config['services']['test']

assert serialized_service['healthcheck'] == {
Expand Down Expand Up @@ -5294,7 +5294,7 @@ def test_serialize_secrets(self):
'secrets': secrets_dict
}))

serialized_config = yaml.load(serialize_config(config_dict))
serialized_config = yaml.safe_load(serialize_config(config_dict))
serialized_service = serialized_config['services']['web']
assert secret_sort(serialized_service['secrets']) == secret_sort(service_dict['secrets'])
assert 'secrets' in serialized_config
Expand All @@ -5309,7 +5309,7 @@ def test_serialize_ports(self):
}
], volumes={}, networks={}, secrets={}, configs={})

serialized_config = yaml.load(serialize_config(config_dict))
serialized_config = yaml.safe_load(serialize_config(config_dict))
assert '8080:80/tcp' in serialized_config['services']['web']['ports']

def test_serialize_ports_with_ext_ip(self):
Expand All @@ -5321,7 +5321,7 @@ def test_serialize_ports_with_ext_ip(self):
}
], volumes={}, networks={}, secrets={}, configs={})

serialized_config = yaml.load(serialize_config(config_dict))
serialized_config = yaml.safe_load(serialize_config(config_dict))
assert '127.0.0.1:8080:80/tcp' in serialized_config['services']['web']['ports']

def test_serialize_configs(self):
Expand Down Expand Up @@ -5349,7 +5349,7 @@ def test_serialize_configs(self):
'configs': configs_dict
}))

serialized_config = yaml.load(serialize_config(config_dict))
serialized_config = yaml.safe_load(serialize_config(config_dict))
serialized_service = serialized_config['services']['web']
assert secret_sort(serialized_service['configs']) == secret_sort(service_dict['configs'])
assert 'configs' in serialized_config
Expand Down Expand Up @@ -5389,7 +5389,7 @@ def test_serialize_escape_dollar_sign(self):
}
config_dict = config.load(build_config_details(cfg))

serialized_config = yaml.load(serialize_config(config_dict))
serialized_config = yaml.safe_load(serialize_config(config_dict))
serialized_service = serialized_config['services']['web']
assert serialized_service['environment']['CURRENCY'] == '$$'
assert serialized_service['command'] == 'echo $$FOO'
Expand All @@ -5411,7 +5411,7 @@ def test_serialize_escape_dont_interpolate(self):
}
config_dict = config.load(build_config_details(cfg), interpolate=False)

serialized_config = yaml.load(serialize_config(config_dict, escape_dollar=False))
serialized_config = yaml.safe_load(serialize_config(config_dict, escape_dollar=False))
serialized_service = serialized_config['services']['web']
assert serialized_service['environment']['CURRENCY'] == '$'
assert serialized_service['command'] == 'echo $FOO'
Expand All @@ -5430,7 +5430,7 @@ def test_serialize_unicode_values(self):

config_dict = config.load(build_config_details(cfg))

serialized_config = yaml.load(serialize_config(config_dict))
serialized_config = yaml.safe_load(serialize_config(config_dict))
serialized_service = serialized_config['services']['web']
assert serialized_service['command'] == 'echo 十六夜 咲夜'

Expand All @@ -5446,6 +5446,6 @@ def test_serialize_external_false(self):
}

config_dict = config.load(build_config_details(cfg))
serialized_config = yaml.load(serialize_config(config_dict))
serialized_config = yaml.safe_load(serialize_config(config_dict))
serialized_volume = serialized_config['volumes']['test']
assert serialized_volume['external'] is False