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

test_auto_formatting fails (with pyproject-fmt 2.0.3) #107

Closed
mtelka opened this issue May 14, 2024 · 2 comments
Closed

test_auto_formatting fails (with pyproject-fmt 2.0.3) #107

mtelka opened this issue May 14, 2024 · 2 comments

Comments

@mtelka
Copy link

mtelka commented May 14, 2024

I'm testing ini2toml 0.15 in an environment with pyproject-fmt 2.0.3 installed and I see the following test to fail:

_____________________________ test_auto_formatting _____________________________

tmp_path = PosixPath('/tmp/pytest-of-marcel/pytest-15/test_auto_formatting0')
capsys = <_pytest.capture.CaptureFixture object at 0x7fffac3c30d0>

    @pytest.mark.skipif(
        sys.version_info < (3, 7),
        reason="pyproject-fmt is only available on Python 3.7+",
    )
    def test_auto_formatting(tmp_path, capsys):
        setupcfg = """
        [metadata]
        version = 42
        name = myproj
        """
        normal_output = """
        requires = ["setuptools>=61.2"]
        """
        expected = """
        requires = [
          "setuptools>=61.2",
        ]
        """
    
        # Check if the underlying function works
        formatted = cli.apply_auto_formatting(cleandoc(expected))
        assert formatted.strip() == cleandoc(expected).strip()

        (tmp_path / "setup.cfg").write_text(cleandoc(setupcfg), encoding="utf-8")
        assert (tmp_path / "setup.cfg").exists()

        # Check the output when formatting in off
        cli.run([str(tmp_path / "setup.cfg")])
        out, _ = capsys.readouterr()
        assert cleandoc(normal_output) in out
        assert cleandoc(expected) not in out

        # Check the output when formatting in on
        cli.run(["-F", str(tmp_path / "setup.cfg")])
        out, _ = capsys.readouterr()
>       assert cleandoc(normal_output) not in out
E       assert 'requires = ["setuptools>=61.2"]' not in '[build-system]\nrequires = ["setuptools>=61.2"]\nbuild-backend = "setuptools.build_meta"\n\n[project]\nversion = "42"\nname = "myproj"\n\n[tool.setuptools]\ninclude-package-data = false\n'
E
E         'requires = ["setuptools>=61.2"]' is contained here:
E           [build-system]
E           requires = ["setuptools>=61.2"]
E           build-backend = "setuptools.build_meta"
E
E           [project]
E           version = "42"
E           name = "myproj"
E
E           [tool.setuptools]
E           include-package-data = false

tests/test_cli.py:161: AssertionError
------------------------------ Captured log call -------------------------------
WARNING  ini2toml:cli.py:103 Auto-formatting failed, falling back to original text
WARNING  ini2toml:cli.py:103 Auto-formatting failed, falling back to original text
@abravalheri
Copy link
Owner

abravalheri commented May 14, 2024

I believe this is a duplicate of #103, right?

For the moment I am trying to figure it out, as pyproject-fmt 2+ removed the public API.

v0.15 should have a version cap on the dependency as a temporary workaround for this problem. But as anything with extras is complicated (because pip does not support extras in entry-points). Now, I am not sure why the cap is not enforced.

@mtelka
Copy link
Author

mtelka commented May 14, 2024

I believe this is a duplicate of #103, right?

Probably.

For the moment I am trying to figure it out, as pyproject-fmt 2+ removed the public API.

v0.15 should have a version cap on the dependency as a temporary workaround for this problem. But as anything with extras is complicated (because pip does not support extras in entry-points). Now, I am not sure why the cap is not enforced.

Cap is not enforced here intentionally because I'm testing in real environment where there is simply newer pyproject-fmt installed. So this could be simply considered as: please add support for pyproject-fmt 2.

Closing as duplicate of #103.

@mtelka mtelka closed this as completed May 14, 2024
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