#4 Adapt doctest of tests.utils.http to work on Python 3.10 as well
Merged 3 years ago by churchyard. Opened 3 years ago by churchyard.
rpms/ churchyard/httpie python3.10-enum  into  rawhide

file added
+51
@@ -0,0 +1,51 @@ 

+ From 7a8d07bdc4ecdb624e6dd880b70ca8c0130bc3fe Mon Sep 17 00:00:00 2001

+ From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>

+ Date: Thu, 27 May 2021 19:48:13 +0200

+ Subject: [PATCH] Adapt doctest of tests.utils.http to work on Python 3.10 as

+  well

+ 

+ https://docs.python.org/3.10/whatsnew/3.10.html#enum

+ 

+ Python 3.10 changed the repr of enum members, and the doctest of tests.utils.http failed.

+ Exact reprs are unfortunately not considered stable API between Python releases:

+ 

+     =================================== FAILURES ===================================

+     __________________________ [doctest] tests.utils.http __________________________

+     209

+     210     Example:

+     211

+     212     $ http --auth=user:password GET pie.dev/basic-auth/user/password

+     213

+     214         >>> httpbin = getfixture('httpbin')

+     215         >>> r = http('-a', 'user:pw', httpbin.url + '/basic-auth/user/pw')

+     216         >>> type(r) == StrCLIResponse

+     217         True

+     218         >>> r.exit_status

+     Expected:

+         <ExitStatus.SUCCESS: 0>

+     Got:

+         ExitStatus.SUCCESS

+ 

+ A simple replacement of the expected output however breaks the doctest on Python 3.9.

+ 

+ This is the best solution I could think of

+ that keeps the docstring readable and doctest working in Pythons both old and new.

+ ---

+  tests/utils/__init__.py | 4 ++--

+  1 file changed, 2 insertions(+), 2 deletions(-)

+ 

+ diff --git a/tests/utils/__init__.py b/tests/utils/__init__.py

+ index 2cf0ce75..6e89d274 100644

+ --- a/tests/utils/__init__.py

+ +++ b/tests/utils/__init__.py

+ @@ -215,8 +215,8 @@ def http(

+          >>> r = http('-a', 'user:pw', httpbin.url + '/basic-auth/user/pw')

+          >>> type(r) == StrCLIResponse

+          True

+ -        >>> r.exit_status

+ -        <ExitStatus.SUCCESS: 0>

+ +        >>> r.exit_status is ExitStatus.SUCCESS

+ +        True

+          >>> r.stderr

+          ''

+          >>> 'HTTP/1.1 200 OK' in r

file modified
+5
@@ -21,8 +21,13 @@ 

  

  # Skip http://pie.dev tests when offline

  # Rebased slightly https://github.com/httpie/httpie/pull/1072

+ # Merged upstream

  Patch4:         1072.patch

  

+ # Adapt doctest of tests.utils.http to work on Python 3.10 as well

+ # Merged upstream

+ Patch5:         https://github.com/httpie/httpie/pull/1075.patch

+ 

  BuildArch:      noarch

  

  BuildRequires:  python3-devel

no initial comment

Pull-Request has been merged by churchyard

3 years ago
Metadata