
GITHUB . COM {
}
Detected CMS Systems:
- Wordpress (2 occurrences)
Title:
Add more powerful set assertion rewrites for comparisons other than equality `==` (eg: `<=`, etc.) Β· Issue #10617 Β· pytest-dev/pytest
Description:
What's the problem this feature will solve? Set comparisons that do not check for pure equality do not have nice assertion rewriting. Examples: # Set equality assertion message is nice! π > ...
Website Age:
17 years and 9 months (reg. 2007-10-09).
Matching Content Categories {π}
- Movies
- Arts & Entertainment
- Humor
Content Management System {π}
What CMS is github.com built with?
Github.com is powered by WORDPRESS.
Traffic Estimate {π}
What is the average monthly size of github.com audience?
ππ Tremendous Traffic: 10M - 20M visitors per month
Based on our best estimate, this website will receive around 10,666,394 visitors per month in the current month.
check SE Ranking
check Ahrefs
check Similarweb
check Ubersuggest
check Semrush
How Does Github.com Make Money? {πΈ}
Subscription Packages {π³}
We've located a dedicated page on github.com that might include details about subscription plans or recurring payments. We identified it based on the word pricing in one of its internal links. Below, you'll find additional estimates for its monthly recurring revenues.How Much Does Github.com Make? {π°}
Subscription Packages {π³}
Prices on github.com are in US Dollars ($).
They range from $4.00/month to $21.00/month.
We estimate that the site has approximately 5,347,507 paying customers.
The estimated monthly recurring revenue (MRR) is $22,459,531.
The estimated annual recurring revenues (ARR) are $269,514,368.
Wordpress Themes and Plugins {π¨}
What WordPress theme does this site use?
It is strange but we were not able to detect any theme on the page.
What WordPress plugins does this website use?
It is strange but we were not able to detect any plugins on the page.
Keywords {π}
assert, set, extra, items, left, sets, pytestsetassertionpy, assertion, equal, def, failed, assertionerror, return, fleft, isinstanceleft, isinstanceright, sign, pytest, add, rewrites, equality, issue, diff, proper, subset, superset, mapstr, type, rewrite, projects, comparisons, feature, nice, navigation, solutions, pull, requests, actions, security, powerful, closed, check, inequality, test, python, testequality, testinequality, testsubset, testpropersubset, testpropersubsetequalsets,
Topics {βοΈ}
personal information add features branch type set assertion rewrites comment metadata assignees assigned labels topic type projects nice assertion rewriting verified 9bbfe99 sign projects milestone def pytest_assertrepr_compare $ pytest pytest_set_assertion assertion text debian pytest 7 rewrite related 5} failed pytest_set_assertion 3} failed pytest_set_assertion 4} failed pytest_set_assertion diff pytest_set_assertion equal pytest_set_assertion add extra items pure equality api change milestone relationships extra = map pytest-7 github left set asserting sets {left} {op} { set comparisons 3 pytest_set_assertion 4 pytest_set_assertion equal equality == equality `==` extra set py nice assert {1 op left op == left left == left sign pytest_assertrepr_compare comparisons
Payment Methods {π}
- Braintree
Questions {β}
- Already have an account?
- What's the problem this feature will solve?
Schema {πΊοΈ}
DiscussionForumPosting:
context:https://schema.org
headline:Add more powerful set assertion rewrites for comparisons other than equality `==` (eg: `<=`, etc.)
articleBody:<!--
Thanks for suggesting a feature!
Quick check-list while suggesting features:
-->
#### What's the problem this feature will solve?
<!-- What are you trying to do, that you are unable to achieve with pytest as it currently stands? -->
Set comparisons that do not check for _pure equality_ do not have nice assertion rewriting.
Examples:
```
# Set equality assertion message is nice! π
> assert {1, 2, 3} == {1, 2, 4}
E assert {1, 2, 3} == {1, 2, 4}
E Extra items in the left set:
E 3
E Extra items in the right set:
E 4
E Use -v to get more diff
# But others are not nice... π
# inequality
> assert {1, 2, 3} != {1, 2, 3}
E assert {1, 2, 3} != {1, 2, 3}
# proper subset
> assert {1, 2, 3} < {1, 2, 3}
E assert {1, 2, 3} < {1, 2, 3}
# proper superset
> assert {1, 2, 3} > {1, 2, 3}
E assert {1, 2, 3} > {1, 2, 3}
# superset
> assert {1, 2, 3} >= {1, 2, 4}
E assert {1, 2, 3} >= {1, 2, 4}
# subset
> assert {1, 2, 3} <= {1, 2, 4}
E assert {1, 2, 3} <= {1, 2, 4}
```
#### Describe the solution you'd like
<!-- A clear and concise description of what you want to happen. -->
When asserting sets are unequal, such as `set_a <= set_b`, the assertion text should be more intelligent only displaying the values that fail the check.
<!-- Provide examples of real-world use cases that this would enable and how it solves the problem described above. -->
This might look like:
```
# inequality
> assert {1, 2, 3} != {1, 2, 3}
E assert {1, 2, 3} != {1, 2, 3}
E Sets are equal
# proper subset
> assert {1, 2, 3} < {1, 2, 3}
E assert {1, 2, 3} < {1, 2, 3}
E Sets are equal
# proper superset
> assert {1, 2, 3} > {1, 2, 3}
E assert {1, 2, 3} > {1, 2, 3}
E Sets are equal
# superset
> assert {1, 2, 3} >= {1, 2, 4}
E assert {1, 2, 3} >= {1, 2, 4}
E Extra items in the right set:
E 4
E Use -v to get more diff
# subset
> assert {1, 2, 3} <= {1, 2, 4}
E assert {1, 2, 3} <= {1, 2, 4}
E Extra items in the left set:
E 3
E Use -v to get more diff
```
#### Alternative Solutions
<!-- Have you tried to workaround the problem using a pytest plugin or other tools? Or a different approach to solving this issue? Please elaborate here. -->
I'm not aware of any plugins or other tools that implement this, but I have creating my own using `pytest_assertrepr_compare`:
```python
def pytest_assertrepr_compare(op, left, right):
if isinstance(left, set) and isinstance(right, set) and op == "!=":
return [
f"{left} {op} {right}", # N.B.: I know this isn't the _actual_ way to do this, but it's good enough for the example!
"Sets are equal"
]
if isinstance(left, set) and isinstance(right, set) and op == "<=":
extra = map(str, left - right)
return [
f"{left} {op} {right}",
"Extra items in left set:",
*extra,
]
if isinstance(left, set) and isinstance(right, set) and op == "<":
if left == right:
return [
f"{left} {op} {right}",
"Sets are equal"
]
extra = map(str, left - right)
return [
f"{left} {op} {right}",
"Extra items in left set:",
*extra,
]
if isinstance(left, set) and isinstance(right, set) and op == ">=":
extra = map(str, right - left)
return [
f"{left} {op} {right}",
"Extra items in right set:",
*extra,
]
if isinstance(left, set) and isinstance(right, set) and op == ">":
if left == right:
return [
f"{left} {op} {right}",
" Sets are equal",
]
extra = map(str, right - left)
return [
f"{left} {op} {right}",
"Extra items in right set:",
*extra,
]
```
We then get the following:
```pytest
$ pytest pytest_set_assertion.py
======================================== test session starts =========================================
platform linux -- Python 3.9.13, pytest-7.2.0, pluggy-1.0.0
rootdir: /usr/local/google/home/dthor/dev/pytest_set_assertrepr
collected 8 items
pytest_set_assertion.py FFFFFFFF [100%]
============================================== FAILURES ==============================================
___________________________________________ test_equality ____________________________________________
def test_equality():
> assert {1, 2, 3} == {1, 2, 4, 5}
E assert {1, 2, 3} == {1, 2, 4, 5}
E Extra items in the left set:
E 3
E Extra items in the right set:
E 4
E 5
E Use -v to get more diff
pytest_set_assertion.py:2: AssertionError
__________________________________________ test_inequality ___________________________________________
def test_inequality():
> assert {1, 2, 3} != {1, 2, 3}
E assert {1, 2, 3} != {1, 2, 3}
E Sets are equal
pytest_set_assertion.py:6: AssertionError
____________________________________________ test_subset _____________________________________________
def test_subset():
> assert {1, 2, 3} <= {1, 2, 4}
E assert {1, 2, 3} <= {1, 2, 4}
E Extra items in left set:
E 3
pytest_set_assertion.py:10: AssertionError
_________________________________________ test_proper_subset _________________________________________
def test_proper_subset():
> assert {1, 2, 3} < {1, 2, 4}
E assert {1, 2, 3} < {1, 2, 4}
E Extra items in left set:
E 3
pytest_set_assertion.py:14: AssertionError
___________________________________ test_proper_subset_equal_sets ____________________________________
def test_proper_subset_equal_sets():
> assert {1, 2, 3} < {1, 2, 3}
E assert {1, 2, 3} < {1, 2, 3}
E Sets are equal
pytest_set_assertion.py:18: AssertionError
___________________________________________ test_superset ____________________________________________
def test_superset():
> assert {1, 2, 3} >= {1, 2, 4}
E assert {1, 2, 3} >= {1, 2, 4}
E Extra items in right set:
E 4
pytest_set_assertion.py:22: AssertionError
________________________________________ test_proper_superset ________________________________________
def test_proper_superset():
> assert {1, 2, 3} > {1, 2, 4}
E assert {1, 2, 3} > {1, 2, 4}
E Extra items in right set:
E 4
pytest_set_assertion.py:26: AssertionError
__________________________________ test_proper_superset_equal_sets ___________________________________
def test_proper_superset_equal_sets():
> assert {1, 2, 3} > {1, 2, 3}
E assert {1, 2, 3} > {1, 2, 3}
E Sets are equal
pytest_set_assertion.py:30: AssertionError
====================================== short test summary info =======================================
FAILED pytest_set_assertion.py::test_equality - assert {1, 2, 3} == {1, 2, 4, 5}
FAILED pytest_set_assertion.py::test_inequality - assert {1, 2, 3} != {1, 2, 3}
FAILED pytest_set_assertion.py::test_subset - assert {1, 2, 3} <= {1, 2, 4}
FAILED pytest_set_assertion.py::test_proper_subset - assert {1, 2, 3} < {1, 2, 4}
FAILED pytest_set_assertion.py::test_proper_subset_equal_sets - assert {1, 2, 3} < {1, 2, 3}
FAILED pytest_set_assertion.py::test_superset - assert {1, 2, 3} >= {1, 2, 4}
FAILED pytest_set_assertion.py::test_proper_superset - assert {1, 2, 3} > {1, 2, 4}
FAILED pytest_set_assertion.py::test_proper_superset_equal_sets - assert {1, 2, 3} > {1, 2, 3}
========================================= 8 failed in 0.06s ==========================================
```
#### Additional context
<!-- Add any other context, links, etc. about the feature here. -->
+ Python 3.9.13 on Debian
+ pytest 7.2.0
author:
url:https://github.com/dougthor42
type:Person
name:dougthor42
datePublished:2022-12-28T23:43:52.000Z
interactionStatistic:
type:InteractionCounter
interactionType:https://schema.org/CommentAction
userInteractionCount:0
url:https://github.com/10617/pytest/issues/10617
context:https://schema.org
headline:Add more powerful set assertion rewrites for comparisons other than equality `==` (eg: `<=`, etc.)
articleBody:<!--
Thanks for suggesting a feature!
Quick check-list while suggesting features:
-->
#### What's the problem this feature will solve?
<!-- What are you trying to do, that you are unable to achieve with pytest as it currently stands? -->
Set comparisons that do not check for _pure equality_ do not have nice assertion rewriting.
Examples:
```
# Set equality assertion message is nice! π
> assert {1, 2, 3} == {1, 2, 4}
E assert {1, 2, 3} == {1, 2, 4}
E Extra items in the left set:
E 3
E Extra items in the right set:
E 4
E Use -v to get more diff
# But others are not nice... π
# inequality
> assert {1, 2, 3} != {1, 2, 3}
E assert {1, 2, 3} != {1, 2, 3}
# proper subset
> assert {1, 2, 3} < {1, 2, 3}
E assert {1, 2, 3} < {1, 2, 3}
# proper superset
> assert {1, 2, 3} > {1, 2, 3}
E assert {1, 2, 3} > {1, 2, 3}
# superset
> assert {1, 2, 3} >= {1, 2, 4}
E assert {1, 2, 3} >= {1, 2, 4}
# subset
> assert {1, 2, 3} <= {1, 2, 4}
E assert {1, 2, 3} <= {1, 2, 4}
```
#### Describe the solution you'd like
<!-- A clear and concise description of what you want to happen. -->
When asserting sets are unequal, such as `set_a <= set_b`, the assertion text should be more intelligent only displaying the values that fail the check.
<!-- Provide examples of real-world use cases that this would enable and how it solves the problem described above. -->
This might look like:
```
# inequality
> assert {1, 2, 3} != {1, 2, 3}
E assert {1, 2, 3} != {1, 2, 3}
E Sets are equal
# proper subset
> assert {1, 2, 3} < {1, 2, 3}
E assert {1, 2, 3} < {1, 2, 3}
E Sets are equal
# proper superset
> assert {1, 2, 3} > {1, 2, 3}
E assert {1, 2, 3} > {1, 2, 3}
E Sets are equal
# superset
> assert {1, 2, 3} >= {1, 2, 4}
E assert {1, 2, 3} >= {1, 2, 4}
E Extra items in the right set:
E 4
E Use -v to get more diff
# subset
> assert {1, 2, 3} <= {1, 2, 4}
E assert {1, 2, 3} <= {1, 2, 4}
E Extra items in the left set:
E 3
E Use -v to get more diff
```
#### Alternative Solutions
<!-- Have you tried to workaround the problem using a pytest plugin or other tools? Or a different approach to solving this issue? Please elaborate here. -->
I'm not aware of any plugins or other tools that implement this, but I have creating my own using `pytest_assertrepr_compare`:
```python
def pytest_assertrepr_compare(op, left, right):
if isinstance(left, set) and isinstance(right, set) and op == "!=":
return [
f"{left} {op} {right}", # N.B.: I know this isn't the _actual_ way to do this, but it's good enough for the example!
"Sets are equal"
]
if isinstance(left, set) and isinstance(right, set) and op == "<=":
extra = map(str, left - right)
return [
f"{left} {op} {right}",
"Extra items in left set:",
*extra,
]
if isinstance(left, set) and isinstance(right, set) and op == "<":
if left == right:
return [
f"{left} {op} {right}",
"Sets are equal"
]
extra = map(str, left - right)
return [
f"{left} {op} {right}",
"Extra items in left set:",
*extra,
]
if isinstance(left, set) and isinstance(right, set) and op == ">=":
extra = map(str, right - left)
return [
f"{left} {op} {right}",
"Extra items in right set:",
*extra,
]
if isinstance(left, set) and isinstance(right, set) and op == ">":
if left == right:
return [
f"{left} {op} {right}",
" Sets are equal",
]
extra = map(str, right - left)
return [
f"{left} {op} {right}",
"Extra items in right set:",
*extra,
]
```
We then get the following:
```pytest
$ pytest pytest_set_assertion.py
======================================== test session starts =========================================
platform linux -- Python 3.9.13, pytest-7.2.0, pluggy-1.0.0
rootdir: /usr/local/google/home/dthor/dev/pytest_set_assertrepr
collected 8 items
pytest_set_assertion.py FFFFFFFF [100%]
============================================== FAILURES ==============================================
___________________________________________ test_equality ____________________________________________
def test_equality():
> assert {1, 2, 3} == {1, 2, 4, 5}
E assert {1, 2, 3} == {1, 2, 4, 5}
E Extra items in the left set:
E 3
E Extra items in the right set:
E 4
E 5
E Use -v to get more diff
pytest_set_assertion.py:2: AssertionError
__________________________________________ test_inequality ___________________________________________
def test_inequality():
> assert {1, 2, 3} != {1, 2, 3}
E assert {1, 2, 3} != {1, 2, 3}
E Sets are equal
pytest_set_assertion.py:6: AssertionError
____________________________________________ test_subset _____________________________________________
def test_subset():
> assert {1, 2, 3} <= {1, 2, 4}
E assert {1, 2, 3} <= {1, 2, 4}
E Extra items in left set:
E 3
pytest_set_assertion.py:10: AssertionError
_________________________________________ test_proper_subset _________________________________________
def test_proper_subset():
> assert {1, 2, 3} < {1, 2, 4}
E assert {1, 2, 3} < {1, 2, 4}
E Extra items in left set:
E 3
pytest_set_assertion.py:14: AssertionError
___________________________________ test_proper_subset_equal_sets ____________________________________
def test_proper_subset_equal_sets():
> assert {1, 2, 3} < {1, 2, 3}
E assert {1, 2, 3} < {1, 2, 3}
E Sets are equal
pytest_set_assertion.py:18: AssertionError
___________________________________________ test_superset ____________________________________________
def test_superset():
> assert {1, 2, 3} >= {1, 2, 4}
E assert {1, 2, 3} >= {1, 2, 4}
E Extra items in right set:
E 4
pytest_set_assertion.py:22: AssertionError
________________________________________ test_proper_superset ________________________________________
def test_proper_superset():
> assert {1, 2, 3} > {1, 2, 4}
E assert {1, 2, 3} > {1, 2, 4}
E Extra items in right set:
E 4
pytest_set_assertion.py:26: AssertionError
__________________________________ test_proper_superset_equal_sets ___________________________________
def test_proper_superset_equal_sets():
> assert {1, 2, 3} > {1, 2, 3}
E assert {1, 2, 3} > {1, 2, 3}
E Sets are equal
pytest_set_assertion.py:30: AssertionError
====================================== short test summary info =======================================
FAILED pytest_set_assertion.py::test_equality - assert {1, 2, 3} == {1, 2, 4, 5}
FAILED pytest_set_assertion.py::test_inequality - assert {1, 2, 3} != {1, 2, 3}
FAILED pytest_set_assertion.py::test_subset - assert {1, 2, 3} <= {1, 2, 4}
FAILED pytest_set_assertion.py::test_proper_subset - assert {1, 2, 3} < {1, 2, 4}
FAILED pytest_set_assertion.py::test_proper_subset_equal_sets - assert {1, 2, 3} < {1, 2, 3}
FAILED pytest_set_assertion.py::test_superset - assert {1, 2, 3} >= {1, 2, 4}
FAILED pytest_set_assertion.py::test_proper_superset - assert {1, 2, 3} > {1, 2, 4}
FAILED pytest_set_assertion.py::test_proper_superset_equal_sets - assert {1, 2, 3} > {1, 2, 3}
========================================= 8 failed in 0.06s ==========================================
```
#### Additional context
<!-- Add any other context, links, etc. about the feature here. -->
+ Python 3.9.13 on Debian
+ pytest 7.2.0
author:
url:https://github.com/dougthor42
type:Person
name:dougthor42
datePublished:2022-12-28T23:43:52.000Z
interactionStatistic:
type:InteractionCounter
interactionType:https://schema.org/CommentAction
userInteractionCount:0
url:https://github.com/10617/pytest/issues/10617
Person:
url:https://github.com/dougthor42
name:dougthor42
url:https://github.com/dougthor42
name:dougthor42
InteractionCounter:
interactionType:https://schema.org/CommentAction
userInteractionCount:0
interactionType:https://schema.org/CommentAction
userInteractionCount:0
External Links {π}(2)
Analytics and Tracking {π}
- Site Verification - Google
Libraries {π}
- Clipboard.js
- D3.js
- GSAP
- Lodash
Emails and Hosting {βοΈ}
Mail Servers:
- aspmx.l.google.com
- alt1.aspmx.l.google.com
- alt2.aspmx.l.google.com
- alt3.aspmx.l.google.com
- alt4.aspmx.l.google.com
Name Servers:
- dns1.p08.nsone.net
- dns2.p08.nsone.net
- dns3.p08.nsone.net
- dns4.p08.nsone.net
- ns-1283.awsdns-32.org
- ns-1707.awsdns-21.co.uk
- ns-421.awsdns-52.com
- ns-520.awsdns-01.net