1

I need to return different desponses depending on the GET parameters via HTTPretty:

@httpretty.activate
def test_multiple_requests():
    httpretty.register_uri(httpretty.GET, 'https://example.com/data.xml?n=0',
                           body='0')

    httpretty.register_uri(httpretty.GET, 'https://example.com/data.xml?n=1',
                           body='1')

    r = requests.get('https://example.com/data.xml?n=0')
    print(r.text)

    r = requests.get('https://example.com/data.xml?n=1')
    print(r.text)

This code prints the following:

1
0

Why? I thought that it should be

0
1

instead.

FrozenHeart
  • 19,844
  • 33
  • 126
  • 242
  • What are you looking to test? Are you looking to control what GET should return, so you can test something else? – idjaw Mar 11 '16 at 13:23
  • Have you tried using [Mock](http://www.voidspace.org.uk/python/mock/). Mock out the GET, make it return the value you expect to continue testing based on those return values. – idjaw Mar 11 '16 at 13:26

0 Answers0