suggestion: improve raises confusing message when matching
See original GitHub issue-
a detailed description of the bug or suggestion I would like
pytest.raises
to check if strings have parenthesis in them when match is not None, so that people have that lightbulb moment, rather than head-scratching when it presents two identical strings as not matching.E AssertionError: Pattern 'Length of values (29) does not match length of index (30)' does not match 'Length of values (29) does not match length of index (30)'
-
output of
pip list
from the virtual environment you are using I believe this is not applicable right now. I’m happy to provide one if you believe other modules or libraries are causing this behavior. -
pytest and operating system versions Windows 10 64-bit (I know), all updates installed Pytest 5.4.3
-
minimal example if possible edited 22:31 (same day) as the example given was the fixed code including escapes and r prefix
msg = ( f"Length of values ({len(newcolumndata)}) " f"does not match length of index ({len(data)})" ) with pytest.raises(MismatchedIndexValueError, match=msg):
I believe a more helpful error message
=============================================================================== warnings summary ===============================================================================
tests/whatever/file.py::test_whatever_function_name_is
file.py:42: UserWarning: non regex passed to match
-- Docs: https://docs.pytest.org/en/latest/warnings.html
=========================================================================== short test summary info ============================================================================
E AssertionError: Pattern 'Length of values (29) does not match length of index (30)' does not match 'Length of values (29) does not match length of index (30)'
Issue Analytics
- State:
- Created 3 years ago
- Comments:15 (15 by maintainers)
Top Results From Across the Web
When and How Do Message Matching Interventions Work?
we can compare different procedures that have been used in research to increase the specificity with which messages are made to match people's ......
Read more >Effective Communication - HelpGuide.org
Want to communicate better? These tips will help you get your message across, avoid misunderstandings, and improve your relationships.
Read more >10 Usability Heuristics for User Interface Design
10 Usability Heuristics for User Interface Design · #1: Visibility of system status · #2: Match between system and the real world ·...
Read more >Match.com Profile, Bio, Question, Answer Guide, Cost, Photos
Biggest Mistakes Made On Match.com Profiles, Bios, Photos ... wait to collect messages, likes, improved photos/profiles before deciding to ...
Read more >Issues - SonarQube Documentation
While running an analysis, SonarQube raises an issue every time a piece of code ... and on the same rule (but not necessarily...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I don’t think this is a good idea, because I may want to pass an actual regex which happens to be string-equal but not regex-match.
I think we can improve in these ways:
r
to the regex pattern, as another visual indicator that it’s a regex. (It would need to actually be valid of course).WDYT?
A check for exact equality + a value error on forgotten regex escape may prevent some headscratching