Skip to content

Compat with pytest 6.0.0#119

Closed
pllim wants to merge 1 commit intoscientific-python:masterfrom
pllim:pytest-6.0.0
Closed

Compat with pytest 6.0.0#119
pllim wants to merge 1 commit intoscientific-python:masterfrom
pllim:pytest-6.0.0

Conversation

@pllim
Copy link
Copy Markdown
Contributor

@pllim pllim commented Jul 28, 2020

Attempt to fix #118

@pllim pllim added 🔥 Critical bug labels Jul 28, 2020
def indent(text, prefix):
return '\n'.join([prefix + line for line in text.splitlines()])

PYTEST_GT_5 = Version(pytest.__version__) > Version('5')
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Version(pytest.__version__) < Version('6.0.0') didn't work because CI pulled 6.0.0rc<blahblah> and that evaluates to True even if I wanted it to be False.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not LooseVersion, that should return False for those (though one could argue False is the wrong answer, but in these scenarios it's the right answer we need)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently Python org hates distutils now or something... Using packaging is consistent with astropy/astropy#10590 .

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pytest also uses packaging, i.e. it's a dependency of pytest, so having it a dependency here is not a big deal. It will get installed regardless.

@pllim

This comment has been minimized.

@pllim
Copy link
Copy Markdown
Contributor Author

pllim commented Jul 28, 2020

Not sure what is going on with this failure. It is unrelated and I cannot reproduce it locally even when I did a hack to make c.packages['pytest'] = '6.0.0rc2.dev67+g38029828d'.

__________________ TestModuleChecker.test_check_distribution ___________________
self = <test_utils.TestModuleChecker object at 0x7f1129d4f310>
    def test_check_distribution(self):
        c = ModuleChecker()
        # in python3.4+ packages attribute will not be populated
        # because it calls 'pip freeze' which is slow
        if not c.packages:
            c.packages = c.get_packages()
            # after this we will be able to test _check_distribution even in
            # python3.4+ environment
>       assert c._check_distribution('pytest>1.0')
E       AssertionError: assert False
E        +  where False = <bound method ModuleChecker._check_distribution of <pytest_doctestplus.utils.ModuleChecker object at 0x7f1129d4fa90>>('pytest>1.0')
E        +    where <bound method ModuleChecker._check_distribution of <pytest_doctestplus.utils.ModuleChecker object at 0x7f1129d4fa90>> = <pytest_doctestplus.utils.ModuleChecker object at 0x7f1129d4fa90>._check_distribution
tests/test_utils.py:23: AssertionError
------------------------------ Captured log call -------------------------------
WARNING  pytest_doctestplus.utils:utils.py:66 The 'pytest' distribution was not found and is required by the application

import sys
import warnings

from packaging.version import Version
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll want to add packaging to install_requires in setup.py. This is working now because pytest also depends on packaging and installs it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think packaging is vendored by setuptools

Copy link
Copy Markdown
Contributor

@jdavies-st jdavies-st Jul 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is, but it doesn't not have the same namespace. You then have to import it from setuptools.extern.version I believe.

@pllim pllim closed this in #120 Jul 29, 2020
@pllim pllim deleted the pytest-6.0.0 branch July 29, 2020 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🔥 Critical

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing importmode with pytest 6.0.0

4 participants