Commit Graph

50 Commits

Author SHA1 Message Date
Ran Benita c31f4dc112 testing: make conftest stuff check for pytester not testdir
testdir uses pytester so this applies to it as well, but now includes
pytester as well.
2020-10-26 15:01:38 +02:00
Anthony Sottile daba7ceb71 py36+: remove requires_ordered_markup 2020-10-02 15:06:59 -07:00
Bruno Oliveira 7ec6401ffa
Change pytest deprecation warnings into errors for 6.0 release (#7362)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2020-07-22 21:36:51 -03:00
Bruno Oliveira 1780924b27 Introduce _pytest.timing as a way to control timing during tests
_pytest.timing is an indirection to 'time' functions, which pytest production
code should use instead of 'time' directly.

'mock_timing' is a new fixture which then mocks those functions, allowing us
to write time-reliable tests which run instantly and are not flaky.

This was triggered by recent flaky junitxml tests on Windows related to timing
issues.
2020-05-23 11:50:33 -03:00
Bruno Oliveira c91abe48ba Assorted improvements following up #6658 2020-02-20 18:51:41 -03:00
Bruno Oliveira 4209ad6fca
Use code highlighting if pygments is installed (#6658)
* Use code highlighting if pygments is installed

* Use colorama constants instead of bare ascii codes

Could not find the exact equivalent of 'hl-reset' code using colorama
constants though.

* Refactor ASCII color handling into a fixture

* Revert back to using explicit color codes

* In Python 3.5 skip rest of tests that require ordered markup in colored output
2020-02-12 08:32:37 -03:00
Daniel Hahler 4316fe8a92
testing/conftest.py: testdir: set PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 (#6655)
Fixes https://github.com/pytest-dev/pytest/pull/4518.
2020-02-04 02:59:20 +01:00
Daniel Hahler 5049e25a6a tests: cleanup unused fixtures 2020-01-16 21:12:48 +01:00
Daniel Hahler d6e324a5e6 tests: conftest: handle tests using runpytest_subprocess as "slowest" 2019-10-28 13:43:42 +01:00
Bruno Oliveira 7bdfba3578 Fix --setup-only and --setup-show for custom pytest items
Fix #5884
2019-09-28 11:52:09 -03:00
Bruno Oliveira 7a69365486 Move TWMock class to a fixture
Using a relative import like before was not very nice
2019-08-26 11:32:57 -03:00
Daniel Hahler aab5687093 tests: restore tracing function
Without this, `testing/test_pdb.py` (already without pexpect) will cause
missing test coverage afterwards (for the same process).
2019-06-05 11:26:48 +02:00
Anthony Sottile 5034399d7a pre-commit run fix-encoding-pragma --all-files 2019-06-03 12:08:01 -03:00
Daniel Hahler 28bf3816e7 tests: conftest: auto-add slow marker 2019-05-30 06:55:38 +02:00
Daniel Hahler 61b76c7f5f tests: conftest: fix collection of slow/slowest items 2019-05-29 21:35:05 +02:00
Daniel Hahler 0025e4408f conftest: add uses_pexpect mark 2019-05-28 18:41:01 +02:00
Anthony Sottile dc75b6af47 Use fix-encoding-pragma pre-commit hook 2019-05-14 15:56:31 -07:00
Daniel Hahler f75f7c1925 conftest: use a hookwrapper with sorting faster tests first 2019-04-19 01:23:34 +02:00
Daniel Hahler 4c0ba6017d Add a conftest to prefer faster tests
This uses pytest_collection_modifyitems for pytest's own tests to order
them, preferring faster ones via quick'n'dirty heuristics only for now.
2019-04-07 19:11:17 +02: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
holger krekel c54afbe42e deprecate and warn about __multicall__ usage in hooks, refine docs about hook ordering,
make hookwrappers respect tryfirst/trylast

--HG--
branch : more_plugin
2015-04-27 12:50:34 +02:00
holger krekel d2a5c7f99b add documented hookimpl_opts and hookspec_opts decorators
so that one doesn't have to use pytest.mark or function-attribute setting anymore

--HG--
branch : more_plugin
2015-04-25 11:29:11 +02:00
holger krekel 715a235b45 remove shutdown logic from PluginManager and add a add_cleanup() API
for the already existing cleanup logic of the config object.
This simplifies lifecycle management as we don't keep two
layers of shutdown functions and also simplifies the pluginmanager
interface.

also add some docstrings.

--HG--
branch : plugin_no_pytest
2015-04-22 16:33:20 +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
holger krekel 745737e337 strike python2.5 from test code cc @flub 2014-09-05 09:50:40 +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
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 663f824fc4 simplify basedir isolation 2013-11-21 14:54:46 +01:00
holger krekel 2700a94d49 remove an old duplicate marker and use recent pytest mechanism for parametrization 2013-11-21 14:40:14 +01:00
holger krekel cbbbfcd101 fix collection imports for python2.5 2013-08-01 15:38:03 +02:00
holger krekel 377f63085a be more liberal with respect to lsof checks because jenkins keeps some files open 2013-07-29 15:39:24 +02:00
holger krekel 2a7c79dbf5 make genscript provide information as to compatibility
(now that argparse is a dependency on python2.6)
2013-07-26 08:59:31 +02:00
holger krekel 296f752cca fix --genscript option to generate standalone scripts that also
work with python3.3 (importer ordering)
2013-02-12 22:59:29 +01:00
holger krekel bb07ba7807 rename a number of internal and externally visible variables to use the fixture name
rather than funcargs.  Introduce .funcargnames compatibility attribute for backward compat.
2012-10-05 14:24:44 +02:00
holger krekel e79a312b92 fix internal test setup failure 2012-06-21 11:30:10 +02:00
holger krekel bc8ee95e72 add ini-file "markers" option and a cmdline option "--markers" to show defined markers. Add "skipif", "xfail" etc. to the set of builtin markers shown with the --markers option. 2011-11-11 22:56:11 +00:00
holger krekel a2f4a11301 refine lsof/FD leakage testing and rework test setup and some of pytest own tests. Note that the actual diff to non-test code is small. Also remove some redundant tests (introduced by a copy-paste-error apparently in test_mark.py). 2011-11-07 18:08:41 +00:00
holger krekel d4fe273b2f fix FD leakage during pytest's own test run and add "--lsof" option to tox default test runs.
the leakage came down to a problematic bit of the stdlib logging module: it takes ownerships of stdout/stderr making it hard for pytest to implement clean capturing.  The current work around is to add some extra code in the setup machinery of pytest's own tests which actually closes sub-FDs.
2011-11-06 15:40:17 +00:00
holger krekel fb1b1d9aae jython-2.5.2 has a core bug preventing pytest to run :( 2011-08-19 19:25:52 +02:00
holger krekel a698465487 streamline docs, especially use "import pytest" and "pytest.*" in python code examples instead of "import py" and "py.test.*". 2010-11-17 22:12:16 +01:00
holger krekel b6ec5a575d get option settings from ini-file. make getting configuration options from conftest.py only an internal feature.
--HG--
branch : trunk
2010-10-31 17:41:58 +01:00
holger krekel b86b1628bb introduce reading of setup.cfg / ini-style configuration files
rename internal config.Error to pytest.UsageError

--HG--
branch : trunk
2010-10-27 19:35:27 +02:00
holger krekel 90c1084a88 add --lsof self-testing option
--HG--
branch : trunk
2010-10-26 09:11:53 +02:00
holger krekel a6f10a6d80 unify collection for finding items and for finding initial nodes.
--HG--
branch : trunk
2010-10-25 23:08:41 +02:00
holger krekel d1aff902d5 remove pylib things and move things to new pytest namespace
--HG--
branch : trunk
2010-10-07 11:59:00 +02:00
holger krekel 5c27076d32 flatten test directory hierarchy and merge smaller into larger files
--HG--
branch : trunk
2010-01-13 16:17:50 +01:00