pytest-dev / pytest-dev/unittest2pytest

Missing trailing : on emitted with statement

Open
#18 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug help wanted
Dominant language
Python
Stars
141
Forks
28
PR merge metrics
No merged PRs in 30d

Description

The tool chokes on https://github.com/coala/coala/blob/8a25983/tests/parsing/CliParsingTest.py#L58

Somehow it writes with statements without a trailing :.

         sections = parse_cli(arg_list=['--relpath'])
-        with self.assertRaisesRegex(SystemExit, '2') as cm:
+        with pytest.raises(SystemExit) as excinfo
+        assert re.search(pattern, excinfo.value) as cm:
             check_conflicts(sections)
-            self.assertEqual(cm.exception.code, 2)
+            assert cm.exception.code == 2
 
         sections = parse_cli(arg_list=['--output', 'iraiseValueError'])
-        with self.assertRaisesRegex(SystemExit, '2') as cm:
+        with pytest.raises(SystemExit) as excinfo
+        assert re.search(pattern, excinfo.value) as cm:
             check_conflicts(sections)
-            self.assertEqual(cm.exception.code, 2)
+            assert cm.exception.code == 2

The result is naturally a syntax error: https://travis-ci.org/jayvdb/coala/jobs/246949584#L9068

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the conversion using tests/parsing/CliParsingTest.py#L58 and inspect the generated with statement. Trace the emitter responsible for that statement and verify that the converted output is syntactically valid, including the trailing colon.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing-qa, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.