Commit Graph

88 Commits

Author SHA1 Message Date
Michal Wajszczuk fb0b90646e New-style classes implemented for python 2.7 - #2147 2017-02-16 20:28:17 +01:00
Bruno Oliveira 043aadeaf2 Consider plugins loaded by PYTEST_PLUGINS for assertion rewrite
Fix #2185
2017-01-11 17:15:16 -02:00
Bruno Oliveira bc0f7e6243 Fix false-positive assert rewrite warnings when using 'pytest_plugins'
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
2016-12-01 15:50:08 -02:00
Ronny Pfannschmidt a5b5090c72 Merge pull request #2070 from nedbat/bug2038
Don't fail if imp can't find the source for a .pyc file. #2038
2016-11-22 17:45:29 +01:00
Bruno Oliveira 1eb5a690d4 Fix flake8 E305 and E306 errors
These errors started to appear with flake8-3.1.1, while they don't appear with
version 3.1.0 (weird).
2016-11-20 18:59:15 -02:00
Ned Batchelder 06bb61bbe3 Don't fail if imp can't find the source for a .pyc file. #2038 2016-11-20 13:09:32 -05:00
Bruno Oliveira 2a2b8cee09 Fix false-positive warnings from assertion rewrite hook
Fix #2005
2016-10-20 21:40:57 -02:00
Bruno Oliveira 6711b1d6ab Rewrite asserts in test-modules loaded very early in the startup
Also now match modules which start with any of the names registered
using register_assert_rewrite as discussed in #1787

Fix #1784
2016-08-03 12:49:48 -03:00
Floris Bruynooghe a98e3cefc5 Enable re-writing of setuptools-installed plugins
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.
2016-07-13 17:29:19 +01:00
Ronny Pfannschmidt b9a91dc112 merge from master to features 2016-07-06 11:51:48 +02:00
RedBeardCode e2f550156e Improve of the test output for logical expression with brackets.
Fixes #925
2016-06-25 18:10:36 +02:00
Tom Viner 77689eb486 Fixes #1503 no longer collapse false explanations 2016-06-24 15:35:24 +02:00
Bruno Oliveira 3a81d2e012 conftest files now use assertion rewriting
Fix #1619
2016-06-20 23:13:29 +02:00
Bruno Oliveira 51694b8295 Merge branch 'master' into issue1290-at-operator 2016-02-06 09:31:42 -02:00
TomV 7d107018e8 Fix #1290: Py3.5's @ operator/assertion rewriting. 2016-02-05 23:09:57 +00:00
Bruno Oliveira a912d3745b Moved py.code code over to py.test
Fix #103
2016-01-25 23:18:04 -02:00
Bruno Oliveira 2ffd37b816 return non-zero exit code if no tests are collected
Fix #812
Fix #500
2015-08-18 07:35:02 -03:00
Bruno Oliveira 7445c5bd70 Add support for PEP302 get_data API
Fix #808
2015-07-11 14:13:43 -03:00
Floris Bruynooghe aa2ffb9805 Merge fix for issue 731 from pytest-2.7 2015-04-30 21:13:03 +01:00
Floris Bruynooghe 7f554f50e3 Fix collapse false to look at unescaped braces only
Sometimes the repr of an object can contain the "\n{" sequence which is
used as a formatting language, so they are escaped to "\\n{".  But the
collapse-false code needs to look for the real "\n{" token instead of
simply "{" as otherwise it may get unbalanced braces from the object's
repr (sometimes caused by the collapsing of long reprs by saferepr).

Fixes issue #731.

--HG--
branch : pytest-2.7
2015-04-30 02:31:12 +01:00
holger krekel db5649ec6a streamline pytester API majorly:
- integrate conftest into pytester plugin
- introduce runpytest() to either call runpytest_inline (default) or
  runpytest_subprocess (python -m pytest)
- move testdir.inline_runsource1 to pdb tests
- strike some unneccessary methods.
- a new section "writing plugins" and some better pytester docs

--HG--
branch : testrefactor
2015-04-28 11:54:53 +02: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
Daniel Hahler c629f6b18b Fix `reload()` with modules handled via `python_files`
If a module exists in `sys.modules` already, `load_module` has to return it.

Fixes https://bitbucket.org/pytest-dev/pytest/issue/435

--HG--
branch : fix-reload
2015-03-04 16:21:27 +01:00
TomV f6caf230f8 fix for issue615: _format_boolop must escape %
fix test for issue615: expression must eval False

--HG--
branch : format_boolop_percent6
2014-10-27 08:57:58 +00:00
TomV f8623a6668 test for issue615: compound assert with percent
--HG--
branch : assert_percent_test
2014-10-13 09:26:18 +01:00
Anatoly Bubenkov a759da0208 Escape % character in the assertion message. closes #604 2014-10-07 01:01:21 +02:00
holger krekel 79d2edcbff Merged in flub/pytest (pull request #207)
Show both user assertion msg as explanation (issue549)
2014-09-22 19:16:10 +02:00
Benjamin Peterson d4cd1aad8e improvements to rewrite cache invalidation
- stat the source path before it is read.
- Validate the source size in addition to mtime.
2014-09-01 16:51:27 -04: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
Floris Bruynooghe 424479cf0f Escape newlines in repr for assertion rewriting
The assertion formatting mini-language depends on newlines being
escaped.  Unfortunately if the repr of an object contained
newlines the rewriting module did not escape those, which is now
fixed.

Fixes issue453.
2014-08-18 20:07:38 +02:00
Bruno Oliveira fd4485a540 Fixed assertionrewrite._read_pyc to handle corrupted pyc files properly
This seems to be the cause for issues #437 and #301.

--HG--
branch : assertionrewrite-currupted-pyc
2014-08-02 18:01:28 -03:00
Marc Abramowitz 555ba4159d Simplify tests; don't use u literal not supported in py32
--HG--
branch : makepyfile_utf8
2014-03-28 12:11:33 -07:00
Marc Abramowitz f47ae74981 Make makepyfile accept UTF-8 so a few cookie tests in test_assertrewrite.py
don't need to be dedented.

--HG--
branch : makepyfile_utf8
2014-03-28 09:44:18 -07:00
Marc Abramowitz 17d7c60735 test_sys_meta_path_munged: Simplify with makepyfile
--HG--
branch : sys_meta_path_remove_hook_only_if_present
2014-03-28 01:03:52 -07:00
Marc Abramowitz 81f822d528 Only try to remove hook from sys.meta_path if it's present
Prevent error on exit if some code messes with sys.meta_path and removes the
assertionrewrite hook (CaptureMock seems to do this):

      File "/Users/marca/dev/hg-repos/pytest/_pytest/assertion/__init__.py", line 64, in pytest_unconfigure
        sys.meta_path.remove(hook)
    ValueError: list.remove(x): x not in list

--HG--
branch : sys_meta_path_remove_hook_only_if_present
2014-03-28 00:33:12 -07:00
holger krekel 8a3b4b9c37 require py>=1.2.20 2014-01-29 13:11:40 +01:00
holger krekel 505a34bb85 fix flakes failures 2014-01-29 10:20:13 +01:00
Andreas Pelme fe4cdd8a90 fixed issue428: Skip test for packages without __init__.py on Python 2
--HG--
branch : py2_pkg_skip
2014-01-22 14:32:22 +01:00
holger krekel 7f49e0fddc xfail a test on pypy that checks wrong encoding/ascii (pypy does
not error out). fixes issue385.

also re-enable pypy tests in tox.
2013-11-19 11:18:51 +01:00
holger krekel 8ac5af2896 fix flakes issues and make --flakes run part of tox runs 2013-10-12 15:39:22 +02:00
Jason R. Coombs 2697b63bcd Fix bytes/string mismatch in test on Python 3 2013-10-10 18:01:56 -04:00
Jason R. Coombs 00c0d62c9b Adding test capturing #366 where an error occurs when package resources are loaded from the test package. 2013-10-10 11:40:31 -04:00
Benjamin Peterson 8b6e42317b add test for detecting coding cookie with CRLF newlines 2013-10-05 15:20:32 -04:00
Benjamin Peterson 56e6ae567c fix detection of the coding cookie when it is on the second line of the file (fixes #330) 2013-10-05 15:16:08 -04:00
Benjamin Peterson 33b663e03d fix coding cookie detection logic 2013-10-05 15:03:04 -04:00
Ronny Pfannschmidt 743711cd1f fix issue317: assertion rewriter support for the is_package method 2013-08-01 22:11:18 +02:00
holger krekel 9ccd52d538 fix issue305 - ignore any problems in writing a pyc file, but print out a trace. 2013-08-01 15:43:42 +02:00
Erik Bray 17e1106584 reindent a few of the blockquotes in these tests 2013-06-07 17:30:10 -04:00
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
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