pytest-dev / pytest-dev/pytest

py.test, assertion for assertDictContainsSubset?

Open
#2,376 20 comments 19 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

topic: rewrite topic: tracebacks type: proposal
Dominant language
Python
Stars
14.5k
Forks
3.4k
Avg merge
2d 9h
Merged PRs (30d)
35

Description

self.assertDictContainsSubset is in unittest in Standard Library.

See https://github.com/python/cpython/blob/bbd3cf8/Lib/unittest/case.py#L1122.

Googled and looked around, I haven't seen a way to do it.

In py.test, assert <dict> in <dict2> should be the same as self.assertDictContainsSubset(dict, dict2.

Is this already a feature and I'm missing it? Is py.test open to a PR for it?

Contributor guide

Open the contributing guide

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 reading the referenced Lib/unittest/case.py implementation of assertDictContainsSubset and compare it with pytest's existing assertion behavior. Determine whether the proposed dict-in-dict syntax and its failure output fit pytest, then identify the relevant assertion tests and define coverage for the supported semantics.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.