Commit Graph

128 Commits

Author SHA1 Message Date
Erik Bray b1595d3f61 Adds a test for and fixes #112. If attempting to write to the __pycache__ directory raises a permission error _write_pyc() should just return False to prevent any further write attempts. 2013-05-28 18:11:12 -04:00
holger krekel 05c4ecf892 fix recursion within import hook and source.decode in particular 2013-04-30 12:05:58 +02:00
Floris Bruynooghe 7a90515d49 Treat frozenset as a set
Thanks to Brianna Laugher.
2013-04-28 20:59:10 +01:00
Floris Bruynooghe 3c317dc35e Minor style cleanup 2013-04-28 20:56:56 +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
Benjamin Peterson 5e479c94ce disable assertion rewriting on CPython 2.6.0 because of bugs (fixes #280) 2013-03-21 12:19:01 -05:00
Benjamin Peterson 0cf79b29cd in the default Python 2 case, manually check the source is ASCII (fixes #269) 2013-03-08 10:44:41 -05:00
Benjamin Peterson 65edf87ea6 display the repr of some global names (fixes #171) 2013-01-10 11:59:08 -06: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 476d210d09 prolong workaround for jython AST bug http://bugs.jython.org/issue1497
to make pytest work for post-2.5.1 jython versions
2012-11-07 10:05:39 +01:00
holger krekel 002c5072af addresses issue209 - avoid error messages from pip on python2.4 related to file, however, never be imported with this interpreter 2012-11-06 09:08:54 +01:00
Floris Bruynooghe 1aca6c9d7c Fix extension of of cached re-written file
With PYTHONOPTIMIZE set this had the extension of "o" instead of ".pyo".
Fixes issue #168.
2012-07-07 16:09:53 +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 42d44bfd43 fix some pep8 issues, more to go ... is there a tool that helps with pep8-ifying? 2012-06-21 11:20:29 +02:00
holger krekel 2e163e4aae mention pep302 in docstring 2012-06-16 10:14:52 +02:00
Benjamin Peterson fe1c35f8d0 prepend the assertion rewriting hook, so as not to break when builtin import is explicitly on sys.meta_path 2012-05-05 17:31:05 -04:00
Benjamin Peterson b4588f1798 escape the % operator in string formatting 2012-05-03 13:49:30 -04:00
Ronny Pfannschmidt d02eaa8881 fix a import strange loop that affects pypy test appsupport on python2.5 2012-04-13 12:41:02 +02:00
Benjamin Peterson 45aa4e5229 remove unused import 2012-03-19 20:04:55 -04: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
Benjamin Peterson 45b98d6e70 cast boolean thing to int to make py3.3 happy 2011-10-14 18:08:10 -04:00
Benjamin Peterson 29b4082b00 put the explanation generating code in the conditional fail body (fixes #79) 2011-10-14 16:26:13 -04:00
holger krekel fb6fc673b8 don't try assertion rewriting on jython for now 2011-09-21 06:45:40 +02:00
Benjamin Peterson 2bc4065a00 rewrite file newlines when the python parser is picky 2011-09-20 17:53:07 -04:00
Benjamin Peterson 8675cf640d every boolop operand must have it's own format context (fixes #69) 2011-08-30 10:34:21 -04:00
Benjamin Peterson 8b211983ff clear instead of deleting temporary assertion variables 2011-08-30 00:24:57 -04:00
Benjamin Peterson 661a8a4a92 only use the last part of the module name in the filename (fixes #68) 2011-08-30 00:12:07 -04:00
Benjamin Peterson abe080c6b4 use different caches for optimized and unoptimized code (fixes #66) 2011-08-29 10:13:00 -04:00
Benjamin Peterson 9675b0f65c factor out win32 checks 2011-08-18 18:15:30 -05:00
Benjamin Peterson 6ca3c980bf same as 6e94b1809f67: ENOTDIR is ENOENT on windows 2011-08-18 14:49:17 -05:00
Benjamin Peterson 5bd34f8ecc windows kicks up a ENOENT when a part of the path is not a dir 2011-08-18 14:39:57 -05:00
Benjamin Peterson c5dee7b549 _make_rewritten_pyc doesn't need to return anything 2011-07-25 21:42:57 -05:00
Benjamin Peterson 643ab120f4 only try to create the __pycache__ dir (not a tree to it) fixes #60
Also, improve error handling surrounding __pycache__ creation.
2011-07-25 21:40:38 -05:00
Benjamin Peterson 2c4964d290 escape '%' in specialized comparison explanations (fixes #63) 2011-07-19 21:42:00 -05:00
holger krekel 43113f9a9d add some debugging tracing to assertion rewriting to understand where failures (specifically issue60) come from. 2011-07-14 19:17:17 +02:00
Benjamin Peterson 7576b3c7d0 fix assertion rewriting on calls with a double-star arg 2011-07-14 11:45:42 -05:00
Benjamin Peterson 3cc8697744 respect sys.dont_write_bytecode and PYTHONDONTWRITEBYTECODE 2011-07-13 13:33:54 -05:00
Benjamin Peterson 14ceaf2459 fix assertion rewriting in read-only directories (refs #60) 2011-07-12 17:09:14 -05:00
Michał Bartoszkiewicz 6096aeca53 Fix a typo in assertion rewriting. 2011-07-11 11:57:47 +02:00
Benjamin Peterson 8cd68494bf update assertion option names 2011-07-10 21:02:36 -05:00
Benjamin Peterson bc66cd85b1 customize pyc tag based on implementation 2011-07-08 13:53:23 -05:00
Benjamin Peterson 639f35bbc4 on windows, rename is not atomic, so utilize exclusive access to the file 2011-07-08 13:17:42 -05:00
Benjamin Peterson fb043c355e use py.builtin.exec_ 2011-07-07 09:27:40 -05: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
Benjamin Peterson 4e8b9fab3c insure moving pyc files around is atomic 2011-07-05 12:02:53 -05:00
holger krekel d105e75d87 fix pytest-xdist breakage 2011-07-05 18:01:31 +02: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 fefdca5787 simplify 2011-06-29 14:00:13 -05:00
Benjamin Peterson c7d120ec1c we want second resolution on mtime 2011-06-29 13:55:26 -05:00
Benjamin Peterson 1707168b62 don't try to remove pycs twice 2011-06-29 12:16:47 -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 d52ff3e2b9 use a plain old list for queuing 2011-06-28 21:11:56 -05:00
Benjamin Peterson f286a02582 rewrite with proper short-circuting on boolean operators (fixes #57) 2011-06-28 20:21:22 -05:00
Benjamin Peterson c6e3606c6b fix the rewriter on relative imports (fixes #58) 2011-06-28 10:39:11 -05:00
Benjamin Peterson 8772b8c928 fix name 2011-06-13 08:50:50 -05:00
Benjamin Peterson 8e81ed693a put explanation simplification in format_explanation so everyone can benefit 2011-06-12 22:41:58 -05:00
Benjamin Peterson d853d9a9af treat local as a black box 2011-06-12 21:57:22 -05:00
Benjamin Peterson 57a3d4d6d8 some tweaks to allow pypy apptests to use newinterpret 2011-06-12 17:07:49 -05:00
Benjamin Peterson 43de6c270f fix assertion introspection on python 3.2+ 2011-06-03 16:51:49 -05:00
Benjamin Peterson 5e31624315 return to the old scheme of rewriting test modules from _importtestmodule 2011-05-28 18:47:16 -05:00
Benjamin Peterson 5f75c5851f can use non-underscored addoption 2011-05-26 23:15:33 -05:00
Benjamin Peterson e56838cb6c write an explicit raise if the assertion fails 2011-05-26 21:15:40 -05:00
Benjamin Peterson d53feaf6f0 fix help for --assertmode 2011-05-26 20:59:43 -05:00
Benjamin Peterson 914f689ee8 beef up --assertmode help 2011-05-26 20:33:12 -05:00
Benjamin Peterson abb07fc732 new way to rewrite tests: do it all during fs collection
This should allow modules to be rewritten before some other test module loads
them.
2011-05-26 19:57:30 -05:00
Benjamin Peterson 657522b629 a less ugly way to detect if assert rewriting is enabled 2011-05-26 17:17:48 -05:00
Benjamin Peterson bf3d9f3737 correct attribute name 2011-05-26 16:18:18 -05:00
Benjamin Peterson 32a67f9622 add some tracing in the assert plugin 2011-05-26 16:08:25 -05:00
Benjamin Peterson d438a0bd83 introduce --assertmode option 2011-05-26 14:34:27 -05:00
Benjamin Peterson d3645758ea this comment was moved away 2011-05-26 13:17:39 -05:00
Benjamin Peterson 15b9e8ed7d forgot to util module 2011-05-26 13:17:26 -05:00
Benjamin Peterson ee64da4bad fix grammar 2011-05-26 13:15:21 -05:00
Benjamin Peterson 4fe13e59a7 fix comment 2011-05-26 13:15:03 -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 491c05cea7 create the _pytest/assertion package 2011-05-25 16:18:45 -05:00