M
M
maxclax2015-03-31 11:14:24
Django
maxclax, 2015-03-31 11:14:24

How to test text on a mask?

I have code:

def test_html_return(self):
        print('>> Admin:GravatarHelpersTest Тест на возвращаемый HTML')

        html = '<img class="gravatar" src="https://secure.gravatar.com/avatar/64e1b8d34f425d19e1ee2ea7236d3028.jpg?d=mm&r=g&s=50" width="50"/>'
        self.assertEqual(helpers.gravatar('[email protected]', 50), html)

the bottom line is that the gravatar returns constantly dynamic parameters. ?d=mm&r=g&s=50 they can be and ?d=mm&s=50&r=g constantly in a different order. And it turns out that the test passes through with a probability of 1 to 3. How can I get around this so that the check does not take into account this particular line ?d=mm&r=g&s=50?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Guest007, 2015-04-09
@Guest007

Well, the simplest is to split the strings multiple times. First by "spaces", then by "quotes", then by "question". And now you have d=mm&r=g&s=50 in your hands. And you already split it by "&" and then by "=" with entering it into the dictionary. Everything. You have a dictionary with key-value pairs, the order is not important - you can check the presence and value of any key. Delov something on a few lines. It is better to issue a separate function or method. Well, or an exercise for lovers of lambda and one-liners :-)
You can also parse regular expressions again to the state of a dictionary.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question