Additional test case to 'Matching Brackets'

I suggest to add addtional test case to ‘Matching Brackets’ exersize. Something like this:

def test_new_pair_at_the_end(self) -> None:                                                                            
    self.assertEqual(is_paired("([]){}"), True)    

The reason is that i managed to pass all test with wrong solution:

def is_paired(input_string):
    input_string_filtered=''.join(symbol for symbol in input_string if (symbol in OPENERS or symbol in CLOSERS))
    while input_string_filtered!='':
        if input_string_filtered[0] in OPENERS and len(input_string_filtered)%2==0:
            end_checker= CLOSERS.index(input_string_filtered[-1]) if input_string_filtered[-1] in CLOSERS else 4
            neighbor_checker=CLOSERS.index(input_string_filtered[1]) if input_string_filtered[1] in CLOSERS else 4
            if OPENERS.index(input_string_filtered[0])==neighbor_checker:
            elif OPENERS.index(input_string_filtered[0])==end_checker:
    return all_paired

Care to explain in English succinctly what class of solutions that additional test would catch and why you think it would add value?

If there is a common/easy mistake to make that this catches, that can justify updating the exercise across tracks. Do you feel like this is a likely bug? Do you see it in any other community solutions?

If this is a very narrow bug that is unlikely to hit anyone else, it might be much harder to justify the change.

Most of the test cases of this exersize with ‘True’ result provide one pair of brackets with some combination of nested pairs inside it.
One exception is “test_several_paired_brackets” test. It provides two empty pairs of brackets.
I suggest to add test which will have at least two seperate pairs of brackets like in “test_several_paired_brackets” but with one of the pairs containing aditional nested pairs.

My reasoning:
The code above strips input string of everything but brackets. Then it starts while loop on modifeid string.
Inside while loop string gets stripped of every pair of brackets until it fails to find a pair for bracket in not empty string.
On every iteration of loop it is assumed that opener is the fist element of the string and closer is the second or the last.
This solution passes every current test but will not pass the one i suggested.

I didn’t find something akin to my solution among all other community solutions. Maybe I’m am unique kind of stupid.

Hope I wasn’t too verbosely.

If this test had existed, would your solution just be to add a third check, that the closer is second, last or ?

The fact that you need to check two locations already is a good indication that there may be a better approach. If you were happy to check two locations, would the test get you to add a third location or rethink your approach?

The thing is - I’ve got the idea of my solution from looking at tests. I’m pretty sure I would have stopped with my line of thought with suggested test in there.

I agree that needing to check two locations is an indication that there may be a better approach but it does not indicate that the approach in itself is wrong.