Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.
This repository was archived by the owner on Aug 29, 2025. It is now read-only.

pytest-black fails with export-all in comment #62

@jaraco

Description

@jaraco

While adding pytest-black to pypa/distutils, I encountered a strange problem. Black was failing on one file, but when I ran black (the same version of black as found in the test environment) on that file, nothing was changed.

I eventually distilled the problem down to the presence of the phrase "export-all" in a comment and was able to replicate the issue minimally:

 draft $ cat > test.py
# export-all
 draft $ env PYTHONWARNINGS=ignore:BlackItem pip-run -q pytest pytest-black -- -m pytest --black
=============================================================================== test session starts ===============================================================================
platform darwin -- Python 3.10.5, pytest-7.1.2, pluggy-1.0.0
rootdir: /Users/jaraco/draft
plugins: black-0.3.12
collected 1 item                                                                                                                                                                  

test.py F                                                                                                                                                                   [100%]

==================================================================================== FAILURES =====================================================================================
_______________________________________________________________________________ Black format check ________________________________________________________________________________

============================================================================= short test summary info =============================================================================
FAILED test.py::BLACK
================================================================================ 1 failed in 1.55s ================================================================================

However, if I run black on the file directly, it reports that all is well:

 draft $ black test.py
All done! ✨ 🍰 ✨
1 file left unchanged.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions