Commit Graph

50 Commits

Author SHA1 Message Date
Ronny Pfannschmidt 49c99a41ea reencode non-ascii python2 assertion reprs, fixes #877
i decided against using a warning since the problem goes away with python3
the support code can be removed once we drop python2 in 10 years or so
2015-09-19 00:30:01 +02:00
Bruno Oliveira dd7112d5ea Show a few diff lines when truncating string diffs
Fix #934
2015-08-27 22:20:13 -03:00
holger krekel ee40ea5f6d Merge branch 'pytest-2.7'
Conflicts:
	AUTHORS
	_pytest/__init__.py
	setup.py
	testing/conftest.py
	tox.ini
2015-06-23 16:49:05 +02:00
Edison Gustavo Muenz 48d91def7e Added workaround to still show the diff on containers with unsortable elements.
fix issue #718
2015-06-19 07:51:59 -03:00
holger krekel a8afba054a - refine lsof checking
- make runpytest() create an inline testing process instead of
  a subprocess one

--HG--
branch : testrefactor
2015-04-28 11:54:46 +02:00
holger krekel d3e363b97a - make API between runpytest() and inline_run() more similar
- shift a number of tests to become inline_run() tests

--HG--
branch : testrefactor
2015-04-28 11:54:45 +02:00
Anatoly Bubenkov 72e6f55b45 Improve assertion failure reporting on iterables, by using ndiff and pprint.
--HG--
branch : better-diff-on-verbose-2
2014-09-27 01:29:47 +00:00
Floris Bruynooghe 37bd1e03cb Show user assertion messages and instrospection together
User provided messages, or any valid expression given as second
argument to the assert statement, are now shown in addition to the
py.test introspection details.  Formerly any user provided message
would entirely replace the introspection details.

Fixes issue549.
2014-08-23 18:14:25 +02:00
holger krekel 07e76cbef2 fix issue364: shorten and enhance tracebacks representation by default.
The new "--tb=auto" option (default) will only display long tracebacks
for the first and last entry.  You can get the old behaviour of printing
all entries as long entries with "--tb=long".  Also short entries by
default are now printed very similarly to "--tb=native" ones.
2014-06-29 13:32:53 +02:00
holger krekel 54c88a6cf3 fix flakes issues 2014-06-16 11:27:32 +02:00
Benjamin Peterson fd9055fd11 fix test on Python 3.2 2014-05-31 14:51:05 -07:00
Floris Bruynooghe adb12d0d4f Escape newlines in result from assertrepr hook
The result from the pytest_assertrepr_compare hook should not include
any newlines since that will confuse the mini-formatting language used
by assertion.util.format_explanation.  So simply escape the included
newlines, this way hook writers do not have to worry about this at
all.

Fixes issue 453.
2014-04-02 17:35:22 +01:00
Floris Bruynooghe 825ea9bfa1 Fix assertrepr for mojibake
If the compared text was in bytes and not actually valid text
(i.e. could not be encoded to text/unicode using the default encoding)
then the assertrepr would fail with an EncodingError.  This ensures
that the internal string is always valid unicode, converting any bytes
safely to valid unicode.  This is done using repr() which then needs
post-processing to fix the encompassing quotes and un-escape newlines.

This fixes issue 429.
2014-01-29 00:42:58 +00:00
holger krekel 307a41339c fix expicit assert messages for Python2.6: it turns out python2.6
instantiates the AssertionError differently for tuples.  Test
and fix to neutralize it.
2013-12-12 06:41:48 +01:00
Floris Bruynooghe e3a945a0b5 Add test for unicode assertion descriptions
Also clean up a few debugging leftovers.
2013-11-29 00:29:14 +00:00
holger krekel 8ac5af2896 fix flakes issues and make --flakes run part of tox runs 2013-10-12 15:39:22 +02:00
holger krekel 8f24e10571 add changelog entry for anthon's hynek-fication of options,
and change the docs and tests to use the new style.
2013-08-01 17:32:19 +02:00
holger krekel cbbbfcd101 fix collection imports for python2.5 2013-08-01 15:38:03 +02:00
Mathieu Agopian 72a48d69cd refs #279: sequence assertions can also deal with (Mutable)Sequence instances 2013-08-01 14:48:34 +02:00
holger krekel 05c4ecf892 fix recursion within import hook and source.decode in particular 2013-04-30 12:05:58 +02:00
holger krekel c5f9958783 never consider a fixture function for test function collection 2013-04-29 10:31:51 +02:00
Floris Bruynooghe 7a90515d49 Treat frozenset as a set
Thanks to Brianna Laugher.
2013-04-28 20:59:10 +01:00
Floris Bruynooghe f31dc7a8b7 Attempt to improve detailed failure reporting
* If --verbose is used do not truncate.

* Add a special dict comparison instead of diffing
  pprint output.
2013-03-28 01:39:01 +00:00
holger krekel 456731ed0f fix issue257 assertion-triggered compilation of source ending in a
comment line doesn't blow up in python2.5 (fixed through py>=1.4.13.dev6)
2013-02-12 22:43:33 +01:00
holger krekel 22dd5e29e2 when informations gets truncated, mention use of "-vv" to see it. 2012-11-30 12:18:12 +01:00
holger krekel 4f94ab4e42 mark a test as xfailing on python2.5 2012-08-01 09:10:40 +02:00
Ronny Pfannschmidt 74e55493d1 test and implement showing verbose assert repr for py.test -vv 2012-06-27 17:26:55 +02:00
holger krekel 91b6f2bda8 mid-scale refactoring to make request API available directly on items.
This commit was slightly tricky because i want to backward
compatibility especially for the oejskit plugin which
uses Funcarg-filling for non-Function objects.
2012-06-25 17:35:33 +02:00
Floris Bruynooghe e2201fe3a9 Look up the pytest_assertrepr_compare hook for each test item
Before this was only done at the time the assertion plugin was loaded.
This lead to counter-intuitive behaviour where two subdirectories with
a pytest_assertrepr_compare hook in their conftest.py would not work,
only one would ever be used.

This defers assiging the _pytest.assertion.util._reprcompare function
until the item is loaded (pytest_runtest_setup) so that it can use the
hookrelay of the test item to find the appropriate
pytest_assertrepr_compare hook for the item.

This fixes issue #77.
2011-10-16 11:51:15 +01:00
holger krekel d37af98db3 try to make test suite pass on jython 2.5.1 again 2011-09-21 08:12:37 +02:00
Benjamin Peterson c13fa886d9 simplify rewrite-on-import
Use load_module on the import hook to load the rewritten module. This allows the
removal of the complicated code related to copying pyc files in and out of the
cache location. It also plays more nicely with parallel py.test processes like
the ones found in xdist.
2011-07-06 23:24:04 -05:00
holger krekel 46950ef19a rename and simplify the assert option:
cmdline usage is now: --assert=rewrite/reinterp/plain
there is no conflict detection (don't think that's neccessary)
2011-07-05 17:29:53 +02:00
holger krekel 407ca5b120 fix python2.5 compatibility 2011-07-05 15:21:08 +02:00
Benjamin Peterson a4fe63c08d test files are rewritten in a subprocess 2011-07-03 19:28:48 -05:00
Benjamin Peterson ae8ee08ac0 adjust for new option 2011-06-29 13:28:04 -05:00
Benjamin Peterson aa7f7a1c71 rename --assertmode choices to be more explicit 2011-06-29 09:44:04 -05:00
Benjamin Peterson 48b76c7544 rewrite test modules on import 2011-06-28 21:13:12 -05:00
Benjamin Peterson 971f34147a test that tests get rewritten 2011-05-26 20:06:11 -05:00
Benjamin Peterson d438a0bd83 introduce --assertmode option 2011-05-26 14:34:27 -05:00
Benjamin Peterson 250160b4b0 refactor explanation formatting things into their own module 2011-05-26 12:01:34 -05:00
Benjamin Peterson f423ce9c01 import assertion code from pylib 2011-05-25 17:54:02 -05:00
Benjamin Peterson f5decc90ca test that python loads our fake pycs 2011-05-24 17:52:17 -05:00
holger krekel 942ae47cd1 tentatively use internal list for cleanups at unconfigure time - this helps reporting with partially executed pytest_configure() hooks 2011-04-17 12:20:13 +02:00
Floris Bruynooghe 2f2586af72 Fix pytest_assertrepr_compare on python3 (issue24)
The maxsize argument must be an integer and the devision syntax changed
between python2 and python3.
2011-02-15 23:24:18 +00:00
holger krekel adacd3491d fix test related to "not in" 2011-01-27 11:36:12 +01:00
holger krekel 4445685285 pypy doesn't neccessarily honour -OO it seems, let's not test assertions there. 2011-01-12 18:57:40 +01:00
Floris Bruynooghe 8631c1f57a Add "not in" to detailed explanations
This simply uses difflib to compare the text without the offending
string to the full text.

Also ensures the summary line uses all space available.  But the
terminal width is still hardcoded.
2010-12-10 01:03:26 +00:00
holger krekel 821f493378 check docstring at test time instead of runtime, improve and test warning on assertion turned off (thanks FND for reporting) 2010-12-09 11:00:31 +01:00
holger krekel a698465487 streamline docs, especially use "import pytest" and "pytest.*" in python code examples instead of "import py" and "py.test.*". 2010-11-17 22:12:16 +01:00
holger krekel 076e03e90f also un-nest test directory 2010-11-13 11:30:40 +01:00