holger krekel
68f3818562
fix add_method_controller to deal properly in the event of exceptions.
...
add a docstring as well.
2014-10-07 16:16:47 +02:00
Anatoly Bubenkov
a298077461
merge with default
2014-10-07 01:06:15 +02:00
Anatoly Bubenkov
a759da0208
Escape % character in the assertion message. closes #604
2014-10-07 01:01:21 +02:00
holger krekel
c45b7012f5
docs for "pytest_addhooks" hook. Thanks Bruno Oliveira.
...
updated plugin index docs. Thanks Bruno Oliveira.
fix issue557: with "-k" we only allow the old style "-" for negation
at the beginning of strings and even that is deprecated. Use "not" instead.
This should allow to pick parametrized tests where "-" appeared in the parameter.
2014-10-06 14:26:03 +02:00
holger krekel
818a412d29
simplify internal pytester machinery
2014-10-06 13:37:57 +02:00
holger krekel
2cb0145bce
fix issue557: with "-k" we only allow the old style "-" for negation
...
at the beginning of strings and even that is deprecated. Use "not" instead.
This should allow to pick parametrized tests where "-" appeared in the parameter.
2014-10-06 12:11:48 +02:00
pytry
ba8ae427e2
Added test for ValueError in custom assert message with % sign (issue #604 )
...
https://bitbucket.org/hpk42/pytest/issue/604/valueerror-unsupported-format-character-in
2014-10-05 14:49:15 +02:00
holger krekel
3d84f35850
simplify method to record calls
2014-10-04 15:49:31 +02:00
holger krekel
d8f4663f49
factor out a small "wrapping" helper
2014-10-04 15:49:31 +02:00
holger krekel
69ff29bf44
remove overhead for tracing of hook calls and remove some old unused code
2014-10-02 15:25:42 +02:00
holger krekel
c7c4f62f77
optimize argument slicing when calling plugin hooks
2014-10-01 14:55:54 +02:00
holger krekel
f250e912eb
simplify _scan_plugin implementation and store argnames on HookCaller
2014-10-01 13:57:35 +02:00
holger krekel
28c785a0d1
call scanning of plugins directly, code is shifted from helpconfig.py to core.py
2014-10-01 12:20:11 +02:00
Anatoly Bubenkov
9a0f2a9fb7
Improve assertion failure reporting on iterables, by using ndiff and pprint.
2014-09-27 01:29:47 +00:00
Floris Bruynooghe
62b8712ca9
Let xfail work on non-python Items
...
For some reason xfail was only implemented on non-python Item
instances. This removes this guard which means plugins creating new
items can raise pytest.xfail.Exception and it will work as expected.
2014-09-23 23:55:26 +01:00
holger krekel
be503f1c43
Merged in wosc/pytest (pull request #204 )
...
Introduce pytest_enter_pdb hook
2014-09-23 14:04:47 +02:00
holger krekel
5abca55412
Merged in nicoddemus/pytest (pull request #203 )
...
fix issue575: xunit-xml reporting collection errors as failures
2014-09-22 19:25:34 +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
David Szotten
35eec99d41
stop leaking file descriptors
...
tripps --lsof on os x but not on linux. there's possibly a bug in the leak
detector (not investigated here)
--HG--
branch : stop_leaking_fds
2014-09-22 13:56:07 +01:00
David Szotten
bc4eecbbac
add `encoding` attr to DontReadFromInput
...
required by https://docs.python.org/2/library/stdtypes.html#file.encoding
and used e.g. by ipdb at _import_ time
--HG--
branch : dontreadfrominput-encoding
2014-09-22 12:19:27 +01:00
Wolfgang Schnerring
1408c9f077
Introduce pytest_enter_pdb hook
2014-09-18 14:58:42 +02:00
Bruno Oliveira
418607846a
fix issue575: xunit-xml reporting collection errors as failures
2014-09-15 22:04:46 -03:00
holger krekel
b6dcfd4377
fix conftest related fixture visibility issue: when running with a
...
CWD outside a test package pytest would get fixture discovery wrong.
Thanks to Wolfgang Schnerring for figuring out a reproducable example.
--HG--
branch : conftest-nodeid
2014-09-15 12:44:16 +02:00
Floris Bruynooghe
c692a0ee9c
Remove jython from tested python versions
...
After testing with the jython 2.7 beta it seems it will require some
work to get jython back working. So for now remove it from this list
so it doesn't get picked up by normal test runs.
2014-09-06 18:44:18 +01:00
Floris Bruynooghe
a8dfe34bfb
Merged in uweschmitt/pytest/default (pull request #194 )
2014-09-05 23:57:18 +01:00
Floris Bruynooghe
7d9d502a01
Use py3k compatible .__getattr__() code
...
From the python-dev thread it seemed like using
object.__getattribute__(self, 'name') is the cleanest way of
implementing a class wich uses .__getattr__() and should be
pickelable. That only works on new-style classes so this also turns
HookProxy into a new-style class on py2.
This also re-writes the test to not use cPickle so it runs on py3k.
2014-09-05 23:55:14 +01:00
holger krekel
745737e337
strike python2.5 from test code cc @flub
2014-09-05 09:50:40 +02:00
Floris Bruynooghe
eae1055fb0
Merged in nocoddemus/pytest/cx_freeze-support (pull request #189 )
2014-09-03 21:55:46 +01:00
holger krekel
2e1c36bbb6
merged in flub/pytest (PR #195 )
2014-09-02 12:33:19 +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
39a297afe6
Improve test by also matching expected output
2014-08-30 21:57:01 +01: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
uweschmitt
d1bde69c1e
added smoke test for bug fixed in 3716:dc080608b6d1
2014-08-19 12:57:37 +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
Floris Bruynooghe
98dcd764bc
Depend on newer version of py
...
This fixes issue560, a test for which is included here as well.
2014-08-14 23:23:04 +01:00
Bruno Oliveira
5873ca5146
Merging with default
...
--HG--
branch : cx_freeze-support
2014-08-11 20:07:11 -03:00
Bruno Oliveira
d2903507d8
Moved freeze_includes() to genscript
...
--HG--
branch : cx_freeze-support
2014-08-11 20:03:14 -03:00
holger krekel
1d7b574b31
fix issue555: just add "errors" attribute to internal Capture stream.
2014-08-07 11:05:42 +02:00
holger krekel
d16fdb378c
merge PR192, streamline a bit.
2014-08-07 10:42:23 +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
holger krekel
d6fc489b2b
Backed out changeset e57017ad86ce -- logging should not be imported
2014-08-01 08:13:44 +02:00
Floris Bruynooghe
4e8438afc8
Simply show the node ID for verbose output
...
This strips the line number, /@\d/, from the verbose output so it is
directly the node ID of the test. This in turn means no special logic
for accepting the line number as part of the node ID is needed when
parsing the command line.
2014-08-01 00:29:35 +01:00
Bruno Oliveira
b1f8038abf
Minor fixed in test_capture
...
This test failed only in py34. We don't import logging directly,
but it seems that one of the standard modules that are now
globally imported started including this on py34.
Just removed the assert as it doesn't seem central to the
test's objective.
2014-07-31 19:52:08 -03:00
Bruno Oliveira
3c649cf91d
guarding scripts with __main__ and doc changes
...
tox-flakes environment tries to import the modules for
checking, and that may fail because of its dependencies
--HG--
branch : cx_freeze-support
2014-07-30 22:28:03 -03:00
Bruno Oliveira
82d573e391
fixed line endings for test_doctest.txt
...
--HG--
branch : cx_freeze-support
2014-07-30 21:57:19 -03:00
Bruno Oliveira
b7b96b24d8
Docs about cx_freeze support and minor adjustments
...
--HG--
branch : cx_freeze-support
2014-07-30 21:50:00 -03:00
Bruno Oliveira
990e7bf3b9
first implementation and tox environment for cx-freeze support
...
--HG--
branch : cx_freeze-support
2014-07-30 19:16:51 -03:00
Anatoly Bubenkov
8ff8dd3ae9
Merged in fix_initial_parsing (pull request #186 )
...
Fix issue544 and fix another issue with parsing ``::``
2014-07-28 14:16:02 +02:00
holger krekel
0d17dc1e19
add a comment for why we only consider .py files when removing @
...
--HG--
branch : fix_initial_parsing
2014-07-28 13:56:10 +02:00
holger krekel
1265612465
fix issue547 2.6 regression: capsys/capfd now work again when output capturing ("-s") is disabled.
2014-07-28 13:17:37 +02:00
holger krekel
40eed363e8
fix issue544 by only removing "@NUM" at the end of a part (parts are
...
separated by "::") and if the part has an .py extension.
--HG--
branch : fix_initial_parsing
2014-07-28 12:07:15 +02:00
holger krekel
5ccd3f2fc5
fix conftest detection if commandline arguments contain "::" syntax
...
--HG--
branch : fix_initial_parsing
2014-07-28 11:48:37 +02:00
holger krekel
8792261df1
Merged in ticosax/pytest/mock-unittest-252 (pull request #184 )
...
Injection of fixture doesn't work when decorated with unittest.mock.patch
2014-07-28 10:31:31 +02:00
david@mcbf.net
309e3d38a0
Directly pass multiple parameters with mark.parametrize()
...
--HG--
branch : xfail-cause
2014-07-26 18:19:27 +02:00
david@mcbf.net
6a4492a22d
isinstance() on exception value instead of comparing types, consolidate tests
...
--HG--
branch : xfail-cause
2014-07-26 17:46:50 +02:00
Nicolas Delaby
0dd378da30
Injection of fixture doesn't work when decorated with unittest.mock.patch
...
This is a continuation of #182
--HG--
branch : mock-unittest-252
2014-07-26 17:26:18 +02:00
david@mcbf.net
7b273b8577
Add mark.xfail argument raises so that unexpected exceptions show up as test failures.
...
--HG--
branch : xfail-cause
2014-07-26 15:11:05 +02:00
Floris Bruynooghe
1641d00cb1
Merge default
2014-07-18 01:34:08 +01:00
Floris Bruynooghe
2d7a32f7ea
Add test case for using different modules
2014-07-18 01:30:29 +01:00
holger krekel
80ad3fb8ed
Merged in wooparadog/pytest (pull request #163 )
...
Also replace `report.longrepr` with `bin_xml_escape`ed skipreason
2014-07-15 22:17:15 +02:00
holger krekel
8c508612ec
with pypy this tests leaks one FD but it's probably a residual effect of the testing machinery and Pypy's lazy GC.
2014-07-14 09:17:04 +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
christian@christian-linux.sarrazin.local
c8264385ea
Implement the "-c" command line switch that allows to explicitly specifiy the config file to load.
...
This feature was requested in issue #174 .
--HG--
branch : explicit-ini-filename
2014-06-27 17:42:37 +02:00
holger krekel
54c88a6cf3
fix flakes issues
2014-06-16 11:27:32 +02:00
Floris Bruynooghe
115f15600f
Add test for inter-dependent fixtures
...
Together with cc0a46a13ac4 this fixes issue 467.
2014-06-15 19:57:52 +01:00
Benjamin Peterson
fd9055fd11
fix test on Python 3.2
2014-05-31 14:51:05 -07:00
Benjamin Peterson
780bdda95a
assert reinterpretation: try mangling attributes that look like private class vars ( fixes #514 )
2014-05-31 14:37:02 -07:00
holger krekel
d6281b4206
- restore compatibility to old getvalueorskip behaviour
...
- introduce a better NOTSET representation to improve docs
2014-05-14 07:36:31 +02:00
WooParadog
0567a8ee77
Add test for skipped case with utf-8 message
2014-04-24 10:45:39 +08:00
Brianna Laugher
4e35c00ab0
issue351: Add ability to specify parametrize ids as a callable, to generate custom test ids. + tests, docs
...
--HG--
branch : issue351
2014-04-17 15:08:49 -04:00
Floris Bruynooghe
c46e2cbbc7
Cache exception raised in fixtures according to their scope
...
Without this if a session scoped fixture fails it's setup it will
be re-tried each time it is requested. Especially in case of
skip or failure exceptions this can be undesirable, but caching
makes sense for all exceptions.
2014-04-15 22:22:41 -04:00
Floris Bruynooghe
c47835f5ec
Merge pull request #158 , fixes issue 504
2014-04-15 11:43:38 -04:00
Floris Bruynooghe
faba432996
Improve error message if pytest.raises is used wrongly
...
If the type is not checked then an incomprehensible error will occur
later. This enforces the type and raies the same exception/msg as
CPython does in that case.
Docstring unmodified, just re-justified for pep8 compat.
2014-04-14 18:09:10 -04:00
Andy Freeland
2ba23e8d08
issue504: verbose output displays node IDs for each test
...
Replace the verbose per-test reporting format of `file:line test_name RESULT`
with the node ID of the test, i.e. `file@line::class::method[param] RESULT`.
This patch does not update the examples in the docs; @hpk42 has a script
to regenerate those.
--HG--
branch : issue504
2014-04-14 17:42:02 -04:00
holger krekel
15af7e1662
fix tests to properly fail on failed collectiosn (which was hiding an error)
...
and also implement __test__=False for test functions properly.
--HG--
branch : nose_test_attr
2014-04-10 13:37:39 +02:00
holger krekel
e42cbc714f
fix wrong merge
...
--HG--
branch : nose_test_attr
2014-04-10 12:58:10 +02:00
holger krekel
494be731e3
support nose-style ``__test__`` attribute on modules, classes and
...
functions, including unittest-style Classes. If set to True, the
test will not be collected.
--HG--
branch : nose_test_attr
2014-04-10 12:46:27 +02:00
holger krekel
f91049cec9
fix issue473: work around mock putting an unbound method into a class
...
dict when double-patching.
--HG--
branch : issue473
2014-04-08 12:50:13 +02:00
holger krekel
ef7cb47b1e
fix issue498: if a fixture finalizer fails, make sure that the fixture
...
is still invalidated.
--HG--
branch : issue498
2014-04-07 13:29:57 +02:00
holger krekel
cbe31f3748
Merged in msabramo/pytest/makepyfile_utf8 (pull request #134 )
...
Make makepyfile accept UTF-8 so a few cookie tests in test_assertrewrite.py
2014-04-03 10:00:24 +02:00
Anatoly Bubenkov
b4fe91943d
Merged in hpk42/pytest-hpk/conftest-clean (pull request #148 )
...
cleanup internal conftest handling and avoid the strange None entry in the conftest cache.
2014-04-03 09:38:47 +02:00
holger krekel
0365e5c3a0
cleanup internal conftest handling and avoid the strange None entry in the conftest cache.
...
(There is basically no reason to ask for conftestmodules without specifying a path.)
--HG--
branch : conftest-clean
2014-04-02 22:30:45 +02:00
holger krekel
e6859406f1
fix test on py33, thanks msabramo1
2014-04-02 20:49:57 +02:00
holger krekel
51cff6f106
fix issue486: better reporting and handling of early conftest loading failures
...
--HG--
branch : issue486
2014-04-02 20:42:41 +02:00
holger krekel
68e58e1493
add a test for robustness of capturing when a test closes FD1/2
2014-04-02 20:29:10 +02:00
holger krekel
7d10a57514
Merged in msabramo/pytest/remove_unused_import (pull request #146 )
...
testing/test_capture.py: Remove unused stuff for PEP8 compliance
2014-04-02 18:56:46 +02:00
Marc Abramowitz
2c0f6207e9
test_capture.py: More PEP8. Remove unused `cap` in `with`.
...
--HG--
branch : remove_unused_import
2014-04-02 09:48:08 -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
Marc Abramowitz
02d94e69f0
testing/test_capture.py: Remove unused `import tempfile`
...
--HG--
branch : remove_unused_import
2014-04-02 09:14:16 -07:00
holger krekel
0c04b44919
fix issue492: avoid leak in test_writeorg
2014-04-02 12:32:21 +02:00
holger krekel
3bca62e9e4
fix issue436: improved finding of initial conftest files from command
...
line arguments by using the result of parse_known_args rather than
the previous flaky heuristics. Thanks Marc Abramowitz for tests
and initial fixing approaches in this area.
2014-04-02 11:29:23 +02:00
holger krekel
72b4534a0c
add changelog entry for some PRs: improvements to pytest's own
...
test-suite leakage detection, courtesy of PRs from Marc Abramowitz
2014-04-02 09:51:24 +02:00
holger krekel
21b4280126
Merged in msabramo/pytest/test_writeorg_close_tempfile (pull request #136 )
...
test_writeorg: Close a tempfile
2014-04-02 09:30:55 +02:00
holger krekel
30a9debaf1
Merged in msabramo/pytest/refactor_LsofFdLeakChecker (pull request #138 )
...
testing/conftest.py: Refactor lsof fd leak checking
2014-04-02 09:24:16 +02:00
Marc Abramowitz
f824a73143
Remove cast of fd to int and sorting
...
Casting of fd can break for non-numeric fd (e.g.: "rtd" on Linux) and isn't
necessary since we don't need to sort.
--HG--
branch : refactor_LsofFdLeakChecker
2014-04-01 15:36:54 -07:00
Marc Abramowitz
e45a33f029
testing/conftest.py: Reintialize config._openfiles for each test
...
And no longer need getopenfiles or config._numfiles
--HG--
branch : refactor_LsofFdLeakChecker
2014-04-01 14:13:11 -07:00
Marc Abramowitz
064e79761c
Improve LsofFdLeakChecker; more reliable and useful leak checking
...
* Make it invoke lsof with options for machine-readable output
* Parse out file descriptor and filename from lsof output
* Draw attention to file descriptors now open that weren't open before
--HG--
branch : refactor_LsofFdLeakChecker
2014-04-01 13:41:35 -07:00
Marc Abramowitz
f7713c47e8
testing/conftest.py: Refactor lsof fd leak checking
...
Isolate the logic into one class to make easier to understand, more maintainable.
This may aid in later plugging in an alternative implementation, such as one
that uses psutil
(https://bitbucket.org/hpk42/pytest/pull-request/137/use-psutil-to-detect-open-files-in-tests/diff )
--HG--
branch : refactor_LsofFdLeakChecker
2014-04-01 10:15:27 -07:00
holger krekel
ce8678e6d5
remove non-documented per-conftest capturing option and simplify/refactor all code accordingly. Also make capturing more robust against tests closing FD1/2 and against pdb.set_trace() calls.
2014-04-01 14:32:12 +02:00
holger krekel
2e1f6c85f6
introduce resume/suspend functionality for FDCapture and SysCapture,
...
fixing problems with early bailouts (from argparse's parse() function e.g.)
that wrote to stdout.
2014-04-01 14:19:58 +02:00