mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-15 11:40:30 +03:00
Use ruamel.yaml in metadata.py and metadata.TestCase
This is to read metadata based on YAML 1.2 rather than 1.1.
This commit is contained in:
parent
8c10614bf9
commit
671a264dfe
3 changed files with 60 additions and 130 deletions
|
|
@ -15,14 +15,11 @@ from collections import OrderedDict
|
|||
from pathlib import Path
|
||||
|
||||
|
||||
import yaml
|
||||
from testcommon import TmpCwd
|
||||
|
||||
from ruamel.yaml import YAML
|
||||
|
||||
try:
|
||||
from yaml import CSafeLoader as SafeLoader
|
||||
except ImportError:
|
||||
from yaml import SafeLoader
|
||||
yaml = YAML(typ='safe')
|
||||
|
||||
localmodule = Path(__file__).resolve().parent.parent
|
||||
print('localmodule: ' + str(localmodule))
|
||||
|
|
@ -173,7 +170,7 @@ class MetadataTest(unittest.TestCase):
|
|||
def test_valid_funding_yml_regex(self):
|
||||
"""Check the regex can find all the cases"""
|
||||
with (self.basedir / 'funding-usernames.yaml').open() as fp:
|
||||
data = yaml.load(fp, Loader=SafeLoader)
|
||||
data = yaml.load(fp)
|
||||
|
||||
for k, entries in data.items():
|
||||
for entry in entries:
|
||||
|
|
@ -212,7 +209,7 @@ class MetadataTest(unittest.TestCase):
|
|||
frommeta = dict(apps[appid])
|
||||
self.assertTrue(appid in apps)
|
||||
with savepath.open('r') as f:
|
||||
from_yaml = yaml.load(f, Loader=SafeLoader)
|
||||
from_yaml = yaml.load(f)
|
||||
self.assertEqual(frommeta, from_yaml)
|
||||
# comment above assert and uncomment below to update test
|
||||
# files when new metadata fields are added
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue