File: pr19.patch

package info (click to toggle)
pytest-expect 1.1.0-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 80 kB
  • sloc: python: 175; makefile: 3
file content (102 lines) | stat: -rw-r--r-- 3,917 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
From 790d299540a33b677f2a3c27dac39b27efdc1e08 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= <joerg@thalheim.io>
Date: Wed, 25 Sep 2024 09:23:06 +0200
Subject: [PATCH] remove six and python2 support

---
 pytest_expect/expect.py | 30 +++++++-----------------------
 setup.py                | 12 +++++-------
 2 files changed, 12 insertions(+), 30 deletions(-)

diff --git a/pytest_expect/expect.py b/pytest_expect/expect.py
index dae1c8d..c4d15f4 100644
--- a/pytest_expect/expect.py
+++ b/pytest_expect/expect.py
@@ -16,7 +16,6 @@
 
 import pytest
 import umsgpack
-from six import PY2, PY3, text_type, binary_type
 
 _magic_file_line = b"pytest-expect file v"
 
@@ -88,9 +87,7 @@ def _parse_file(self, fp):
 
         # parse Python version line
         try:
-            line = next(fp)
-            if PY3:
-                line = line.decode("ascii")
+            line = next(fp).decode("ascii")
             version_info = ast.literal_eval(line)
             major, minor, micro, releaselevel, serial = version_info
         except (StopIteration, ValueError):
@@ -100,8 +97,7 @@ def _parse_file(self, fp):
         if version == 1:
             fails = set()
             for line in fp:
-                if PY3:
-                    line = line.decode("ascii")
+                line = line.decode("ascii")
                 try:
                     name, result = line.rsplit(":", 1)
                 except ValueError:
@@ -110,16 +106,11 @@ def _parse_file(self, fp):
                     raise SyntaxError("invalid pytest-expect file")
                 name = ast.literal_eval(name)
                 fails.add(name)
-                if PY3 and major == 2 and isinstance(name, bytes):
+                if major == 2 and isinstance(name, bytes):
                     try:
                         fails.add(name.decode("latin1"))
                     except UnicodeDecodeError:
                         pass
-                if PY2 and major == 3 and isinstance(name, unicode):
-                    try:
-                        fails.add(name.encode("latin1"))
-                    except UnicodeEncodeError:
-                        pass
             return fails
         else:
             raise SyntaxError("unknown pytest-expect file version")
@@ -129,22 +120,20 @@ def _raw_make_file(self, fails):
         yield repr(tuple(sys.version_info)) + "\n"
         for fail in sorted(fails):
             r = repr(fail)
-            if PY2 and isinstance(fail, str):
-                r = "b" + r
-            elif PY3 and isinstance(fail, str):
+            if isinstance(fail, str):
                 r = "u" + r
             yield "%s: FAIL\n" % r
 
     def _make_file(self, fp, fails):
         for line in self._raw_make_file(fails):
-            if isinstance(line, text_type):
+            if isinstance(line, str):
                 line = line.encode("ascii")
             fp.write(line)
 
     def _parse_legacy_file(self, fp):
         state = umsgpack.unpack(fp)
 
-        if PY3 and b'py_version' in state:
+        if b'py_version' in state:
             for key in list(state.keys()):
                 state[key.decode("ASCII")] = state[key]
                 del state[key]
@@ -160,13 +149,8 @@ def _parse_legacy_file(self, fp):
             xfail = state["expect_xfail"]
             for s in xfail:
                 fails.add(s)
-                if PY3 and py_version == 2 and isinstance(s, binary_type):
+                if py_version == 2 and isinstance(s, bytes):
                     fails.add(s.decode('latin1'))
-                elif PY2 and py_version == 3 and isinstance(s, text_type):
-                    try:
-                        fails.add(s.encode("latin1"))
-                    except UnicodeEncodeError:
-                        pass
         else:
             self.config.warn("W1", "test expectation file in unsupported version")
         return fails