'Test Request.replace() method'

def test_replace(self):

    r1 = self.request_class('http://www.example.com', method='GET')
    hdrs = Headers(r1.headers)
    hdrs['key'] = 'value'
    r2 = r1.replace(method='POST', body='New    body', headers=hdrs)
    self.assertEqual(r1.url, r2.url)
    self.assertEqual((r1.method, r2.method), ('GET', 'POST'))
    self.assertEqual((r1.body, r2.body), ('', 'New    body'))
    self.assertEqual((r1.headers, r2.headers), (self.default_headers, hdrs))
    r3 = self.request_class('http://www.example.com', meta={'a': 1}, dont_filter=True)
    r4 = r3.replace(url='http://www.example.com/2', body='', meta={}, dont_filter=False)
    self.assertEqual(r4.url, 'http://www.example.com/2')
    self.assertEqual(r4.body, '')
    self.assertEqual(r4.meta, {})
    assert (r4.dont_filter is False)
