[issue27132] New assert method that checks an error message for a list of strings

2022-03-22 Thread Irit Katriel


Irit Katriel  added the comment:

> Personally I'd write multiple asserts rather than regex permutations.

I would too, because then when one of them fails it's clear which of the 
strings is missing.

--
nosy: +iritkatriel

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27132] New assert method that checks an error message for a list of strings

2016-05-28 Thread R. David Murray

R. David Murray added the comment:

The complexity of those solutions argues in favor of adding a method, I'd say.

Personally I'd write multiple asserts rather than regex permutations.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27132] New assert method that checks an error message for a list of strings

2016-05-28 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

The simple way is just write all possible variants 
('ENABLE.*NOAUTH|NOAUTH.*ENABLE').

The general way is to use itertools.permutations():

pattern = '|'.join(map('.*'.join, permutations(map(re.escape, strings

See also similar problem in issue19681. The first my patch used permutations(). 
But there was committed the patch with manually written variants.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27132] New assert method that checks an error message for a list of strings

2016-05-28 Thread R. David Murray

R. David Murray added the comment:

Serhiy, how do you spell "match if and only if all of the following substrings 
exist in the target string, in any position" in a regex?  If we aren't going to 
add the method, we should add an example of how to do this to the 
assertMsgRegex docs.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27132] New assert method that checks an error message for a list of strings

2016-05-26 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

This issue looks similar to issue24922, and I think it should be closed for 
same reasons.

--
nosy: +berker.peksag, ezio.melotti, michael.foord, rbcollins

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27132] New assert method that checks an error message for a list of strings

2016-05-26 Thread Martin Panter

Martin Panter added the comment:

Maybe a generic superset test would be good enough:

def assertSuperset(self, superset, subset):
# Expand for friendlier failure handling
self.assertTrue(all(e in superset for e in subset))

self.assertSuperset("Error message", ("mess", "or me"))

Or is that too obscure, treating a string as a set of substrings?

--
nosy: +martin.panter

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27132] New assert method that checks an error message for a list of strings

2016-05-26 Thread Maciej Szulik

Maciej Szulik added the comment:

You could, but then you end up writing nasty regex-es to do that. The idea here 
is to create a native function that will verify a number of words in whatever 
order.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27132] New assert method that checks an error message for a list of strings

2016-05-26 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

You can use assertRaisesRegex() for this.

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27132] New assert method that checks an error message for a list of strings

2016-05-26 Thread Maciej Szulik

New submission from Maciej Szulik:

To quote David from 
http://bugs.python.org/review/25591/diff/16398/Lib/test/test_imaplib.py:

"I've been thinking I'd like a new assert method that checks an error message 
for a list of strings in any order, but I haven't opened an issue for it :)"

--
components: Tests
messages: 266454
nosy: maciej.szulik, r.david.murray
priority: normal
severity: normal
status: open
title: New assert method that checks an error message for a list of strings
type: enhancement

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com