def test_pypi_section_order_preserved(testing_workdir): """ Test whether sections have been written in the correct order. """ from conda_build.render import FIELDS from conda_build.skeletons.pypi import (ABOUT_ORDER, REQUIREMENTS_ORDER, PYPI_META_STATIC) api.skeletonize(packages='sympy', repo='pypi') # Since we want to check the order of items in the recipe (not whether # the metadata values themselves are sensible), read the file as (ordered) # yaml, and check the order. with open('sympy/meta.yaml', 'r') as file: lines = [l for l in file.readlines() if not l.startswith("{%")] # The loader below preserves the order of entries... recipe = ruamel_yaml.load('\n'.join(lines), Loader=ruamel_yaml.RoundTripLoader) major_sections = list(recipe.keys()) # Blank fields are omitted when skeletonizing, so prune any missing ones # before comparing. pruned_fields = [f for f in FIELDS if f in major_sections] assert major_sections == pruned_fields assert list(recipe['about']) == ABOUT_ORDER assert list(recipe['requirements']) == REQUIREMENTS_ORDER for k, v in PYPI_META_STATIC.items(): assert list(v.keys()) == list(recipe[k])