Skip to content
This repository was archived by the owner on Sep 14, 2023. It is now read-only.

Commit d18a4a2

Browse files
authored
Remove Python 2 compatibility code (#86)
Since pytest-molecule requires Python 3.6 or newer, having compatibility code makes no sense anymore.
1 parent 3145e28 commit d18a4a2

File tree

1 file changed

+7
-26
lines changed

1 file changed

+7
-26
lines changed

pytest_molecule/__init__.py

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -182,15 +182,13 @@ def runtest(self):
182182
# Workaround for STDOUT/STDERR line ordering issue:
183183
# https://github.com/pytest-dev/pytest/issues/5449
184184

185-
if sys.version_info.major == 2:
186-
# https://bugs.python.org/issue13202
187-
proc = subprocess.Popen(
188-
cmd,
189-
cwd=cwd,
190-
stdout=subprocess.PIPE,
191-
stderr=subprocess.STDOUT,
192-
universal_newlines=True,
193-
)
185+
with subprocess.Popen(
186+
cmd,
187+
cwd=cwd,
188+
stdout=subprocess.PIPE,
189+
stderr=subprocess.STDOUT,
190+
universal_newlines=True,
191+
) as proc:
194192
for line in proc.stdout:
195193
print(line, end="")
196194
proc.wait()
@@ -200,23 +198,6 @@ def runtest(self):
200198
% (proc.returncode, " ".join(cmd)),
201199
pytrace=False,
202200
)
203-
else:
204-
with subprocess.Popen(
205-
cmd,
206-
cwd=cwd,
207-
stdout=subprocess.PIPE,
208-
stderr=subprocess.STDOUT,
209-
universal_newlines=True,
210-
) as proc:
211-
for line in proc.stdout:
212-
print(line, end="")
213-
proc.wait()
214-
if proc.returncode != 0:
215-
pytest.fail(
216-
"Error code %s returned by: %s"
217-
% (proc.returncode, " ".join(cmd)),
218-
pytrace=False,
219-
)
220201
except Exception as exc: # pylint: disable=broad-except
221202
pytest.fail(
222203
"Exception %s returned by: %s" % (exc, " ".join(cmd)), pytrace=False

0 commit comments

Comments
 (0)