pytest-dev / pytest-dev/unittest2pytest
Output of invalid indents when comments appear inside implicit string continuations
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 141
- Forks
- 28
- PR merge metrics
- No merged PRs in 30d
Description
A comment inside a string breaks the tools as it unnecessarily appends line continuations to strings
i.e. this chokes
foo('a'
# foo
'b')
A real example
- self.assertEqual('\n' + STR_PROJECT_WIDE + '\n\n'
- '**** t [Section: ] ****' + '\n\n'
- '! ! [Severity: NORMAL]\n'
- '! ! msg\n'
- # Second results file isn't there, no context is
- # printed, only a warning log message which we
- # don't catch
- '\n**** t [Section: ] ****' + '\n\n'
- '! ! [Severity: NORMAL]\n'
+ assert '\n' + STR_PROJECT_WIDE + '\n\n' \
+ '**** t [Section: ] ****' + '\n\n' \
+ '! ! [Severity: NORMAL]\n' \
+ '! ! msg\n' \
+ # Second results file isn't there, no context is \
+ # printed, only a warning log message which we \
+ # don't catch \
+ '\n**** t [Section: ] ****' + '\n\n' \
+ '! ! [Severity: NORMAL]\n' \
'! ! {0}\n'.format(
highlight_text(self.no_color, 'msg',
- style=BackgroundMessageStyle)),
- stdout.getvalue())
+ style=BackgroundMessageStyle)) == \
+ stdout.getvalue()
From https://github.com/coala/coala/blob/8a25983/tests/output/ConsoleInteractionTest.py#L623
Result: https://travis-ci.org/jayvdb/coala/jobs/246949584#L9052
(Another bug coming about the other problem in that build log.)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the implicit string continuation example and trace how unittest2pytest handles comments between adjacent string literals. The referenced tests/output/ConsoleInteractionTest.py example shows the unwanted backslashes; done means comments remain valid and the converted output no longer appends line continuations unnecessarily.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing-qa, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100