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

pytest>=5.0.0 incompatible with Flask<=1.0.4 #991

Closed
kornicameister opened this issue Jul 8, 2019 · 5 comments · Fixed by #995
Closed

pytest>=5.0.0 incompatible with Flask<=1.0.4 #991

kornicameister opened this issue Jul 8, 2019 · 5 comments · Fixed by #995

Comments

@kornicameister
Copy link
Contributor

Description

Master builds are failing due to error:

import_name = 'conftest'
    def find_package(import_name):
        """Finds a package and returns the prefix (or None if the package is
        not installed) as well as the folder that contains the package or
        module as a tuple.  The package path returned is the module that would
        have to be added to the pythonpath in order to make it possible to
        import the module.  The prefix is the path below which a UNIX like
        folder structure exists (lib, share etc.).
        """
        root_mod_name = import_name.split('.')[0]
        loader = pkgutil.get_loader(root_mod_name)
        if loader is None or import_name == '__main__':
            # import name is not found, or interactive/main module
            package_path = os.getcwd()
        else:
            # For .egg, zipimporter does not have get_filename until Python 2.7.
            if hasattr(loader, 'get_filename'):
                filename = loader.get_filename(root_mod_name)
            elif hasattr(loader, 'archive'):
                # zipimporter's loader.archive points to the .egg or .zip
                # archive filename is dropped in call to dirname below.
                filename = loader.archive
            else:
                # At least one loader is missing both get_filename and archive:
                # Google App Engine's HardenedModulesHook
                #
                # Fall back to imports.
                __import__(import_name)
                filename = sys.modules[import_name].__file__
            package_path = os.path.abspath(os.path.dirname(filename))
            # package_path ends with __init__.py for a package
>           if loader.is_package(root_mod_name):
E           AttributeError: 'AssertionRewritingHook' object has no attribute 'is_package'
.tox/py37-min/lib/python3.7/site-packages/flask/helpers.py:682: AttributeError

This can be tracked to following issues:

Indeed (either one of those actions):

  • restricting flask to be at least 1.0.4 makes tests pass.
  • restricting pytest to be at most 4.9.x makes test pass

Which brings us down to final question.
Should Flask be kept at low version (which is pretty old TBH) or should pytest be restricted.
Personally I favor running newer version instead of supporting older codebases.

Expected behaviour

master branch builds correctly against min environments.

Actual behaviour

master branch builds correctly against min fail with aforementioned error.

Steps to reproduce

Just run tox -e py3(X)-min where X stands for Python minor version {4,5,6,7}.

@hjacobs
Copy link
Contributor

hjacobs commented Jul 8, 2019

Thanks for reporting, so just updating Flask would fix the problem?

@drummerwolli
Copy link
Contributor

@hjacobs especially pinning to Flask>=1.0.4 seems to do the job, which means abandoning old versions of Flask ...

@kornicameister
Copy link
Contributor Author

In a defense of this approach, may I be so bold to say that dropping older Flask opens door to support newer Python that is not only faster but also typed which makes it extremely easier to maintain larger projects.

@kornicameister
Copy link
Contributor Author

@hjacobs it did the trick for me. All we need to test IT is the PR. I will drop one later on.

@hjacobs
Copy link
Contributor

hjacobs commented Jul 8, 2019

Great, thanks!

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

Successfully merging a pull request may close this issue.

3 participants