pytest-dev / pytest-dev/unittest2pytest

assertRaises with context should replace context.exception with context.value

Open
#36 6 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

input

with self.assertRaises(Exception) as ctx:
    sut()

self.assertIn("msg", str(ctx.exception))

expected output

with pytest.raises(Exception) as ctx:
    sut()

assert "msg" in str(ctx.value)

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 locating the rewrite handling assertRaises context managers and the conversion of context.exception. Use the input and expected output in this issue as the acceptance case, and verify that the resulting pytest assertion uses context.value while preserving the message check.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing-qa
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.