#18 Fix duplicate requests in latest_requests() if there are chunks
Closed 2 years ago by jpopelka. Opened 2 years ago by packit.
rpms/ packit/python-httpretty 1.1.4-rawhide-src-1  into  rawhide

@@ -0,0 +1,76 @@ 

+ From 141555895002d6b933ad2b6f03ae402291d7a427 Mon Sep 17 00:00:00 2001

+ From: Eugene Morozov <jmv@emorozov.net>

+ Date: Mon, 13 Sep 2021 20:30:00 +0300

+ Subject: [PATCH 4/4] Fixes #425. (#436)

+ 

+ by @emorozov

+ ---

+  httpretty/core.py                 | 6 +++---

+  tests/functional/test_requests.py | 6 +++---

+  2 files changed, 6 insertions(+), 6 deletions(-)

+ 

+ diff --git a/httpretty/core.py b/httpretty/core.py

+ index 19715e0..6968645 100644

+ --- a/httpretty/core.py

+ +++ b/httpretty/core.py

+ @@ -796,7 +796,7 @@ class fakesock(object):

+                      else:

+                          self._entry.request.body += body

+  

+ -                    httpretty.historify_request(headers, body, sock=self)

+ +                    httpretty.historify_request(headers, body, sock=self, append=False)

+                      return

+  

+              if path[:2] == '//':

+ @@ -1602,7 +1602,7 @@ class httpretty(HttpBaseClass):

+          __internals__.cleanup_sockets()

+  

+      @classmethod

+ -    def historify_request(cls, headers, body='', sock=None):

+ +    def historify_request(cls, headers, body='', sock=None, append=True):

+          """appends request to a list for later retrieval

+  

+          .. testcode::

+ @@ -1618,7 +1618,7 @@ class httpretty(HttpBaseClass):

+          request = HTTPrettyRequest(headers, body, sock=sock)

+          cls.last_request = request

+  

+ -        if request not in cls.latest_requests:

+ +        if append or not cls.latest_requests:

+              cls.latest_requests.append(request)

+          else:

+              cls.latest_requests[-1] = request

+ diff --git a/tests/functional/test_requests.py b/tests/functional/test_requests.py

+ index 752428b..55aa109 100644

+ --- a/tests/functional/test_requests.py

+ +++ b/tests/functional/test_requests.py

+ @@ -407,7 +407,7 @@ def test_multiline():

+      expect(HTTPretty.last_request.body).to.equal(data)

+      expect(HTTPretty.last_request.headers['content-length']).to.equal('37')

+      expect(HTTPretty.last_request.headers['content-type']).to.equal('application/x-www-form-urlencoded; charset=utf-8')

+ -    expect(len(HTTPretty.latest_requests)).to.equal(2)

+ +    expect(len(HTTPretty.latest_requests)).to.equal(1)

+  

+  

+  @httprettified

+ @@ -431,7 +431,7 @@ def test_octet_stream():

+      expect(HTTPretty.last_request.body).to.equal(data)

+      expect(HTTPretty.last_request.headers['content-length']).to.equal('4')

+      expect(HTTPretty.last_request.headers['content-type']).to.equal('application/octet-stream')

+ -    expect(len(HTTPretty.latest_requests)).to.equal(2)

+ +    expect(len(HTTPretty.latest_requests)).to.equal(1)

+  

+  

+  @httprettified

+ @@ -452,7 +452,7 @@ def test_multipart():

+      expect(HTTPretty.last_request.body).to.equal(data)

+      expect(HTTPretty.last_request.headers['content-length']).to.equal('495')

+      expect(HTTPretty.last_request.headers['content-type']).to.equal('multipart/form-data; boundary=xXXxXXyYYzzz')

+ -    expect(len(HTTPretty.latest_requests)).to.equal(2)

+ +    expect(len(HTTPretty.latest_requests)).to.equal(1)

+  

+  

+  @httprettified

+ -- 

+ 2.34.1

+ 

file modified
+7 -2
@@ -20,8 +20,8 @@ 

  # Alternative for building from a github snapshot

  #Source0:        https://github.com/%%{github_owner}/%%{github_name}/archive/%%{github_commit}/%%{github_name}-%%{shortcommit}.tar.gz

  

- # Avoid unnecessary remote access requirement (note: test only actually

- # does a remote connection after PR #313)

+ # [PATCH 1/4] Apply patch

+ #  python-httpretty-fakesock_getpeercert_noconnect.patch

  Patch1: python-httpretty-fakesock_getpeercert_noconnect.patch

  

  # Remote access (these tests were skipped upstream in <= 0.9.7)
@@ -32,6 +32,11 @@ 

  # Fixes RHBZ#2046877

  Patch3: test_response-no-within.patch

  

+ # Fixes #425. (#436)

+ #

+ # by @emorozov

+ Patch4: 0004-Fixes-425.-436.patch

+ 

  BuildArch:      noarch

  

  %global _description\

https://github.com/gabrielfalcao/HTTPretty/issues/425


Info for package maintainer

This MR has been automatically created from
this source-git MR.
Please review the contribution and once you are comfortable with the content,
you should trigger a CI pipeline run via Pipelines → Run pipeline.

Pull-Request has been closed by jpopelka

2 years ago