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

Fixing tests for ruamel yaml 0.18+ #199

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

# 3rd party imports
import pytest
from pykwalify.compat import yaml
from pykwalify.compat import yml
from testfixtures import compare


Expand Down Expand Up @@ -579,7 +579,7 @@ def test_core_files(self):
for passing_test_file in pass_tests:
f = self.f(os.path.join("success", passing_test_file))
with open(f, "r") as stream:
yaml_data = yaml.safe_load_all(stream)
yaml_data = yml.load_all(stream)

for document_index, document in enumerate(yaml_data):
data = document["data"]
Expand All @@ -600,7 +600,7 @@ def test_core_files(self):
for failing_test, exception_type in _fail_tests:
f = self.f(os.path.join("fail", failing_test))
with open(f, "r") as stream:
yaml_data = yaml.safe_load_all(stream)
yaml_data = yml.load_all(stream)

for document_index, document in enumerate(yaml_data):
data = document["data"]
Expand Down
12 changes: 7 additions & 5 deletions tests/test_unicode.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from pykwalify.errors import SchemaError

# 3rd party imports
from pykwalify.compat import yaml
from pykwalify.compat import yml
from testfixtures import compare


Expand Down Expand Up @@ -47,7 +47,8 @@ def test_files_with_unicode_content_success(self, tmpdir):
}

source_f = tmpdir.join(u"2så.json")
source_f.write(yaml.safe_dump(fail_data_2s_yaml, allow_unicode=True))
with source_f.open('w') as stream:
yml.dump(fail_data_2s_yaml, stream)

_pass_tests = [
# Test mapping with unicode key and value
Expand All @@ -65,7 +66,7 @@ def test_files_with_unicode_content_success(self, tmpdir):
f = self.f(passing_test_files)

with open(f, "r") as stream:
yaml_data = yaml.safe_load(stream)
yaml_data = yml.load(stream)
data = yaml_data["data"]
schema = yaml_data["schema"]

Expand Down Expand Up @@ -102,7 +103,8 @@ def test_files_with_unicode_content_failing(self, tmpdir):
}

source_f = tmpdir.join(u"2få.json")
source_f.write(yaml.safe_dump(fail_data_2f_yaml, allow_unicode=True))
with source_f.open('w') as stream:
yml.dump(fail_data_2f_yaml, stream)

_fail_tests = [
# Test mapping with unicode key and value but wrong type
Expand All @@ -120,7 +122,7 @@ def test_files_with_unicode_content_failing(self, tmpdir):
f = self.f(failing_test)

with open(f, "r") as stream:
yaml_data = yaml.safe_load(stream)
yaml_data = yml.load(stream)
data = yaml_data["data"]
schema = yaml_data["schema"]
errors = yaml_data["errors"]
Expand Down