Commit Graph

726 Commits

Author SHA1 Message Date
holger krekel 47379d4a79 Merged in dangra/pytest (pull request #132)
no need for im_func and it does not exists in python3
2014-03-28 14:46:34 +01: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
Daniel Grana b96d552dbd no need for im_func and it does not exists in python3 2014-03-27 23:57:18 -03:00
holger krekel 530cae9204 Merged in cgilling/pytest (pull request #123)
Fix to work properly when @patch is used with new not equal to DEFAULT
2014-03-26 19:05:46 +01:00
Marc Abramowitz 8af265da04 _pytest/config.py: In --help, show args with `=` instead of space.
The `=` is better because it encourages folks to use the form that doesn't
suffer from issue #436 (https://bitbucket.org/hpk42/pytest/issue/436), which
can cause the arg to be treated as an "anchor" and used as the (unexpected)
path for searching for conftest.py files.

--HG--
branch : help_show_args_with_equals_instead_of_space
2014-03-26 10:47:30 -07:00
Chris Gilling e3b9382122 use sys.modules.get correctly and reference DEFAULT with respect to it 2014-03-26 09:36:02 -07:00
Chris Gilling c3f4eb6d57 change try/except to sys.module.get and a conditional 2014-03-26 09:27:33 -07:00
holger krekel 8f7b53e55b fix issue490: include pytest_load_initial_conftests in documentation
and improve docstring.
2014-03-25 14:43:58 +01:00
schlamar 85e7b11ef5 Removed unnecessary iteration in nose.pytest_runtest_makereport. 2014-03-14 15:29:42 +01:00
schlamar 77e1f93ca1 Fixed pyflakes errors. 2014-03-14 14:25:36 +01:00
schlamar 94b1ce65c6 Fixed race condition with SkipTest when module not in sys.modules on collection. 2014-03-14 14:04:54 +01:00
holger krekel cfd43a9b02 add changelog for warning system, bump internal version 2014-03-14 08:15:38 +01:00
holger krekel ebd10aa6b4 shrink and merge the somewhat obscure and undocumented internal hinting
system with the new warnings one
2014-03-11 22:10:51 +01:00
holger krekel 24db492f53 warn if instances are callable and have a test name 2014-03-11 22:10:18 +01:00
holger krekel 1b387bea62 introduce warning system with this API:
- node.warn() for a node-specific warning
- config.warn() for a global non-node specific warning

Each warning is accompanied by a "warning number" so that we can later
introduce mechanisms for surpressing them.

Each warning will trigger a call to pytest_report_warn(number, node, message)
which is by default implemented by the TerminalReporter which introduces
a new option "-rw" to show details about warnings.
2014-03-11 22:10:17 +01:00
Chris Gilling 3388d82c1c Fix to work properly when @patch is used with new not equal to DEFAULT
also updated test_mock to include this situation
2014-03-03 10:36:59 -08:00
holger krekel 25ab906b8b add release announcement, bump version to 2.5.2,
add links to plugins index, regenerate doc examples.
2014-01-29 13:47:11 +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
Floris Bruynooghe cc1186242c Avoid wasted string concatenation and improve english 2014-01-29 00:39:04 +00:00
holger krekel 86284689a3 simplify loop which turns direct funcarg parametrization to indirect 2014-01-27 12:53:44 +01:00
holger krekel 4622c28ffd setupstate.addfinalizer(): fix docstring and remove related unit test not covering functional reality 2014-01-26 12:44:21 +01:00
holger krekel 6f385fb4ea remove "mixed" capturing mode which is not used by pytest
--HG--
branch : capsimple1
2014-01-25 19:56:27 +01:00
holger krekel 18e12cbd67 remove "StdCapture*.call" classmethod because pytest does not use it.
--HG--
branch : capsimple1
2014-01-25 19:43:57 +01:00
holger krekel 3cf4e133cc remove now parameter because pytest only used now==False everywhere
--HG--
branch : capsimple1
2014-01-25 19:42:45 +01:00
Ronny Pfannschmidt 97da43d909 merge from default
--HG--
branch : multi-usageerror
2014-01-25 10:42:21 +01:00
Ronny Pfannschmidt 177637bfb9 Redo the Capture integration propperly 2014-01-24 21:22:19 +01:00
Jurko Gospodnetić 75c124ea17 reword note on explicitly clearing local references to pytest.raises() results
Made it clearer that clearing such references is not mandatory and is only an
optional step which may help the Python interpreter speed up its garbage
collection.

--HG--
branch : document_ExceptionInfo_ref_cycle
2014-01-23 11:36:04 +01:00
Jurko Gospodnetić ffffac27f9 document explicitly clearing local references to pytest.raises() results
pytest.raises() returns an ExceptionInfo object which, if a local reference is
made to it, forms a reference cycle:
  ExceptionInfo
  --> exception
  --> stack frame raising the exception
  --> current stack frame
  --> current local variables
  --> Exception Info

Such a reference cycle would then prevent any local variables in the current
stack frame, or any of its child stack frames involved in the same reference
cycle, from being garbage collected until the next reference cycle garbage
collection phase. This unnecessarily increases the program's memory footprint
and potentially slows it down.

This situation is based on a similar one described in the official 'try'
statement Python documentation for locally stored exception references.

--HG--
branch : document_ExceptionInfo_ref_cycle
2014-01-23 09:46:36 +01:00
holger krekel 9aaf0fd340 backing out Ronny's PR because it was merged too early (still has failing tests) 2014-01-22 22:15:40 +01:00
Ronny Pfannschmidt 8976b3ee0e stop exposing capsys/capfd.capture 2014-01-22 21:52:32 +01:00
Ronny Pfannschmidt ac2f2b1deb add notes on the copied pylib version 2014-01-22 21:50:07 +01:00
Ronny Pfannschmidt b4a397d153 kill ancient capture devnullpath, os.devnull exists since py 2.4 2014-01-22 21:37:59 +01:00
Ronny Pfannschmidt d1a9ab3df0 small cleanp 2014-01-22 21:04:00 +01:00
Ronny Pfannschmidt 0ede968ec0 kill the str magic of Encodedfile 2014-01-22 21:03:49 +01:00
Ronny Pfannschmidt 5f21abc3a3 move imports and declarations to the top 2014-01-22 20:48:17 +01:00
Ronny Pfannschmidt e2bb81124c simplify StdCaptureFD snapshot reading 2014-01-22 19:48:10 +01:00
Ronny Pfannschmidt ea18e9656b rewrite all _pytest.capture uses of py.io to _pytest.capture 2014-01-22 19:44:20 +01:00
Ronny Pfannschmidt 0ac94134f5 initial code import for capture transfer 2014-01-22 19:04:38 +01:00
holger krekel 3a4f69734a remove superflous line 2014-01-22 13:54:25 +01:00
Floris Bruynooghe e12fe64b54 Include py version in the terminal output
This can help to reproduce bugs when looking at the output pasted into
bug reports.
2014-01-22 11:27:15 +01:00
holger krekel 1ffc006363 fixed circular imports by reverting a few py.test -> pytest substitions. 2014-01-22 11:17:25 +01:00
holger krekel 836232e544 fix issue425: mention at end of "py.test -h" that --markers
and --fixtures work according to specified test path (or current dir)
2014-01-22 10:24:22 +01:00
holger krekel 2539e5a352 Merged in derdon/pytest/no-p-option (pull request #102)
added docs about the `no:` syntax for the -p option
2014-01-20 13:22:31 +01:00
Jurko Gospodnetić 8e457338ee fix handling MarkDecorators called with a single positional plus keyword args
When a MarkDecorator instance is called it does the following:
  1. If called with a single class as its only positional argument and no
     additional keyword arguments, it attaches itself to the class so it gets
     applied automatically to all test cases found in that class.
  2. If called with a single function as its only positional argument and no
     additional keyword arguments, it attaches a MarkInfo object to the
     function, containing all the arguments already stored internally in the
     MarkDecorator.
  3. When called in any other case, it performs a 'fake construction' call, i.e.
     it returns a new MarkDecorator instance with the original MarkDecorator's
     content updated with the arguments passed to this call.

When Python applies a function decorator it always passes the target class/
function to the decorator as its positional argument with no additional
positional or keyword arguments. However, when MarkDecorator was deciding
whether it was being called to decorate a target function/class (cases 1. & 2.
as documented above) or to return an updated MarkDecorator (case 3. as
documented above), it only checked that it received a single callable positional
argument and did not take into consideration whether additional keyword
arguments were being passed in as well.

With this change, it is now possible to create a pytest mark storing a function/
class parameter passed as its only positional argument and accompanied by one or
more additional keyword arguments. Before, it was only possible to do so if the
function/class parameter argument was accompanied by at least one other
positional argument.

Added a related unit test.

Updated MarkDecorator doc-string.
2014-01-20 01:27:33 +01:00
Simon Liedtke d92ee8c3c3 added docs about the `no:` syntax for the -p option
--HG--
branch : no-p-option
2014-01-19 22:05:14 +01:00
Jurko Gospodnetić 657a395839 fix comment typos 2014-01-18 12:39:16 +01:00
Jurko Gospodnetić 9fb2079458 replace py.test module references with pytest
The only remaining 'py.test' references are:
 * those referring to the 'py.test' executable
 * those in code explicitly testing py.test/pytest module compatibility
 * those in old CHANGES documentation
 * those in documentation generated based on external data
 * those in seemingly unfinished & unmaintained Japanese documentation

Minor stylistic changes and typo corrections made to documentation next to
several applied py.test --> pytest content changes.
2014-01-18 12:31:33 +01:00
Lukasz Balcerzak 99277be25f Updated error message to be more helpful
Also, added misssing test
2013-12-19 14:29:57 +01:00
holger krekel 699892bd03 fix issue409 -- better interoperate with cx_freeze by not
trying to import from collections.abc which causes problems for py27/cx_freeze.
2013-12-18 14:56:45 +01:00
holger krekel 5a13f31bce fix issue407: fix addoption docstring to point to argparse instead of
optparse. Thanks Daniel D. Wright.
2013-12-16 18:07:05 +01:00