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

Tests failed when flex is installed #116

Open
felixonmars opened this issue Aug 6, 2021 · 1 comment
Open

Tests failed when flex is installed #116

felixonmars opened this issue Aug 6, 2021 · 1 comment

Comments

@felixonmars
Copy link

felixonmars commented Aug 6, 2021

Expected Behaviour

Tests should pass. Perhaps we should lower flex's preference or something? (Sorry I am not familiar with this...)

Actual Behaviour

Tests broken.

Steps to Reproduce

Install flex and run this project's test suite.

Environment

  • OS: Arch Linux
  • Python version: 3.9.6
  • Backend: (flex, swagger-spec-validator or openapi-spec-validator) flex
ERROR tests/test_translating_parser.py::test_local_reference_from_root - pran...
ERROR tests/test_translating_parser.py::test_file_reference_from_root - pranc...
ERROR tests/test_translating_parser.py::test_local_reference_from_file - pran...
ERROR tests/test_translating_parser.py::test_same_file_reference_from_file - ...
ERROR tests/test_translating_parser.py::test_different_file_reference_from_file
ERROR tests/test_translating_parser.py::test_root_file_reference_from_file - ...
ERROR tests/test_translating_parser.py::test_root_file_reference_from_root - ...
ERROR tests/test_translating_parser.py::test_recursive_reference_in_root - pr...
ERROR tests/test_translating_parser.py::test_recursive_reference_in_file - pr...
ERROR tests/test_translating_parser.py::test_nested_recursive_reference_in_file
= 126 passed, 24 skipped, 3 xfailed, 32 xpassed, 264 warnings, 10 errors in 15.07s =

Example failure:

__________ ERROR at setup of test_nested_recursive_reference_in_file ___________

request = <SubRequest 'tester' for <Function test_nested_recursive_reference_in_file>>

    @fixture
    def tester(request):
        pattern = r"test_(.+)"
        test_function_name = request.node.name
        name_match = match(pattern, test_function_name)
        test_name = name_match[1]

        file_name = f"{test_name}.spec.yaml"
        path = join("tests", "specs", "translating_parser", file_name)
>       return SpecificationTester(path)

tests/test_translating_parser.py:18:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_translating_parser.py:46: in __init__
    parser = _TranslatingParser(url)
prance/__init__.py:116: in __init__
    self.parse()
prance/__init__.py:146: in parse
    self._validate()
prance/__init__.py:334: in _validate
    BaseParser._validate(self)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <prance._TranslatingParser object at 0x7f6b4467dc40>

    def _validate(self):
        # Ensure specification is a mapping
        from collections.abc import Mapping

        if not isinstance(self.specification, Mapping):
            raise ValidationError("Could not parse specifications!")

        # Ensure the selected backend supports the given spec version
        versions, validator_name = BaseParser.BACKENDS[self.backend]

        # Fetch the spec version. Note that this is the spec version the spec
        # *claims* to be; we later set the one we actually could validate as.
        spec_version = None
        if spec_version is None:
            spec_version = self.specification.get("openapi", None)
        if spec_version is None:
            spec_version = self.specification.get("swagger", None)
        if spec_version is None:
            raise ValidationError(
                "Could not determine specification schema " "version!"
            )

        # Try parsing the spec version, examine the first component.
        import distutils.version

        parsed = distutils.version.StrictVersion(spec_version).version
        if parsed[0] not in versions:
>           raise ValidationError(
                'Version mismatch: selected backend "%s"'
                " does not support specified version %s!" % (self.backend, spec_version)
            )
E           prance.ValidationError: Version mismatch: selected backend "flex" does not support specified version 3.0.3!

prance/__init__.py:175: ValidationError
@leonpros
Copy link

leonpros commented Feb 13, 2023

EDIT:
issue resolved by NOT using flex (although it is default), but using openapi-spec-validator
prance validate --backend=openapi-spec-validator --no-resolve openapi

did you resolve this issue?
reproduced using python 3
prance 0.22.11.4.0
flex 6.14.1
for openapi 3.0.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants