Repository: psf/black
File: tests/test_black.py (Python)

Code before:
        path = THIS_DIR / "data" / "include_exclude_tests"
        include = ""
        exclude = r"/exclude/|a\.py"
        src = "-"
        report = black.Report()
        stdin_filename = str(path / "b/exclude/a.py")
        expected = [Path(f"__BLACK_STDIN_FILENAME__{stdin_filename}")]
        sources = list(
            black.get_sources(
                ctx=FakeContext(),
                src=(src,),
                quiet=True,
                verbose=False,
                include=include,
                exclude=exclude,
                extend_exclude=None,
                force_exclude=None,
                report=report,
                stdin_filename=stdin_filename,
            )
        )
        self.assertEqual(sorted(expected), sorted(sources))

    @patch("black.find_project_root", lambda *args: THIS_DIR.resolve())
    def test_get_sources_with_stdin_filename_and_extend_exclude(self) -> None:
        # Extend exclude shouldn't exclude stdin_filename since it is mimicing the
        # file being passed directly. This is the same as
        # test_exclude_for_issue_1572
        path = THIS_DIR / "data" / "include_exclude_tests"
        include = ""
        extend_exclude = r"/exclude/|a\.py"
        src = "-"
        report = black.Report()
        stdin_filename = str(path / "b/exclude/a.py")
        expected = [Path(f"__BLACK_STDIN_FILENAME__{stdin_filename}")]
        sources = list(
            black.get_sources(
                ctx=FakeContext(),
                src=(src,),
                quiet=True,
                verbose=False,
                include=include,
                exclude="",
                extend_exclude=extend_exclude,
                force_exclude=None,
                report=report,
                stdin_filename=stdin_filename,
            )
        )
        self.assertEqual(sorted(expected), sorted(sources))


Review comment (suggestion):
typo :)
```suggestion
        # Extend exclude shouldn't exclude stdin_filename since it is mimicking the
```

Code after:
        path = THIS_DIR / "data" / "include_exclude_tests"
        include = ""
        exclude = r"/exclude/|a\.py"
        src = "-"
        report = black.Report()
        stdin_filename = str(path / "b/exclude/a.py")
        expected = [Path(f"__BLACK_STDIN_FILENAME__{stdin_filename}")]
        sources = list(
            black.get_sources(
                ctx=FakeContext(),
                src=(src,),
                quiet=True,
                verbose=False,
                include=include,
                exclude=exclude,
                extend_exclude=None,
                force_exclude=None,
                report=report,
                stdin_filename=stdin_filename,
            )
        )
        self.assertEqual(sorted(expected), sorted(sources))

    @patch("black.find_project_root", lambda *args: THIS_DIR.resolve())
    def test_get_sources_with_stdin_filename_and_extend_exclude(self) -> None:
        # Extend exclude shouldn't exclude stdin_filename since it is mimicking the
        # file being passed directly. This is the same as
        # test_exclude_for_issue_1572
        path = THIS_DIR / "data" / "include_exclude_tests"
        include = ""
        extend_exclude = r"/exclude/|a\.py"
        src = "-"
        report = black.Report()
        stdin_filename = str(path / "b/exclude/a.py")
        expected = [Path(f"__BLACK_STDIN_FILENAME__{stdin_filename}")]
        sources = list(
            black.get_sources(
                ctx=FakeContext(),
                src=(src,),
                quiet=True,
                verbose=False,
                include=include,
                exclude="",
                extend_exclude=extend_exclude,
                force_exclude=None,
                report=report,
                stdin_filename=stdin_filename,
            )
        )
        self.assertEqual(sorted(expected), sorted(sources))