Closed Sup3rGeo closed 5 years ago
your code was fundamentally broken from the beginning, our recent switch from a hackish mess to just deindent just made it more apparent (as the text is now exactly rendered as your code intends)
@RonnyPfannschmidt, is it really the case to have the first (import pytest
) and second (https://github.com/pyinstaller/pyinstaller.git
) line differently indented, even though they have the same indentation in the string? Could you explain why?
@Sup3rGeo it is not obvious, after some debugging I noticed that your text (before being passed to makepyfile
) expands to:
import pytest
from typhoon.utils.test_executor_compat import run_test
var1 = "test level 1"
var2 = "test level 2"
var3 = "test level 3"
test_list = [
[asdas]
[dasdasd]
[123]
]
@pytest.mark.parametrize("test_spec", [
pytest.param(item, id=item[0]) for item in test_list
])
def test_executor_tests(test_spec, request, capsys):
run_test(test_spec, request, capsys)
The indent of lines [dasdasd]
and [123]
is what's messing with textwrap.dedent
, because it is generic and not Python-code specific.
Solved this problem of defining indented multiline triple-quote strings using inspect.cleandoc
.
Example test:
Now we check the created py file in
tmpdir
.pytest-3.8.2
:pytest-3.9.1
(onwards):This of course fails when running because indentation is screwed up.
pip list
of the virtual environment you are usingNot using virtual environments at all.