Commit Graph

1596 Commits

Author SHA1 Message Date
Danielle Jenkins 9877bf47e3 Improve commenting for setupplan unittest. 2016-06-25 12:21:31 +02:00
Florian Bruhin 757f37f445 Don't ignore ImportError with setuptools plugins
This was added in b2d66b9e7b but is a bad
idea. When a plugin can't be imported, commandline options (optionally
set in pytest.ini) could be undefined, which means pytest bails out
much earlier before showing the warning, which is hard to debug.

Fixes #1479, also see #1307 and #1497
2016-06-25 09:56:22 +02:00
Daniel Hahler 939407ef63 Simplify Argument.__repr__
I have came across this when noticing that universal-ctags fails to parse
this correctly (https://github.com/universal-ctags/ctags/issues/997).
2016-06-25 09:31:31 +02:00
Omar Kohl d81f23009b Raise CollectError if pytest.skip() is called during collection
pytest.skip() must not be used at module level because it can easily be
misunderstood and used as a decorator instead of pytest.mark.skip, causing the
whole module to be skipped instead of just the test being decorated.

This is unexpected for users used to the @unittest.skip decorator and therefore
it is best to bail out with a clean error when it happens.

The pytest equivalent of @unittest.skip is @pytest.mark.skip .

Adapt existing tests that were actually relying on this behaviour and add a
test that explicitly test that collection fails.

fix #607
2016-06-24 20:56:21 +02:00
Tom Viner 77689eb486 Fixes #1503 no longer collapse false explanations 2016-06-24 15:35:24 +02:00
Tom Viner df9918eda3 issue1625, name getfuncargvalue to getfixturevalue 2016-06-24 10:08:19 +02:00
Vasily Kuznetsov c6af737d4e Fix fixture parameter display when ids is a function 2016-06-23 10:54:22 +02:00
Vasily Kuznetsov 1a5e530b98 Fix capturing with --setup-only/--setup-plan 2016-06-23 10:23:04 +02:00
Florian Bruhin 6359e75ff8 Trivial spelling fix in runtest_setup.py 2016-06-22 20:18:00 +02:00
Stefan Zimmermann 69bab4ab04 added check for already existing option names to OptionGroup.addoption() 2016-06-22 18:01:35 +02:00
Steffen Allner dd97a2e7c8 Merge from upstream 2016-06-22 17:51:48 +02:00
Vasily Kuznetsov f7d50dfa91 Add a test for handling of dynamic requests for fixtures from other fixtures 2016-06-22 17:24:55 +02:00
Vasily Kuznetsov 61992b4e22 Implement --setup-plan option 2016-06-22 16:45:36 +02:00
Ronny Pfannschmidt 18ef7de96b merge from master again 2016-06-22 16:03:52 +02:00
Ronny Pfannschmidt e96cd51a2a Merge remote-tracking branch 'upstream/features' into merge-master 2016-06-22 16:03:00 +02:00
Ronny Pfannschmidt f7585c7549 Merge pull request #1635 from Avira/master
Add test for change in pull request #1631
2016-06-22 15:49:09 +02:00
Ronny Pfannschmidt 083f64100d merge master into features 2016-06-22 14:39:33 +02:00
Oliver Bestwalter db79ed5c4d Add tests to make sure expected entry points exist (#1629) 2016-06-22 14:28:53 +02:00
Vasily Kuznetsov 1a75139f72 Fix the tests 2016-06-22 13:25:46 +02:00
Steffen Allner 7d19f83982 Add test for setuponly option 2016-06-22 12:00:45 +02:00
Oliver Bestwalter 7d87a1b127 Add test for failing assertion
Should contain function name that caused the failure (see pull request #1631).
2016-06-22 11:23:50 +02:00
Tom Viner 98adf204b2 issue 1553: Include terminal newlines in diffs 2016-06-22 09:50:15 +02:00
Bruno Oliveira c3ee1c17bc Merge pull request #1620 from tomviner/issue460/parameterized-subrequest
Issue 460: Fail on getfuncargvalue(<fixture with params>)
2016-06-21 13:43:06 -03:00
Bruno Oliveira 4350f499b2 Merge branch 'issue1629' of https://github.com/davehunt/pytest into features 2016-06-21 18:37:14 +02:00
Bruno Oliveira 573866bfad Merge remote-tracking branch 'upstream/features' into issue-1619-conftest-assert-rewrite 2016-06-21 18:10:19 +02:00
Dave Hunt ef9dd14963 Introduce pytest command as recommended entry point
Fixes #1629
2016-06-21 16:16:57 +02:00
Omar Kohl ede7478dcc Exit pytest on collection error (without executing tests)
Add --continue-on-collection-errors option to restore the previous behaviour:
Execute tests (that were successfully collected) even when collection errors
happen.

Some tests had to be modified e.g. because the return code changed to 2
(EXIT_INTERRUPTED) instead of 1 (EXIT_TESTSFAILED) because an Interrupted
exception is raised on collection error.

Implemented via pair programming with:
    Oleg Pidsadnyi <oleg.pidsadnyi@gmail.com>

closes #1421
2016-06-21 13:32:34 +02:00
Tom Viner 5854a71ece Issue 460: getfuncargvalue fixture w. params err 2016-06-21 11:29:21 +02:00
Bruno Oliveira 3a81d2e012 conftest files now use assertion rewriting
Fix #1619
2016-06-20 23:13:29 +02:00
Daniel Hahler e9d7989140 Ignore hidden files (.testmondata) in test_pytest_collect_file
`test_pytest_collect_file` fails if you run the tests using `--testmon`,
because pytest-testmon will put its DB there as `.testmondata`.
2016-06-20 22:30:36 +02:00
Florian Bruhin 54872e94b4 Fix test name typo 2016-06-20 18:44:34 +02:00
Florian Bruhin 4f2db6c08d Merge pull request #1616 from palaviv/pytest.raises-message
Pytest.raises custom error message
2016-06-20 18:43:12 +02:00
palaviv ca093673fb pytest.raises accept cutom message only when used as context manager 2016-06-19 21:24:47 +03:00
Bruno Oliveira d81ee9acfb Merge pull request #1597 from taschini/pyargs-fix
Ensure that a module within a namespace package can be found by --pyargs
2016-06-19 14:20:52 -03:00
Bruno Oliveira 72bf11cbe9 Add disabled() method to capsys and capfd
Fix #1599
2016-06-19 19:14:36 +02:00
palaviv e6ff01ada3 CR fixes 2016-06-16 21:09:15 +03:00
palaviv d21886c005 pytest.raises accpets custom message 2016-06-16 20:15:32 +03:00
Greg Price 2a3cbdf4d1 Cut a dead test helper function
This appears to have been unused since commit
320835d "split out pytest-xdist related reporting to the plugin"
in July 2010.  It's the only caller outside of _pytest/runner.py
of the `call_and_report` helper function there, so cutting it out
makes that more of a pure helper function and makes it slightly
easier to understand the code in _pytest/runner.py .
2016-06-15 18:26:10 -07:00
Bruno Oliveira 308396ae3c Merge pull request #1606 from hackebrot/show-fixtures-per-test
Show fixtures per test
2016-06-14 09:54:18 -03:00
taschini 4d9e293b4d Incorporated feedback (#1597).
Fixed problem caused in a test on Windows by file left open by PyPy and not immediately garbage collected.
2016-06-14 07:12:40 +02:00
taschini e2e6e31711 Ensure that a module within a namespace package can be found by --pyargs. 2016-06-14 07:12:40 +02:00
Raphael Pierzina adc50ac72f Change format for test function locations 2016-06-12 15:58:32 +01:00
Guyzmo accd962c9f Fixed issue shadowing error when missing argument on teardown_method
When the method argument is missing on teardown_method, the traceback is
100% internal to pytest, which with default options get pruned. Then
that traceback is empty, leading to a new exception as a traceback shall
not be empty.

This PR fixes that issue by pushing back the last stack on the
traceback, when the stacktrace is empty after pruning. Then the output
is still pruned, but gives meaningful information with the item where it
failed on the stack.

* fixes issue #1604

Signed-off-by: Guyzmo <guyzmo+github@m0g.net>
2016-06-12 03:45:24 +02:00
Raphael Pierzina b47f155d74 Implement tests for --fixtures-per-test 2016-06-12 00:17:50 +01:00
Bruno Oliveira d712428d33 Fix custom name for yield_fixtures 2016-06-08 21:07:49 -03:00
Bruno Oliveira 366879db27 Make normal fixtures work with "yield" 2016-06-08 21:07:47 -03:00
marscher 09d163aa3a [exception handling] Fix case the current working directory (CWD) gets deleted during testing.
Fixes #1235.
2016-06-08 15:18:23 +02:00
Thomas Grainger 74862b8f2f
Don't mark empty doctest files as skipped, fixes #1578 2016-06-01 19:19:14 +01:00
Ronny Pfannschmidt b5bd4d959d merge master to features 2016-06-01 08:13:26 +02:00
Raphael Pierzina fb8ad714b1 Implement a test for showfixtures to show fixtures with same name 2016-05-31 11:47:16 +01:00
Ronny Pfannschmidt 158f3cfaea merge master 2016-05-31 11:24:53 +02:00
Ronny Pfannschmidt d217b52508 fix #510 by adding a describing skip marker on empty parameterize 2016-05-30 14:34:38 +02:00
Bruno Oliveira 8c1be624a6 Merge pull request #1554 from RonnyPfannschmidt/merge-master
Merge master into features
2016-05-24 11:09:33 -03:00
Bruno Oliveira 5ab5a11544 Merge pull request #1565 from tomviner/issue1544/ignore-build-dist-dirs
Issue 1544: norecursedirs build & dist dirs
2016-05-23 19:30:20 -03:00
TomV d6dfb1a393 issue 1544: norecursedirs build & dist dirs 2016-05-23 21:02:29 +01:00
Ronny Pfannschmidt 85393d34b6 Merge pull request #1561 from AbdealiJK/ajk/1558_feature
unittest.UnitTestCase: Allow __test__ for methods
2016-05-19 10:17:28 +02:00
AbdealiJK d4c9fa9f1a unittest.UnitTestCase: Allow __test__ for methods
__test__ needs to be checked for methods of a class too. Earlier,
this was not done, and all methods in a class was assumed to be
a test. This commit adds the appropriate condition to ensure that
if the __test__ is set to False, it does not collect that method.

Fixes https://github.com/pytest-dev/pytest/issues/1558
2016-05-19 08:19:57 +05:30
Ronny Pfannschmidt ec5e05834f fix typo 2016-05-18 21:35:31 +02:00
Ronny Pfannschmidt eab762ea99 Merge branch 'master' into merge-master 2016-05-13 19:37:41 +02:00
Ronny Pfannschmidt c49863aa63 merge next chunk from master and fix changelog linting issue 2016-05-13 19:36:47 +02:00
Ronny Pfannschmidt 01d2ff804b Merge commit '56156bb119194014129ac08c4a2c370f0b893104' into merge-master 2016-05-13 17:55:02 +02:00
John Towler 0d07b64571 Fixes Issue 1549 2016-05-05 11:29:05 -07:00
Ronny Pfannschmidt 98dd2ce75c document reason for #1540 2016-04-28 16:22:31 +02:00
Ronny Pfannschmidt 308e76e19c add xfailing test for #1540 2016-04-28 16:11:30 +02:00
Ronny Pfannschmidt 6cc56b4a1b Merge pull request #1535 from palaviv/parametrize-test-ids-hook
introduce pytest_make_parametrize_id hook
2016-04-27 16:16:16 +02:00
palaviv 9733127951 pytest_make_parametrize_id receive config object 2016-04-26 10:23:57 +03:00
Bruno Oliveira fdee88f086 Merge pull request #1520 from omarkohl/invalid_test_module_name
Raise CollectError if import test module fails
2016-04-25 21:42:41 -03:00
palaviv b9faf78d51 Added test_pytest_make_parametrize_id 2016-04-25 17:48:28 +03:00
Omar Kohl 56855893ca Raise CollectError if import test module fails
One of the reasons for failing to import the test module is invalid Python
identifiers in the full package path of the test module.

fix #1426
2016-04-23 13:50:48 +02:00
Florian Bruhin 75160547f2 Use a callable __tracebackhide__ for filtering
While this leads to slightly more complicated user code for the common
case (checking if the exception is of a given type) it's easier to
implement and more flexible.
2016-04-20 11:09:27 +02:00
Florian Bruhin 4c552d4ef7 Fix tests for python 2.6 2016-04-20 10:36:13 +02:00
Florian Bruhin b607f6728f Filter selectively with __tracebackhide__
When __tracebackhide__ gets set to an exception type or list/tuple of
exception types, only those exceptions get filtered, while the full
traceback is shown if another exception (e.g. a bug in a assertion
helper) happens.
2016-04-20 10:25:33 +02:00
MengJueM 1a37035d71 Add test test_absolute_win32_path 2016-04-20 01:27:37 +08:00
TomV 99c4b6fdc3 issue 1496 - xfail with condition keyword 2016-04-19 18:12:37 +01:00
Martin Prusse 7ce5873da2 Perform a "unicode aware" check for maximum recursion depth error
Avoid errors `UnicodeErrosr`s due non maximum recursion depth errors
when checking for those errors.
2016-04-08 23:32:18 -03:00
Ronny Pfannschmidt 0f7aeafe7c Merge pull request #1486 from roolebo/fix-issue-138
Fix issue #138 - support chained exceptions
2016-04-03 19:21:57 +02:00
Bruno Oliveira e3bc6faa2b Merge pull request #1470 from ceridwen/features
Escape both bytes and unicode strings for "ids" in Metafunc.parametrize
2016-04-03 13:48:30 -03:00
Omar Kohl c578226d43 Implement ExceptionInfo.match() to match regexp on str(exception)
This implements similar functionality to
unittest.TestCase.assertRegexpMatches()

closes #372
2016-04-03 11:22:44 +02:00
Ceridwen 23a8e2b469 Add .hypothesis to .gitignore and try an older version of Hypothesis for 2.6 2016-04-02 11:47:37 -04:00
Ceridwen 491b30c5d9 Add Hypothesis test for _idval and fix bug it found 2016-04-01 22:45:44 -04:00
Ceridwen b631fc0bc1 Fix test_escaped_parametrized_names_xml 2016-04-01 21:30:45 -04:00
Tyler Goodlet 053c052190 Always lstrip() keyword expression 2016-04-01 13:10:05 -04:00
Ceridwen 9b438d56e8 Fix a test_unicode_idval_python2 (now test_unicode_idval) and associated string handling on Python 3 2016-04-01 12:27:17 -04:00
palaviv b8c15a0215 improved idmaker name selection in case of duplicate ids 2016-03-23 00:20:58 +02:00
Quentin Pradet 653a53226a Add strict parameter to xfail marker doc 2016-03-22 16:01:51 +04:00
Quentin Pradet 1fbd19b8cb Fix pytest.mark.skip mark when used in strict mode 2016-03-22 15:40:34 +04:00
palaviv 7885e43b78 Merge remote-tracking branch 'upstream/features' into allow-none-as-parametrized-test-id 2016-03-20 18:57:17 +02:00
Roman Bolshakov a736e26734 Merge remote-tracking branch 'pytest-dev/master' into fix-issue-138 2016-03-20 01:04:22 +03:00
Roman Bolshakov fbc5ba08d9 Fix issue #138 2016-03-20 01:02:17 +03:00
palaviv 4b0237c8ee added test for unique names when recievieng identical ids in parametrize 2016-03-19 21:42:47 +02:00
palaviv 877ca5a0bf added test for None in paramtrized ids list 2016-03-19 21:38:24 +02:00
palaviv a8cfd54871 added test for None in idmaker 2016-03-19 21:23:49 +02:00
Bruno Oliveira 5fcce8a7d6 Merge branch 'master' into merge-master-into-features 2016-03-18 18:26:56 -03:00
Tareq Alayan fa6acdcfd4 junitxml: add properties node in testsuite level
The commit allow users to add a properties node in testsuite level see
example below:

<testsuite errors="0" failures="0" name="pytest" skips="1" tests="1"
time="11.824">
  <properties>
    <property name="ARCH" value="PPC"/>
    <property name="OS" value="RHEL 7.2"/>
    <property name="TestPlanURL" value="https://url.."/>
    <property name="Automated" value="True"/>
  </properties>
  <testcase classname="git.....>
  </testcase>
</testsuite>

The current situation is that properties node can be added to every
testcase node. However, sometimes we need some global properties that
applies to all testcases and give better description for the testsuite
itself.
2016-03-16 13:24:33 +02:00
Kale Kundert 5ceee08590 Fix CHANGELOG merge conflicts. 2016-03-14 11:55:50 -07:00
palaviv 1ee3d40dbe allow parametrized nodes to be specified from command line 2016-03-13 23:37:21 +02:00
Kale Kundert 916c0a8b36 Fix Decimal() and __ne__() errors. 2016-03-11 16:29:18 -08:00
Kale Kundert 42a7e0488d Properly handle inf, nan, and built-in numeric types.
This commit also:

- Dramatically increases the number of unit tests , mostly by borrowing
  from the standard  library's unit tests for math.isclose().

- Refactors approx() into two classes, one of which handles comparing
  individual numbers (ApproxNonIterable) and another which uses the
  first to compare individual numbers or sequences of numbers.
2016-03-11 08:49:26 -08:00
Ronny Pfannschmidt 4636bf6160 Merge pull request #1391 from malinoff/issue1342
LastFailed now creates .cache only when needed. Fixes #1342
2016-03-11 11:18:50 +01:00
Mike Lundy 9577120592 Allow custom fixture names for fixtures
When defining a fixture in the same module as where it is used, the
function argument shadows the fixture name, which a) annoys pylint and
b) can lead to bugs where you forget to request a fixture into a test
method.

This allows one to define fixtures with a different name than the name
of the function, bypassing that problem.
2016-03-09 14:58:54 -08:00