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

autoformatting against pyproject-fmt 0.4.0 #61

Closed
stanislavlevin opened this issue Nov 23, 2022 · 1 comment · Fixed by #62
Closed

autoformatting against pyproject-fmt 0.4.0 #61

stanislavlevin opened this issue Nov 23, 2022 · 1 comment · Fixed by #62

Comments

@stanislavlevin
Copy link

With new pyproject-fmt (0.4.0) test_auto_formatting fails:

________________________________ test_auto_formatting ________________________________

tmp_path = PosixPath('/usr/src/tmp/pytest-of-builder/pytest-2/test_auto_formatting0')
capsys = <_pytest.capture.CaptureFixture object at 0x7ff8d4065180>

    @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
        breakpoint()
        cli.run(["-F", str(tmp_path / "setup.cfg")])
        out, _ = capsys.readouterr()
        assert cleandoc(normal_output) not in out
>       assert cleandoc(expected) in out
E       assert 'requires = [\n  "setuptools>=61.2",\n]' in ''
E        +  where 'requires = [\n  "setuptools>=61.2",\n]' = cleandoc('\n    requires = [\n      "setuptools>=61.2",\n    ]\n    ')

tests/test_cli.py:145: AssertionError
--------------------------------- Captured log call ----------------------------------
WARNING  ini2toml:cli.py:101 Auto-formatting failed, falling back to original text
WARNING  ini2toml:cli.py:101 Auto-formatting failed, falling back to original text
============================== short test summary info ===============================
FAILED tests/test_cli.py::test_auto_formatting - assert 'requires = [\n  "setuptools>=61.2",\n]' in ''
(py3) [builder@localhost python3-module-ini2toml-0.11.1]$ ini2toml -vv -F /usr/src/tmp/pytest-of-builder/pytest-3/test_auto_formatting0/setup.cfg
[DEBUG] pyproject-fmt failed: Config.__init__() missing 1 required positional argument: 'toml'
Traceback (most recent call last):
  File "/usr/src/RPM/BUILD/python3-module-ini2toml-0.11.1/.tox/py3/lib/python3/site-packages/ini2toml/cli.py", line 98, in apply_auto_formatting
    return format_pyproject(Config(text))
TypeError: Config.__init__() missing 1 required positional argument: 'toml'
[WARNING] Auto-formatting failed, falling back to original text
[build-system]
requires = ["setuptools>=61.2"]
build-backend = "setuptools.build_meta"

[project]
version = "42"
name = "myproj"

[tool.setuptools]
include-package-data = false

This is caused by tox-dev/pyproject-fmt@c690ab2 (added pyproject_toml: Path field to Config).

@abravalheri
Copy link
Owner

Thank you very much for reporting @stanislavlevin

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.

2 participants