Skip to content

Commit

Permalink
test: nicer way to test debug=pybehave
Browse files Browse the repository at this point in the history
  • Loading branch information
nedbat committed Feb 6, 2022
1 parent 4864c4f commit b60b789
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 4 additions & 3 deletions tests/test_cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

"""Test cmdline.py for coverage.py."""

import ast
import pprint
import re
import sys
Expand All @@ -20,7 +21,7 @@
from coverage.version import __url__

from tests.coveragetest import CoverageTest, OK, ERR, command_line
from tests.helpers import os_sep
from tests.helpers import os_sep, re_line


class BaseCmdLineTest(CoverageTest):
Expand Down Expand Up @@ -298,8 +299,8 @@ def test_debug_pybehave(self):
assert " CPYTHON:" in out
assert " PYVERSION:" in out
assert " pep626:" in out
pyversion = next(l for l in out.splitlines() if " PYVERSION:" in l)
vtuple = eval(pyversion.partition(":")[-1]) # pylint: disable=eval-used
pyversion = re_line(r" PYVERSION:", out)
vtuple = ast.literal_eval(pyversion.partition(":")[-1].strip())
assert vtuple[:5] == sys.version_info

def test_debug_premain(self):
Expand Down
5 changes: 3 additions & 2 deletions tests/test_debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

"""Tests of coverage/debug.py"""

import ast
import io
import os
import re
Expand Down Expand Up @@ -202,8 +203,8 @@ def test_debug_pybehave(self):
out_text = self.f1_debug_output(["pybehave"])
out_lines = out_text.splitlines()
assert 10 < len(out_lines) < 40
pyversion = next(l for l in out_lines if " PYVERSION:" in l)
vtuple = eval(pyversion.partition(":")[-1]) # pylint: disable=eval-used
pyversion = re_line(r" PYVERSION:", out_text)
vtuple = ast.literal_eval(pyversion.partition(":")[-1].strip())
assert vtuple[:5] == sys.version_info


Expand Down

0 comments on commit b60b789

Please sign in to comment.