pytest would emit false positive warnings about assertion-rewrite when a
module appears multiple times in plugins which depend
on other plugins using the 'pytest_plugins' mechanism
This addresses ref https://github.com/pytest-dev/pytest/issues/1954.
The current truncation for assertion explanations does not deal with long lines
properly:
- Previously if lines were too long it would display a "-n more lines"
message.
- 999e7c6541 introduced a bug where long lines can
cause index errors if there are < 10 lines.
Extract the truncation logic into its own file and ensure it can deal with
long lines properly.
Running through some of my tests with the `-3` flag in python2.7 I encountered some errors within py.test itself. This fixes those errors so we can use py.test in order to identify problems with Python 3.
Part two of https://github.com/pytest-dev/pytest/issues/1512. Update the format
of the truncation message to help make it clear that pytest truncates the
entire assertion output when verbosity < 2.
Part one of https://github.com/pytest-dev/pytest/issues/1512.
If verbosity=1, assertion explanations are truncated at 10 lines. In this
situation, it's more important to tell the user which dictionary items are
different than which are the same.
We used to have this when we where patching the real Python
AssertionError for use with reinterpret, but reinterpret is now
gone so we no longer need this as it is not used by rewrite.
The assertion reinterpretation is an old backwards compatibility
mode which was no longer being maintained on feature-parity with
the assertion rewriting mode. It was also responsible for some
dubious patching of builtins and test with side-effects would
suddenly start passing. Since re-writing has been the default for
a long time and plugins are now also re-written it is time to
retire reinterpretation.
Hook up the PEP 302 import hook very early in pytest startup so
that it gets installed before setuptools-installed plugins are
imported. Also iterate over all installed plugins and mark them
for rewriting. If an installed plugin is already imported then
a warning is issued, we can not break since that might break
existing plugins and the fallback will still be gracefull to
plain asserts.
Some existing tests are failing in this commit because of the new
warning triggered by inline pytest runs due to the hypothesis
plugin already being imported. The tests will be fixed in the next
commit.