Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/_pytest/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import argparse
import collections
import platform
import subprocess
import sys
import time

Expand Down Expand Up @@ -574,6 +575,11 @@ def pytest_sessionstart(self, session):
):
msg += " -- " + str(sys.executable)
self.write_line(msg)
pipe = subprocess.Popen("pip list", shell=True, stdout=subprocess.PIPE).stdout
package_msg = pipe.read()
package_msg = package_msg[:-2]
if package_msg:
self.write_line(package_msg)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this meant for debugging / this PR only?

lines = self.config.hook.pytest_report_header(
config=self.config, startdir=self.startdir
)
Expand Down
47 changes: 47 additions & 0 deletions testing/test_assertrewrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,53 @@ def __repr__(self):
assert "UnicodeDecodeError" not in msg
assert "UnicodeEncodeError" not in msg

def test_generator(self, testdir):
testdir.makepyfile(
"""
def check_even(num):
if num % 2 == 0:
return True
return False

def test_generator():
odd_list = list(range(1,9,2))
assert all(check_even(num) for num in odd_list)"""
)
result = testdir.runpytest()
result.stdout.fnmatch_lines(["*assert False*", "*where False = check_even(1)*"])

def test_list_comprehension(self, testdir):
testdir.makepyfile(
"""
def check_even(num):
if num % 2 == 0:
return True
return False

def test_list_comprehension():
odd_list = list(range(1,9,2))
assert all([check_even(num) for num in odd_list])"""
)
result = testdir.runpytest()
result.stdout.fnmatch_lines(["*assert False*", "*where False = check_even(1)*"])

def test_for_loop(self, testdir):
testdir.makepyfile(
"""
def check_even(num):
if num % 2 == 0:
return True
return False

def test_for_loop():
odd_list = list(range(1,9,2))
for num in odd_list:
assert check_even(num)
"""
)
result = testdir.runpytest()
result.stdout.fnmatch_lines(["*assert False*", "*where False = check_even(1)*"])


class TestRewriteOnImport(object):
def test_pycache_is_a_file(self, testdir):
Expand Down
9 changes: 9 additions & 0 deletions testing/test_terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,15 @@ def test_rewrite(self, testdir, monkeypatch):
tr.rewrite("hey", erase=True)
assert f.getvalue() == "hello" + "\r" + "hey" + (6 * " ")

def test_packages_display(self, testdir):
testdir.makepyfile(
"""
def test_pass(num):
assert 1 == 1"""
)
result = testdir.runpytest()
result.stdout.fnmatch_lines(["*Package Version *"])


class TestCollectonly(object):
def test_collectonly_basic(self, testdir):
Expand Down