Commits

Ronny Pfannschmidt  committed d36f807 Merge

merge from default

  • Participants
  • Parent commits 46b26ed, 552a700
  • Branches collect-funcfail

Comments (0)

Files changed (160)

 *.pyc
 *.pyo
 *.swp
-*.html
 *.class
 *.orig
 *~
 0000000000000000000000000000000000000000 1.4.14
 0000000000000000000000000000000000000000 1.4.14
 0000000000000000000000000000000000000000 1.4.14
+af860de70cc3f157ac34ca1d4bf557a057bff775 2.4.0
+8828c924acae0b4cad2e2cb92943d51da7cb744a 2.4.1
+8d051f89184bfa3033f5e59819dff9f32a612941 2.4.2
+a064ad64d167508a8e9e73766b1a4e6bd10c85db 2.5.0
+039d543d1ca02a716c0b0de9a7131beb8021e8a2 2.5.1
 language: python
 # command to install dependencies
-install: "pip install 'virtualenv<1.10' -e . detox"
+install: "pip install -U detox"
 # # command to run tests
-script: detox --recreate
+script: detox --recreate -i ALL=https://devpi.net/hpk/dev/
+
 notifications:
   irc:
     - "chat.freenode.net#pytest-dev"
 Holger Krekel, holger at merlinux eu
 merlinux GmbH, Germany, office at merlinux eu
 
-Contributors include:: 
+Contributors include::
 
 Ronny Pfannschmidt
 Benjamin Peterson
 Jason R. Coombs
 Wouter van Ackooy
 Samuele Pedroni
-Anatoly Bubenkoff 
+Anatoly Bubenkoff
 Brianna Laugher
 Carl Friedrich Bolz
 Armin Rigo
 Maho
-Jaap Broekhuizen 
+Jaap Broekhuizen
 Maciek Fijalkowski
 Guido Wesdorp
 Brian Dorsey
 Ross Lawley
 Ralf Schmitt
-Chris Lamb 
+Chris Lamb
 Harald Armin Massa
 Martijn Faassen
-Ian Bicking 
+Ian Bicking
 Jan Balster
 Grig Gheorghiu
 Bob Ippolito
 Katarzyna Jachim
 Christian Theunert
 Anthon van der Neut
+Mark Abramowitz
+Piotr Banaszkiewicz
+Jurko Gospodnetić
-Changes between 2.3.5 and 2.4.DEV
+UNRELEASED
 -----------------------------------
 
-- make "import pdb ; pdb.set_trace()" work natively wrt capturing (no "-s" needed
-  anymore), making ``pytest.set_trace()`` a mere shortcut.
+- fix issue409 -- better interoperate with cx_freeze by not
+  trying to import from collections.abc which causes problems for py27/cx_freeze.
+  Thanks Wolfgang L. for reporting and tracking it down.
 
-- fix issue181: --pdb now also works on collect errors (and 
-  on internal errors) .  This was implemented by a slight internal 
-  refactoring and the introduction of a new hook 
-  ``pytest_exception_interact`` hook (see below).
+- fixed docs and code to use "pytest" instead of "py.test" almost everywhere.
+  Thanks Jurko Gospodnetic for the complete PR.  
 
-- fix issue341: introduce new experimental hook for IDEs/terminals to 
+- fix issue425: mention at end of "py.test -h" that --markers
+  and --fixtures work according to specified test path (or current dir)
+
+- fix issue413: exceptions with unicode attributes are now printed
+  correctly also on python2 and with pytest-xdist runs. (the fix
+  requires py-1.4.20)
+
+- copy, cleanup and integrate py.io capture
+  from pylib 1.4.20.dev2 (rev 13d9af95547e)
+  
+- address issue416: clarify docs as to conftest.py loading semantics
+
+
+- make capfd/capsys.capture private, its unused and shouldnt be exposed
+
+
+2.5.1
+-----------------------------------
+
+- merge new documentation styling PR from Tobias Bieniek.
+
+- fix issue403: allow parametrize of multiple same-name functions within
+  a collection node.  Thanks Andreas Kloeckner and Alex Gaynor for reporting
+  and analysis.
+
+- Allow parameterized fixtures to specify the ID of the parameters by
+  adding an ids argument to pytest.fixture() and pytest.yield_fixture().
+  Thanks Floris Bruynooghe. 
+
+- fix issue404 by always using the binary xml escape in the junitxml
+  plugin.  Thanks Ronny Pfannschmidt.
+
+- fix issue407: fix addoption docstring to point to argparse instead of
+  optparse. Thanks Daniel D. Wright.
+
+
+
+2.5.0
+-----------------------------------
+
+- dropped python2.5 from automated release testing of pytest itself
+  which means it's probably going to break soon (but still works
+  with this release we believe).
+
+- simplified and fixed implementation for calling finalizers when
+  parametrized fixtures or function arguments are involved.  finalization
+  is now performed lazily at setup time instead of in the "teardown phase".
+  While this might sound odd at first, it helps to ensure that we are
+  correctly handling setup/teardown even in complex code.  User-level code
+  should not be affected unless it's implementing the pytest_runtest_teardown
+  hook and expecting certain fixture instances are torn down within (very
+  unlikely and would have been unreliable anyway).
+
+- PR90: add --color=yes|no|auto option to force terminal coloring
+  mode ("auto" is default).  Thanks Marc Abramowitz.
+
+- fix issue319 - correctly show unicode in assertion errors.  Many
+  thanks to Floris Bruynooghe for the complete PR.  Also means
+  we depend on py>=1.4.19 now.
+
+- fix issue396 - correctly sort and finalize class-scoped parametrized
+  tests independently from number of methods on the class.
+
+- refix issue323 in a better way -- parametrization should now never
+  cause Runtime Recursion errors because the underlying algorithm
+  for re-ordering tests per-scope/per-fixture is not recursive
+  anymore (it was tail-call recursive before which could lead
+  to problems for more than >966 non-function scoped parameters).
+
+- fix issue290 - there is preliminary support now for parametrizing
+  with repeated same values (sometimes useful to to test if calling
+  a second time works as with the first time).
+
+- close issue240 - document precisely how pytest module importing
+  works, discuss the two common test directory layouts, and how it
+  interacts with PEP420-namespace packages.
+
+- fix issue246 fix finalizer order to be LIFO on independent fixtures
+  depending on a parametrized higher-than-function scoped fixture.
+  (was quite some effort so please bear with the complexity of this sentence :)
+  Thanks Ralph Schmitt for the precise failure example.
+
+- fix issue244 by implementing special index for parameters to only use
+  indices for paramentrized test ids
+
+- fix issue287 by running all finalizers but saving the exception
+  from the first failing finalizer and re-raising it so teardown will
+  still have failed.  We reraise the first failing exception because
+  it might be the cause for other finalizers to fail.
+
+- fix ordering when mock.patch or other standard decorator-wrappings
+  are used with test methods.  This fixues issue346 and should
+  help with random "xdist" collection failures.  Thanks to
+  Ronny Pfannschmidt and Donald Stufft for helping to isolate it.
+
+- fix issue357 - special case "-k" expressions to allow for
+  filtering with simple strings that are not valid python expressions.
+  Examples: "-k 1.3" matches all tests parametrized with 1.3.
+  "-k None" filters all tests that have "None" in their name
+  and conversely "-k 'not None'".
+  Previously these examples would raise syntax errors.
+
+- fix issue384 by removing the trial support code
+  since the unittest compat enhancements allow
+  trial to handle it on its own
+
+- don't hide an ImportError when importing a plugin produces one.
+  fixes issue375.
+
+- fix issue275 - allow usefixtures and autouse fixtures
+  for running doctest text files.
+
+- fix issue380 by making --resultlog only rely on longrepr instead
+  of the "reprcrash" attribute which only exists sometimes.
+
+- address issue122: allow @pytest.fixture(params=iterator) by exploding
+  into a list early on.
+
+- fix pexpect-3.0 compatibility for pytest's own tests.
+  (fixes issue386)
+
+- allow nested parametrize-value markers, thanks James Lan for the PR.
+
+- fix unicode handling with new monkeypatch.setattr(import_path, value)
+  API.  Thanks Rob Dennis.  Fixes issue371.
+
+- fix unicode handling with junitxml, fixes issue368.
+
+- In assertion rewriting mode on Python 2, fix the detection of coding
+  cookies. See issue #330.
+
+- make "--runxfail" turn imperative pytest.xfail calls into no ops
+  (it already did neutralize pytest.mark.xfail markers)
+
+- refine pytest / pkg_resources interactions: The AssertionRewritingHook
+  PEP302 compliant loader now registers itself with setuptools/pkg_resources
+  properly so that the pkg_resources.resource_stream method works properly.
+  Fixes issue366.  Thanks for the investigations and full PR to Jason R. Coombs.
+
+- pytestconfig fixture is now session-scoped as it is the same object during the
+  whole test run.  Fixes issue370.
+
+- avoid one surprising case of marker malfunction/confusion::
+
+      @pytest.mark.some(lambda arg: ...)
+      def test_function():
+
+  would not work correctly because pytest assumes @pytest.mark.some
+  gets a function to be decorated already.  We now at least detect if this
+  arg is an lambda and thus the example will work.  Thanks Alex Gaynor
+  for bringing it up.
+
+- xfail a test on pypy that checks wrong encoding/ascii (pypy does
+  not error out). fixes issue385.
+
+- internally make varnames() deal with classes's __init__,
+  although it's not needed by pytest itself atm.  Also
+  fix caching.  Fixes issue376.
+
+- fix issue221 - handle importing of namespace-package with no
+  __init__.py properly.
+
+- refactor internal FixtureRequest handling to avoid monkeypatching.
+  One of the positive user-facing effects is that the "request" object
+  can now be used in closures.
+
+- fixed version comparison in pytest.importskip(modname, minverstring)
+
+- fix issue377 by clarifying in the nose-compat docs that pytest
+  does not duplicate the unittest-API into the "plain" namespace.
+
+- fix verbose reporting for @mock'd test functions
+
+v2.4.2
+-----------------------------------
+
+- on Windows require colorama and a newer py lib so that py.io.TerminalWriter()
+  now uses colorama instead of its own ctypes hacks. (fixes issue365)
+  thanks Paul Moore for bringing it up.
+
+- fix "-k" matching of tests where "repr" and "attr" and other names would
+  cause wrong matches because of an internal implementation quirk
+  (don't ask) which is now properly implemented. fixes issue345.
+
+- avoid tmpdir fixture to create too long filenames especially
+  when parametrization is used (issue354)
+
+- fix pytest-pep8 and pytest-flakes / pytest interactions
+  (collection names in mark plugin was assuming an item always
+  has a function which is not true for those plugins etc.)
+  Thanks Andi Zeidler.
+
+- introduce node.get_marker/node.add_marker API for plugins
+  like pytest-pep8 and pytest-flakes to avoid the messy
+  details of the node.keywords  pseudo-dicts.  Adapated
+  docs.
+
+- remove attempt to "dup" stdout at startup as it's icky.
+  the normal capturing should catch enough possibilities
+  of tests messing up standard FDs.
+
+- add pluginmanager.do_configure(config) as a link to
+  config.do_configure() for plugin-compatibility
+
+v2.4.1
+-----------------------------------
+
+- When using parser.addoption() unicode arguments to the
+  "type" keyword should also be converted to the respective types.
+  thanks Floris Bruynooghe, @dnozay. (fixes issue360 and issue362)
+
+- fix dotted filename completion when using argcomplete
+  thanks Anthon van der Neuth. (fixes issue361)
+
+- fix regression when a 1-tuple ("arg",) is used for specifying
+  parametrization (the values of the parametrization were passed
+  nested in a tuple).  Thanks Donald Stufft.
+
+- merge doc typo fixes, thanks Andy Dirnberger
+
+v2.4
+-----------------------------------
+
+known incompatibilities:
+
+- if calling --genscript from python2.7 or above, you only get a
+  standalone script which works on python2.7 or above.  Use Python2.6
+  to also get a python2.5 compatible version.
+
+- all xunit-style teardown methods (nose-style, pytest-style,
+  unittest-style) will not be called if the corresponding setup method failed,
+  see issue322 below.
+
+- the pytest_plugin_unregister hook wasn't ever properly called
+  and there is no known implementation of the hook - so it got removed.
+
+- pytest.fixture-decorated functions cannot be generators (i.e. use
+  yield) anymore.  This change might be reversed in 2.4.1 if it causes
+  unforeseen real-life issues.  However, you can always write and return
+  an inner function/generator and change the fixture consumer to iterate
+  over the returned generator.  This change was done in lieu of the new
+  ``pytest.yield_fixture`` decorator, see below.
+
+new features:
+
+- experimentally introduce a new ``pytest.yield_fixture`` decorator
+  which accepts exactly the same parameters as pytest.fixture but
+  mandates a ``yield`` statement instead of a ``return statement`` from
+  fixture functions.  This allows direct integration with "with-style"
+  context managers in fixture functions and generally avoids registering
+  of finalization callbacks in favour of treating the "after-yield" as
+  teardown code.  Thanks Andreas Pelme, Vladimir Keleshev, Floris
+  Bruynooghe, Ronny Pfannschmidt and many others for discussions.
+
+- allow boolean expression directly with skipif/xfail
+  if a "reason" is also specified.  Rework skipping documentation
+  to recommend "condition as booleans" because it prevents surprises
+  when importing markers between modules.  Specifying conditions
+  as strings will remain fully supported.
+
+- reporting: color the last line red or green depending if
+  failures/errors occured or everything passed.  thanks Christian
+  Theunert.
+
+- make "import pdb ; pdb.set_trace()" work natively wrt capturing (no
+  "-s" needed anymore), making ``pytest.set_trace()`` a mere shortcut.
+
+- fix issue181: --pdb now also works on collect errors (and
+  on internal errors) .  This was implemented by a slight internal
+  refactoring and the introduction of a new hook
+  ``pytest_exception_interact`` hook (see next item).
+
+- fix issue341: introduce new experimental hook for IDEs/terminals to
   intercept debugging: ``pytest_exception_interact(node, call, report)``.
 
+- new monkeypatch.setattr() variant to provide a shorter
+  invocation for patching out classes/functions from modules:
+
+     monkeypatch.setattr("requests.get", myfunc)
+
+  will replace the "get" function of the "requests" module with ``myfunc``.
+
+- fix issue322: tearDownClass is not run if setUpClass failed. Thanks
+  Mathieu Agopian for the initial fix.  Also make all of pytest/nose
+  finalizer mimick the same generic behaviour: if a setupX exists and
+  fails, don't run teardownX.  This internally introduces a new method
+  "node.addfinalizer()" helper which can only be called during the setup
+  phase of a node.
+
+- simplify pytest.mark.parametrize() signature: allow to pass a
+  CSV-separated string to specify argnames.  For example:
+  ``pytest.mark.parametrize("input,expected",  [(1,2), (2,3)])``
+  works as well as the previous:
+  ``pytest.mark.parametrize(("input", "expected"), ...)``.
+
+- add support for setUpModule/tearDownModule detection, thanks Brian Okken.
+
+- integrate tab-completion on options through use of "argcomplete".
+  Thanks Anthon van der Neut for the PR.
+
+- change option names to be hyphen-separated long options but keep the
+  old spelling backward compatible.  py.test -h will only show the
+  hyphenated version, for example "--collect-only" but "--collectonly"
+  will remain valid as well (for backward-compat reasons).  Many thanks to
+  Anthon van der Neut for the implementation and to Hynek Schlawack for
+  pushing us.
+
+- fix issue 308 - allow to mark/xfail/skip individual parameter sets
+  when parametrizing.  Thanks Brianna Laugher.
+
+- call new experimental pytest_load_initial_conftests hook to allow
+  3rd party plugins to do something before a conftest is loaded.
+
+Bug fixes:
+
+- fix issue358 - capturing options are now parsed more properly
+  by using a new parser.parse_known_args method.
+
+- pytest now uses argparse instead of optparse (thanks Anthon) which
+  means that "argparse" is added as a dependency if installing into python2.6
+  environments or below.
+
+- fix issue333: fix a case of bad unittest/pytest hook interaction.
+
 - PR27: correctly handle nose.SkipTest during collection.  Thanks
   Antonio Cuni, Ronny Pfannschmidt.
 
-- new monkeypatch.replace() to avoid imports and provide a shorter
-  invocation for patching out classes/functions from modules:
-
-     monkeypatch.replace("requests.get", myfunc
-
-  will replace the "get" function of the "requests" module with ``myfunc``.
-  
-- fix issue322: tearDownClass is not run if setUpClass failed. Thanks
-  Mathieu Agopian for the initial fix.  Also make all of pytest/nose finalizer 
-  mimick the same generic behaviour: if a setupX exists and fails, 
-  don't run teardownX.  This also introduces a new method "node.addfinalizer()"
-  helper which can only be called during the setup phase of a node.
+- fix issue355: junitxml puts name="pytest" attribute to testsuite tag.
 
 - fix issue336: autouse fixture in plugins should work again.
 
-- change to use hyphen-separated long options but keep the old spelling
-  backward compatible.  py.test -h will only show the hyphenated version,
-  for example "--collect-only" but "--collectonly" will remain valid as well
-  (for backward-compat reasons).  Many thanks to Anthon van der Neut for
-  the implementation and to Hynek Schlawack for pushing us.
-
 - fix issue279: improve object comparisons on assertion failure
   for standard datatypes and recognise collections.abc.  Thanks to
   Brianna Laugher and Mathieu Agopian.
 
 - fix issue305: ignore any problems when writing pyc files.
 
-- integrate tab-completion on options through use of "argcomplete".
-  Thanks Anthon van der Neut for the PR.
-
-- pytest now uses argparse instead of optparse (thanks Anthon) which 
-  means that "argparse" is added as a dependency if installing into python2.6
-  environments or below.
-
 - SO-17664702: call fixture finalizers even if the fixture function
   partially failed (finalizers would not always be called before)
 
-- color the last line red or green depending if failures/errors occured
-  or everything passed.  thanks Christian Theunert.
-
 - fix issue320 - fix class scope for fixtures when mixed with
   module-level functions.  Thanks Anatloy Bubenkoff.
 
 
 - fix issue323 - sorting of many module-scoped arg parametrizations
 
-- add support for setUpModule/tearDownModule detection, thanks Brian Okken.
-
 - make sessionfinish hooks execute with the same cwd-context as at
-  session start (helps fix plugin behaviour which write output files 
+  session start (helps fix plugin behaviour which write output files
   with relative path such as pytest-cov)
 
 - fix issue316 - properly reference collection hooks in docs
 
-- fix issue 308 - allow to mark/xfail/skip individual parameter sets
-  when parametrizing.  Thanks Brianna Laugher.
-
-- simplify parametrize() signature: allow to pass a CSV-separated string 
-  to specify argnames.  For example: ``pytest.mark.parametrize("input,expected",  [(1,2), (2,3)])`` is possible now in addition to the prior
-  ``pytest.mark.parametrize(("input", "expected"), ...)``.
-
 - fix issue 306 - cleanup of -k/-m options to only match markers/test
   names/keywords respectively.  Thanks Wouter van Ackooy.
 
-- (experimental) allow fixture functions to be 
-  implemented as context managers.  Thanks Andreas Pelme,
-  Vladimir Keleshev. 
-
-- (experimental) allow boolean expression directly with skipif/xfail
-  if a "reason" is also specified.  Rework skipping documentation
-  to recommend "condition as booleans" because it prevents surprises
-  when importing markers between modules.  Specifying conditions
-  as strings will remain fully supported.
-
-- improved doctest counting for doctests in python modules -- 
+- improved doctest counting for doctests in python modules --
   files without any doctest items will not show up anymore
   and doctest examples are counted as separate test items.
   thanks Danilo Bellini.
   mode. Thanks Jason R. Coombs.
 
 - fix junitxml generation when test output contains control characters,
-  addressing issue267, thanks Jaap Broekhuizen 
+  addressing issue267, thanks Jaap Broekhuizen
 
 - fix issue338: honor --tb style for setup/teardown errors as well.  Thanks Maho.
 
 
 - better parametrize error messages, thanks Brianna Laugher
 
+- pytest_terminal_summary(terminalreporter) hooks can now use
+  ".section(title)" and ".line(msg)" methods to print extra
+  information at the end of a test run.
 
-known incompatibilities:
-
-- if calling --genscript from python2.7 or above, you only get a
-  standalone script which works on python2.7 or above.  Use Python2.6
-  to also get a python2.5 compatible version.
-
-
-Changes between 2.3.4 and 2.3.5
+v2.3.5
 -----------------------------------
 
 - fix issue169: respect --tb=style with setup/teardown errors as well.
 - fix bug where using capsys with pytest.set_trace() in a test
   function would break when looking at capsys.readouterr()
 
-- allow to specify prefixes starting with "_" when 
+- allow to specify prefixes starting with "_" when
   customizing python_functions test discovery. (thanks Graham Horler)
 
 - improve PYTEST_DEBUG tracing output by puting
 
 - fix issue266 - accept unicode in MarkEvaluator expressions
 
-Changes between 2.3.3 and 2.3.4
+v2.3.4
 -----------------------------------
 
-- yielded test functions will now have autouse-fixtures active but 
+- yielded test functions will now have autouse-fixtures active but
   cannot accept fixtures as funcargs - it's anyway recommended to
   rather use the post-2.0 parametrize features instead of yield, see:
   http://pytest.org/latest/example/parametrize.html
   can write: -k "name1 or name2" etc.  This is a slight incompatibility
   if you used special syntax like "TestClass.test_method" which you now
   need to write as -k "TestClass and test_method" to match a certain
-  method in a certain test class.  
+  method in a certain test class.
 
-Changes between 2.3.2 and 2.3.3
+v2.3.3
 -----------------------------------
 
 - fix issue214 - parse modules that contain special objects like e. g.
 - fix issue127 - improve documentation for pytest_addoption() and
   add a ``config.getoption(name)`` helper function for consistency.
 
-Changes between 2.3.1 and 2.3.2
+v2.3.2
 -----------------------------------
 
-- fix issue208 and fix issue29 use new py version to avoid long pauses 
+- fix issue208 and fix issue29 use new py version to avoid long pauses
   when printing tracebacks in long modules
 
 - fix issue205 - conftests in subdirs customizing
   - add tox.ini to pytest distribution so that ignore-dirs and others config
     bits are properly distributed for maintainers who run pytest-own tests
 
-Changes between 2.3.0 and 2.3.1
+v2.3.1
 -----------------------------------
 
 - fix issue202 - fix regression: using "self" from fixture functions now
 - link to web pages from --markers output which provides help for
   pytest.mark.* usage.
 
-Changes between 2.2.4 and 2.3.0
+v2.3.0
 -----------------------------------
 
 - fix issue202 - better automatic names for parametrized test functions
 - pluginmanager.register(...) now raises ValueError if the
   plugin has been already registered or the name is taken
 
-- fix issue159: improve http://pytest.org/latest/faq.html 
+- fix issue159: improve http://pytest.org/latest/faq.html
   especially with respect to the "magic" history, also mention
   pytest-django, trial and unittest integration.
 
     you can use startdir.bestrelpath(yourpath) to show
     nice relative path
 
-  - allow plugins to implement both pytest_report_header and 
+  - allow plugins to implement both pytest_report_header and
     pytest_sessionstart (sessionstart is invoked first).
 
   - don't show deselected reason line if there is none
 
   - py.test -vv will show all of assert comparisations instead of truncating
 
-Changes between 2.2.3 and 2.2.4
+v2.2.4
 -----------------------------------
 
 - fix error message for rewritten assertions involving the % operator
 - fix issue #144: better mangle test ids to junitxml classnames
 - upgrade distribute_setup.py to 0.6.27
 
-Changes between 2.2.2 and 2.2.3
+v2.2.3
 ----------------------------------------
 
 - fix uploaded package to only include neccesary files
 
-Changes between 2.2.1 and 2.2.2
+v2.2.2
 ----------------------------------------
 
 - fix issue101: wrong args to unittest.TestCase test function now
   produce better output
-- fix issue102: report more useful errors and hints for when a 
+- fix issue102: report more useful errors and hints for when a
   test directory was renamed and some pyc/__pycache__ remain
 - fix issue106: allow parametrize to be applied multiple times
   e.g. from module, class and at function level.
 - allow adding of attributes to test reports such that it also works
   with distributed testing (no upgrade of pytest-xdist needed)
 
-Changes between 2.2.0 and 2.2.1
+v2.2.1
 ----------------------------------------
 
 - fix issue99 (in pytest and py) internallerrors with resultlog now
-  produce better output - fixed by normalizing pytest_internalerror 
+  produce better output - fixed by normalizing pytest_internalerror
   input arguments.
 - fix issue97 / traceback issues (in pytest and py) improve traceback output
   in conjunction with jinja2 and cython which hack tracebacks
   the final test in a test node will now run its teardown directly
   instead of waiting for the end of the session. Thanks Dave Hunt for
   the good reporting and feedback.  The pytest_runtest_protocol as well
-  as the pytest_runtest_teardown hooks now have "nextitem" available 
+  as the pytest_runtest_teardown hooks now have "nextitem" available
   which will be None indicating the end of the test run.
 - fix collection crash due to unknown-source collected items, thanks
   to Ralf Schmitt (fixed by depending on a more recent pylib)
 
-Changes between 2.1.3 and 2.2.0
+v2.2.0
 ----------------------------------------
 
 - fix issue90: introduce eager tearing down of test items so that
   teardown function are called earlier.
-- add an all-powerful metafunc.parametrize function which allows to 
+- add an all-powerful metafunc.parametrize function which allows to
   parametrize test function arguments in multiple steps and therefore
-  from indepdenent plugins and palces. 
+  from indepdenent plugins and palces.
 - add a @pytest.mark.parametrize helper which allows to easily
   call a test function with different argument values
-- Add examples to the "parametrize" example page, including a quick port 
+- Add examples to the "parametrize" example page, including a quick port
   of Test scenarios and the new parametrize function and decorator.
 - introduce registration for "pytest.mark.*" helpers via ini-files
-  or through plugin hooks.  Also introduce a "--strict" option which 
+  or through plugin hooks.  Also introduce a "--strict" option which
   will treat unregistered markers as errors
   allowing to avoid typos and maintain a well described set of markers
   for your test suite.  See exaples at http://pytest.org/latest/mark.html
   (this is a stricter and more predictable version of '-k' in that "-m"
   only matches complete markers and has more obvious rules for and/or
   semantics.
-- new feature to help optimizing the speed of your tests: 
-  --durations=N option for displaying N slowest test calls 
+- new feature to help optimizing the speed of your tests:
+  --durations=N option for displaying N slowest test calls
   and setup/teardown methods.
 - fix issue87: --pastebin now works with python3
 - fix issue89: --pdb with unexpected exceptions in doctest work more sensibly
-- fix and cleanup pytest's own test suite to not leak FDs 
+- fix and cleanup pytest's own test suite to not leak FDs
 - fix issue83: link to generated funcarg list
 - fix issue74: pyarg module names are now checked against imp.find_module false positives
 - fix compatibility with twisted/trial-11.1.0 use cases
 - simplify junitxml output code by relying on py.xml
 - add support for skip properties on unittest classes and functions
 
-Changes between 2.1.2 and 2.1.3
+v2.1.3
 ----------------------------------------
 
 - fix issue79: assertion rewriting failed on some comparisons in boolops
 - fix issue75 / skipping test failure on jython
 - fix issue77 / Allow assertrepr_compare hook to apply to a subset of tests
 
-Changes between 2.1.1 and 2.1.2
+v2.1.2
 ----------------------------------------
 
 - fix assertion rewriting on files with windows newlines on some Python versions
 - fix issue66: use different assertion rewriting caches when the -O option is passed
 - don't try assertion rewriting on Jython, use reinterp
 
-Changes between 2.1.0 and 2.1.1
+v2.1.1
 ----------------------------------------------
 
 - fix issue64 / pytest.set_trace now works within pytest_generate_tests hooks
 - fix issue61: assertion rewriting on boolean operations with 3 or more operands
 - you can now build a man page with "cd doc ; make man"
 
-Changes between 2.0.3 and 2.1.0.DEV
+v2.1.0
 ----------------------------------------------
 
 - fix issue53 call nosestyle setup functions with correct ordering
 - report KeyboardInterrupt even if interrupted during session startup
 - fix issue 35 - provide PDF doc version and download link from index page
 
-Changes between 2.0.2 and 2.0.3
+v2.0.3
 ----------------------------------------------
 
 - fix issue38: nicer tracebacks on calls to hooks, particularly early
 
 - fix issue37: avoid invalid characters in junitxml's output
 
-Changes between 2.0.1 and 2.0.2
+v2.0.2
 ----------------------------------------------
 
 - tackle issue32 - speed up test runs of very quick test functions
 
   Also you can now access module globals from xfail/skipif
   expressions so that this for example works now::
- 
+
     import pytest
     import mymodule
     @pytest.mark.skipif("mymodule.__version__[0] == "1")
     def test_function():
         pass
 
-  This will not run the test function if the module's version string 
+  This will not run the test function if the module's version string
   does not start with a "1".  Note that specifying a string instead
-  of a boolean expressions allows py.test to report meaningful information 
-  when summarizing a test run as to what conditions lead to skipping 
+  of a boolean expressions allows py.test to report meaningful information
+  when summarizing a test run as to what conditions lead to skipping
   (or xfail-ing) tests.
 
 - fix issue28 - setup_method and pytest_generate_tests work together
 - fixed typos in the docs (thanks Victor Garcia, Brianna Laugher) and particular
   thanks to Laura Creighton who also revieved parts of the documentation.
 
-- fix slighly wrong output of verbose progress reporting for classes 
+- fix slighly wrong output of verbose progress reporting for classes
   (thanks Amaury)
 
 - more precise (avoiding of) deprecation warnings for node.Class|Function accesses
 
 - avoid std unittest assertion helper code in tracebacks (thanks Ronny)
 
-Changes between 2.0.0 and 2.0.1
+v2.0.1
 ----------------------------------------------
 
 - refine and unify initial capturing so that it works nicely
 - allow to omit "()" in test ids to allow for uniform test ids
   as produced by Alfredo's nice pytest.vim plugin.
 - fix issue12 - show plugin versions with "--version" and
-  "--traceconfig" and also document how to add extra information 
+  "--traceconfig" and also document how to add extra information
   to reporting test header
 - fix issue17 (import-* reporting issue on python3) by
   requiring py>1.4.0 (1.4.1 is going to include it)
 - fix issue14: no logging errors at process exit
 - refinements to "collecting" output on non-ttys
 - refine internal plugin registration and --traceconfig output
-- introduce a mechanism to prevent/unregister plugins from the 
+- introduce a mechanism to prevent/unregister plugins from the
   command line, see http://pytest.org/plugins.html#cmdunregister
 - activate resultlog plugin by default
 - fix regression wrt yielded tests which due to the
-  collection-before-running semantics were not 
+  collection-before-running semantics were not
   setup as with pytest 1.3.4.  Note, however, that
-  the recommended and much cleaner way to do test 
+  the recommended and much cleaner way to do test
   parametraization remains the "pytest_generate_tests"
   mechanism, see the docs.
 
-Changes between 1.3.4 and 2.0.0
+v2.0.0
 ----------------------------------------------
 
 - pytest-2.0 is now its own package and depends on pylib-2.0
 - add ability to use "class" level for cached_setup helper
 - fix strangeness: mark.* objects are now immutable, create new instances
 
-Changes between 1.3.3 and 1.3.4
+v1.3.4
 ----------------------------------------------
 
 - fix issue111: improve install documentation for windows
 - fix issue115: unify internal exception passthrough/catching/GeneratorExit
 - fix issue118: new --tb=native for presenting cpython-standard exceptions
 
-Changes between 1.3.2 and 1.3.3
+v1.3.3
 ----------------------------------------------
 
 - fix issue113: assertion representation problem with triple-quoted strings
   (thanks Armin Ronacher for reporting)
 - remove trailing whitespace in all py/text distribution files
 
-Changes between 1.3.1 and 1.3.2
+v1.3.2
 ----------------------------------------------
 
 New features
 - fix homedir detection on Windows
 - ship distribute_setup.py version 0.6.13
 
-Changes between 1.3.0 and 1.3.1
+v1.3.1
 ---------------------------------------------
 
 New features
   (and internally be more careful when presenting unexpected byte sequences)
 
 
-Changes between 1.2.1 and 1.3.0
+v1.3.0
 ---------------------------------------------
 
 - deprecate --report option in favour of a new shorter and easier to
 - added links to the new capturelog and coverage plugins
 
 
-Changes between 1.2.1 and 1.2.0
+v1.2.0
 ---------------------------------------------
 
 - refined usage and options for "py.cleanup"::
 
 - fix plugin links
 
-Changes between 1.2 and 1.1.1
+v1.1.1
 ---------------------------------------------
 
 - moved dist/looponfailing from py.test core into a new
 - fix docs, fix internal bin/ script generation
 
 
-Changes between 1.1.1 and 1.1.0
+v1.1.0
 ---------------------------------------------
 
 - introduce automatic plugin registration via 'pytest11'
 - try harder to have deprecation warnings for py.compat.* accesses
   report a correct location
 
-Changes between 1.1.0 and 1.0.2
+v1.0.2
 ---------------------------------------------
 
 * adjust and improve docs
 
 * simplified internal localpath implementation
 
-Changes between 1.0.1 and 1.0.2
+v1.0.2
 -------------------------------------------
 
 * fixing packaging issues, triggered by fedora redhat packaging,
 
 * added a documentation link to the new django plugin.
 
-Changes between 1.0.0 and 1.0.1
+v1.0.1
 -------------------------------------------
 
 * added a 'pytest_nose' plugin which handles nose.SkipTest,
 * simplified multicall mechanism and plugin architecture,
   renamed some internal methods and argnames
 
-Changes between 1.0.0b9 and 1.0.0
+v1.0.0
 -------------------------------------------
 
 * more terse reporting try to show filesystem path relatively to current dir
 * improve xfail output a bit
 
-Changes between 1.0.0b8 and 1.0.0b9
+v1.0.0b9
 -------------------------------------------
 
 * cleanly handle and report final teardown of test setup
 * item.repr_failure(excinfo) instead of item.repr_failure(excinfo, outerr)
 
 
-Changes between 1.0.0b7 and 1.0.0b8
+v1.0.0b8
 -------------------------------------------
 
 * pytest_unittest-plugin is now enabled by default
 * tweaked doctest output for docstrings in py modules,
   thanks Radomir.
 
-Changes between 1.0.0b3 and 1.0.0b7
+v1.0.0b7
 -------------------------------------------
 
 * renamed py.test.xfail back to py.test.mark.xfail to avoid
 
 * make __name__ == "__channelexec__" for remote_exec code
 
-Changes between 1.0.0b1 and 1.0.0b3
+v1.0.0b3
 -------------------------------------------
 
 * plugin classes are removed: one now defines
   well with function arguments.
 
 
-Changes between 0.9.2 and 1.0.0b1
+v1.0.0b1
 -------------------------------------------
 
 * introduced new "funcarg" setup method,
 
 XXX lots of things missing here XXX
 
-Changes between 0.9.1 and 0.9.2
+v0.9.2
 -------------------------------------------
 
 * refined installation and metadata, created new setup.py,
 
 * there now is a py.__version__ attribute
 
-Changes between 0.9.0 and 0.9.1
+v0.9.1
 -------------------------------------------
 
-This is a fairly complete list of changes between 0.9 and 0.9.1, which can
+This is a fairly complete list of v0.9.1, which can
 serve as a reference for developers.
 
 * allowing + signs in py.path.svn urls [39106]

File CONTRIBUTING.rst

+============
+Contributing
+============
+
+Contributions are highly welcomed and appreciated.  Every little help counts,
+so do not hesitate!
+
+
+Types of contributions
+======================
+
+Report bugs
+-----------
+
+Report bugs at https://bitbucket.org/hpk42/pytest/issues.
+
+If you are reporting a bug, please include:
+
+* Your operating system name and version.
+* Any details about your local setup that might be helpful in troubleshooting,
+  specifically Python interpreter version,
+  installed libraries and pytest version.
+* Detailed steps to reproduce the bug.
+
+Submit feedback for developers
+------------------------------
+
+Do you like pytest?  Share some love on Twitter or in your blog posts!
+
+We'd also like to hear about your propositions and suggestions.  Feel free to
+`submit them as issues <https://bitbucket.org/hpk42/pytest/issues>`__ and:
+
+* Set the "kind" to "enhancement" or "proposal" so that we can quickly find
+  about them.
+* Explain in detail how they should work.
+* Keep the scope as narrow as possible.  This will make it easier to implement.
+* If you have required skills and/or knowledge, we are very happy for
+  :ref:`pull requests <pull-requests>`.
+
+
+Fix bugs
+--------
+
+Look through the BitBucket issues for bugs.  Here is sample filter you can use:
+https://bitbucket.org/hpk42/pytest/issues?status=new&status=open&kind=bug
+
+:ref:`Talk <contact>` to developers to find out how you can fix specific bugs.
+
+Implement features
+------------------
+
+Look through the BitBucket issues for enhancements.  Here is sample filter you
+can use:
+https://bitbucket.org/hpk42/pytest/issues?status=new&status=open&kind=enhancement
+
+:ref:`Talk <contact>` to developers to find out how you can implement specific
+features.
+
+Write documentation
+-------------------
+
+pytest could always use more documentation.  What exactly is needed?
+
+* More complementary documentation.  Have you perhaps found something unclear?
+* Documentation translations.  We currently have English and Japanese versions.
+* Docstrings.  There's never too much of them.
+* Blog posts, articles and such -- they're all very appreciated.
+
+.. _pull-requests:
+
+Preparing Pull Requests on Bitbucket
+=====================================
+
+.. note::
+  What is a "pull request"?  It informs project's core developers about the
+  changes you want to review and merge.  Pull requests are stored on
+  `BitBucket servers <https://bitbucket.org/hpk42/pytest/pull-requests>`__.
+  Once you send pull request, we can discuss it's potential modifications and
+  even add more commits to it later on.
+
+The primary development platform for pytest is BitBucket.  You can find all
+the issues there and submit your pull requests.
+
+1. Fork the
+   `pytest BitBucket repository <https://bitbucket.org/hpk42/pytest>`__.  It's
+   fine to use ``pytest`` as your fork repository name because it will live
+   under your user.
+
+.. _virtualenvactivate:
+
+2. Create and activate a fork-specific virtualenv
+   (http://www.virtualenv.org/en/latest/)::
+
+    $ virtualenv pytest-venv
+    $ source pytest-venv/bin/activate
+
+.. _checkout:
+
+3. Clone your fork locally using `Mercurial <http://mercurial.selenic.com/>`_
+   (``hg``) and create a branch::
+
+    $ hg clone ssh://hg@bitbucket.org/YOUR_BITBUCKET_USERNAME/pytest
+    $ cd pytest
+    $ hg branch your-branch-name
+
+   If you need some help with Mercurial, follow this quick start
+   guide: http://mercurial.selenic.com/wiki/QuickStart
+
+.. _testing-pytest:
+
+4. You can now edit your local working copy.  To test you need to
+   install the "tox" tool into your virtualenv::
+
+    $ pip install tox
+
+  You need to have Python 2.7 and 3.3 available in your system.  Now
+  running tests is as simple as issuing this command::
+
+    $ python runtox.py -e py27,py33,flakes
+
+  This command will run tests via the "tox" tool against Python 2.7 and 3.3
+  and also perform "flakes" coding-style checks.  ``runtox.py`` is
+  a thin wrapper around ``tox`` which installs from a development package
+  index where newer (not yet released to pypi) versions of dependencies
+  (especially ``py``) might be present.
+
+  To run tests on py27 and pass options (e.g. enter pdb on failure)
+  to pytest you can do::
+
+    $ python runtox.py -e py27 -- --pdb
+
+  or to only run tests in a particular test module on py33::
+
+    $ python runtox.py -e py33 -- testing/test_config.py
+
+5. Commit and push once your tests pass and you are happy with your change(s)::
+
+    $ hg commit -m"<commit message>"
+    $ hg push -b .
+
+6. Finally, submit a pull request through the BitBucket website:
+
+  .. image:: img/pullrequest.png
+     :width: 700px
+     :align: center
+
+  ::
+
+    source: YOUR_BITBUCKET_USERNAME/pytest
+    branch: your-branch-name
+
+    target: hpk42/pytest
+    branch: default
+
+.. _contribution-using-git:
+
+What about git (and so GitHub)?
+-------------------------------
+
+There used to be the pytest GitHub mirror.  It was removed in favor of the
+Mercurial one, to remove confusion of people not knowing where it's better to
+put their issues and pull requests.  Also it wasn't easily possible to automate
+the mirroring process.
+
+However, it's still possible to use git to contribute to pytest using tools
+like `gitifyhg <https://github.com/buchuki/gitifyhg>`_ which allows you to
+clone and work with Mercurial repo still using git.
+
+.. warning::
+  Remember that git is **not** a default version control system for pytest and
+  you need to be careful using it.
 -------------------------------------------------------
 tags: feature 
 
-- introduce py.test.mark.nocollect for not considering a function for
-  test collection at all.  maybe also introduce a py.test.mark.test to
+- introduce pytest.mark.nocollect for not considering a function for
+  test collection at all.  maybe also introduce a pytest.mark.test to
   explicitely mark a function to become a tested one.  Lookup JUnit ways
   of tagging tests.
 
 a pytest.mark.importorskip so that the test count is more correct.
 
 
-introduce py.test.mark.platform
+introduce pytest.mark.platform
 -------------------------------------------------------
 tags: feature 
 
 Introduce nice-to-spell platform-skipping, examples:
 
-    @py.test.mark.platform("python3")
-    @py.test.mark.platform("not python3")
-    @py.test.mark.platform("win32 and not python3")
-    @py.test.mark.platform("darwin")
-    @py.test.mark.platform("not (jython and win32)")
-    @py.test.mark.platform("not (jython and win32)", xfail=True)
+    @pytest.mark.platform("python3")
+    @pytest.mark.platform("not python3")
+    @pytest.mark.platform("win32 and not python3")
+    @pytest.mark.platform("darwin")
+    @pytest.mark.platform("not (jython and win32)")
+    @pytest.mark.platform("not (jython and win32)", xfail=True)
 
 etc. Idea is to allow Python expressions which can operate
 on common spellings for operating systems and python
 allow to name conftest.py files (in sub directories) that should
 be imported early, as to include command line options.
 
-improve central py.test ini file
-----------------------------------
+improve central pytest ini file
+-------------------------------
 tags: feature 
 
 introduce more declarative configuration options:
 ----------------------------------
 tags: feature 
 
-- logo py.test
+- logo pytest
 - examples for unittest or functional testing
 - resource management for functional testing
 - patterns: page object
 --------------------------------------------------------
 tags: bug 
 
-With 1.1.1 py.test fails at least on windows if an import
+With 1.1.1 pytest fails at least on windows if an import
 is relative and compared against an absolute conftest.py
 path. Normalize.
 
-consider globals: py.test.ensuretemp and config
+consider globals: pytest.ensuretemp and config
 --------------------------------------------------------------
 tags: experimental-wish 
 
-consider deprecating py.test.ensuretemp and py.test.config
-to further reduce py.test globality.  Also consider
-having py.test.config and ensuretemp coming from
+consider deprecating pytest.ensuretemp and pytest.config
+to further reduce pytest globality.  Also consider
+having pytest.config and ensuretemp coming from
 a plugin rather than being there from the start.
 
 
 -----------------------------------------
 tags: wish
 
-py.test could call a new pytest_addsyspath() in order to systematically
+pytest could call a new pytest_addsyspath() in order to systematically
 allow manipulation of sys.path and to inhibit it via --no-addsyspath
 in order to more easily run against installed packages.
 
 
 
 
-deprecate global py.test.config usage
+deprecate global pytest.config usage
 ----------------------------------------------------------------
 tags: feature 
 
-py.test.ensuretemp and py.test.config are probably the last
+pytest.ensuretemp and pytest.config are probably the last
 objects containing global state.  Often using them is not
 neccessary.  This is about trying to get rid of them, i.e.
 deprecating them and checking with PyPy's usages as well
-The ``py.test`` testing tool makes it easy to write small tests, yet
+
+Documentation: http://pytest.org/latest/
+
+Changelog: http://pytest.org/latest/changelog.html
+
+Issues: https://bitbucket.org/hpk42/pytest/issues?status=open
+
+The ``pytest`` testing tool makes it easy to write small tests, yet
 scales to support complex functional testing.  It provides
 
 - `auto-discovery
 - detailed info on failing `assert statements <http://pytest.org/latest/assert.html>`_ (no need to remember ``self.assert*`` names)
 - `modular fixtures <http://pytest.org/latest/fixture.html>`_  for
   managing small or parametrized long-lived test resources.
-- multi-paradigm support: you can use ``py.test`` to run test suites based
+- multi-paradigm support: you can use ``pytest`` to run test suites based
   on `unittest <http://pytest.org/latest/unittest.html>`_ (or trial),
   `nose <http://pytest.org/latest/nose.html>`_
-- single-source compatibility to Python2.4 all the way up to Python3.3,
+- single-source compatibility to Python2.5 all the way up to Python3.3,
   PyPy-1.9 and Jython-2.5.1.
 
 - many `external plugins <http://pytest.org/latest/plugins.html#installing-external-plugins-searching>`_.
 
-.. image:: https://secure.travis-ci.org/hpk42/pytest.png
-   :target: http://travis-ci.org/hpk42/pytest
-
 A simple example for a test::
 
     # content of test_module.py

File _pytest/__init__.py

 #
-__version__ = '2.4.0.dev12'
+__version__ = '2.5.2.dev1'

File _pytest/_argcomplete.py

         else:
             prefix_dir = 0
         completion = []
+        globbed = []
         if '*' not in prefix and '?' not in prefix:
+            if prefix[-1] == os.path.sep:  # we are on unix, otherwise no bash
+                globbed.extend(glob(prefix + '.*'))
             prefix += '*'
-        for x in sorted(glob(prefix)):
+        globbed.extend(glob(prefix))
+        for x in sorted(globbed):
             if os.path.isdir(x):
                 x += '/'
             # append stripping the prefix (like bash, not like compgen)

File _pytest/assertion/__init__.py

 """
 import py
 import sys
-import pytest
 from _pytest.monkeypatch import monkeypatch
 from _pytest.assertion import util
 
 to provide assert expression information. """)
     group.addoption('--no-assert', action="store_true", default=False,
         dest="noassert", help="DEPRECATED equivalent to --assert=plain")
-    group.addoption('--nomagic', '--no-magic', action="store_true", 
+    group.addoption('--nomagic', '--no-magic', action="store_true",
         default=False, help="DEPRECATED equivalent to --assert=plain")
 
 class AssertionState:
         mode = "plain"
     if mode == "rewrite":
         try:
-            import ast
+            import ast  # noqa
         except ImportError:
             mode = "reinterp"
         else:
         m = monkeypatch()
         config._cleanup.append(m.undo)
         m.setattr(py.builtin.builtins, 'AssertionError',
-                  reinterpret.AssertionError)
+                  reinterpret.AssertionError)  # noqa
     hook = None
     if mode == "rewrite":
-        hook = rewrite.AssertionRewritingHook()
+        hook = rewrite.AssertionRewritingHook()  # noqa
         sys.meta_path.insert(0, hook)
     warn_about_missing_assertion(mode)
     config._assertstate = AssertionState(config, mode)
 
         for new_expl in hook_result:
             if new_expl:
-                # Don't include pageloads of data unless we are very verbose (-vv)
-                if len(''.join(new_expl[1:])) > 80*8 and item.config.option.verbose < 2:
-                    new_expl[1:] = ['Detailed information truncated, use "-vv" to see']
-                res = '\n~'.join(new_expl)
+                # Don't include pageloads of data unless we are very
+                # verbose (-vv)
+                if (len(py.builtin._totext('').join(new_expl[1:])) > 80*8
+                        and item.config.option.verbose < 2):
+                    new_expl[1:] = [py.builtin._totext(
+                        'Detailed information truncated, use "-vv" to see')]
+                res = py.builtin._totext('\n~').join(new_expl)
                 if item.config.getvalue("assertmode") == "rewrite":
                     # The result will be fed back a python % formatting
                     # operation, which will fail if there are extraneous
 def _load_modules(mode):
     """Lazily import assertion related code."""
     global rewrite, reinterpret
-    from _pytest.assertion import reinterpret
+    from _pytest.assertion import reinterpret  # noqa
     if mode == "rewrite":
-        from _pytest.assertion import rewrite
+        from _pytest.assertion import rewrite  # noqa
 
 def warn_about_missing_assertion(mode):
     try:

File _pytest/assertion/reinterpret.py

 import sys
 import py
 from _pytest.assertion.util import BuiltinAssertionError
+u = py.builtin._totext
+
 
 class AssertionError(BuiltinAssertionError):
     def __init__(self, *args):
         BuiltinAssertionError.__init__(self, *args)
         if args:
+            # on Python2.6 we get len(args)==2 for: assert 0, (x,y)
+            # on Python2.7 and above we always get len(args) == 1
+            # with args[0] being the (x,y) tuple.
+            if len(args) > 1:
+                toprint = args
+            else:
+                toprint = args[0]
             try:
-                self.msg = str(args[0])
-            except py.builtin._sysex:
-                raise
-            except:
-                self.msg = "<[broken __repr__] %s at %0xd>" %(
-                    args[0].__class__, id(args[0]))
+                self.msg = u(toprint)
+            except Exception:
+                self.msg = u(
+                    "<[broken __repr__] %s at %0xd>"
+                    % (toprint.__class__, id(toprint)))
         else:
             f = py.code.Frame(sys._getframe(1))
             try:

File _pytest/assertion/rewrite.py

 from _pytest.assertion import util
 
 
-# py.test caches rewritten pycs in __pycache__.
+# pytest caches rewritten pycs in __pycache__.
 if hasattr(imp, "get_tag"):
     PYTEST_TAG = imp.get_tag() + "-PYTEST"
 else:
     def __init__(self):
         self.session = None
         self.modules = {}
+        self._register_with_pkg_resources()
 
     def set_session(self, session):
         self.fnpats = session.config.getini("python_files")
         names = name.rsplit(".", 1)
         lastname = names[-1]
         pth = None
-        if path is not None and len(path) == 1:
-            pth = path[0]
+        if path is not None:
+            # Starting with Python 3.3, path is a _NamespacePath(), which
+            # causes problems if not converted to list.
+            path = list(path)
+            if len(path) == 1:
+                pth = path[0]
         if pth is None:
             try:
                 fd, fn, desc = imp.find_module(lastname, path)
         # the most magical part of the process: load the source, rewrite the
         # asserts, and load the rewritten source. We also cache the rewritten
         # module code in a special pyc. We must be aware of the possibility of
-        # concurrent py.test processes rewriting and loading pycs. To avoid
+        # concurrent pytest processes rewriting and loading pycs. To avoid
         # tricky race conditions, we maintain the following invariant: The
         # cached pyc is always a complete, valid pyc. Operations on it must be
         # atomic. POSIX's atomic rename comes in handy.
         tp = desc[2]
         return tp == imp.PKG_DIRECTORY
 
+    @classmethod
+    def _register_with_pkg_resources(cls):
+        """
+        Ensure package resources can be loaded from this loader. May be called
+        multiple times, as the operation is idempotent.
+        """
+        try:
+            import pkg_resources
+            # access an attribute in case a deferred importer is present
+            pkg_resources.__name__
+        except ImportError:
+            return
+
+        # Since pytest tests are always located in the file system, the
+        #  DefaultProvider is appropriate.
+        pkg_resources.register_loader_type(cls, pkg_resources.DefaultProvider)
+
+
 def _write_pyc(state, co, source_path, pyc):
     # Technically, we don't have to have the same pyc format as
     # (C)Python, since these "pycs" should never be seen by builtin
 RN = "\r\n".encode("utf-8")
 N = "\n".encode("utf-8")
 
-cookie_re = re.compile("coding[:=]\s*[-\w.]+")
+cookie_re = re.compile(r"^[ \t\f]*#.*coding[:=][ \t]*[-\w.]+")
 BOM_UTF8 = '\xef\xbb\xbf'
 
 def _rewrite_test(state, fn):
         end1 = source.find("\n")
         end2 = source.find("\n", end1 + 1)
         if (not source.startswith(BOM_UTF8) and
-            (not cookie_re.match(source[0:end1]) or
-            not cookie_re.match(source[end1:end2]))):
+            cookie_re.match(source[0:end1]) is None and
+            cookie_re.match(source[end1 + 1:end2]) is None):
             if hasattr(state, "_indecode"):
                 return None  # encodings imported us again, we don't rewrite
             state._indecode = True
             os.rename(proc_pyc, pyc)
 
 def _read_pyc(source, pyc):
-    """Possibly read a py.test pyc containing rewritten code.
+    """Possibly read a pytest pyc containing rewritten code.
 
     Return rewritten code if successful or None if not.
     """
 
 
 _saferepr = py.io.saferepr
-from _pytest.assertion.util import format_explanation as _format_explanation
+from _pytest.assertion.util import format_explanation as _format_explanation # noqa
 
 def _should_repr_global_name(obj):
     return not hasattr(obj, "__name__") and not py.builtin.callable(obj)
         for i, v in enumerate(boolop.values):
             if i:
                 fail_inner = []
-                self.on_failure.append(ast.If(cond, fail_inner, []))
+                # cond is set in a prior loop iteration below
+                self.on_failure.append(ast.If(cond, fail_inner, [])) # noqa
                 self.on_failure = fail_inner
             self.push_format_context()
             res, expl = self.visit(v)
             res_expr = ast.Compare(left_res, [op], [next_res])
             self.statements.append(ast.Assign([store_names[i]], res_expr))
             left_res, left_expl = next_res, next_expl
-        # Use py.code._reprcompare if that's available.
+        # Use pytest.assertion.util._reprcompare if that's available.
         expl_call = self.helper("call_reprcompare",
                                 ast.Tuple(syms, ast.Load()),
                                 ast.Tuple(load_names, ast.Load()),

File _pytest/assertion/util.py

 
 import py
 try:
-    from collections.abc import Sequence
+    from collections import Sequence
 except ImportError:
-    try:
-        from collections import Sequence
-    except ImportError:
-        Sequence = list
-
+    Sequence = list
 
 BuiltinAssertionError = py.builtin.builtins.AssertionError
+u = py.builtin._totext
 
 # The _reprcompare attribute on the util module is used by the new assertion
 # interpretation code and assertion rewriter to detect this plugin was
     for when one explanation needs to span multiple lines, e.g. when
     displaying diffs.
     """
-    # simplify 'assert False where False = ...'
+    explanation = _collapse_false(explanation)
+    lines = _split_explanation(explanation)
+    result = _format_lines(lines)
+    return u('\n').join(result)
+
+
+def _collapse_false(explanation):
+    """Collapse expansions of False
+
+    So this strips out any "assert False\n{where False = ...\n}"
+    blocks.
+    """
     where = 0
     while True:
         start = where = explanation.find("False\n{False = ", where)
             explanation = (explanation[:start] + explanation[start+15:end-1] +
                            explanation[end+1:])
             where -= 17
-    raw_lines = (explanation or '').split('\n')
-    # escape newlines not followed by {, } and ~
+    return explanation
+
+
+def _split_explanation(explanation):
+    """Return a list of individual lines in the explanation
+
+    This will return a list of lines split on '\n{', '\n}' and '\n~'.
+    Any other newlines will be escaped and appear in the line as the
+    literal '\n' characters.
+    """
+    raw_lines = (explanation or u('')).split('\n')
     lines = [raw_lines[0]]
     for l in raw_lines[1:]:
         if l.startswith('{') or l.startswith('}') or l.startswith('~'):
             lines.append(l)
         else:
             lines[-1] += '\\n' + l
+    return lines
 
+
+def _format_lines(lines):
+    """Format the individual lines
+
+    This will replace the '{', '}' and '~' characters of our mini
+    formatting language with the proper 'where ...', 'and ...' and ' +
+    ...' text, taking care of indentation along the way.
+
+    Return a list of formatted lines.
+    """
     result = lines[:1]
     stack = [0]
     stackcnt = [0]
     for line in lines[1:]:
         if line.startswith('{'):
             if stackcnt[-1]:
-                s = 'and   '
+                s = u('and   ')
             else:
-                s = 'where '
+                s = u('where ')
             stack.append(len(result))
             stackcnt[-1] += 1
             stackcnt.append(0)
-            result.append(' +' + '  '*(len(stack)-1) + s + line[1:])
+            result.append(u(' +') + u('  ')*(len(stack)-1) + s + line[1:])
         elif line.startswith('}'):
             assert line.startswith('}')
             stack.pop()
             result[stack[-1]] += line[1:]
         else:
             assert line.startswith('~')
-            result.append('  '*len(stack) + line[1:])
+            result.append(u('  ')*len(stack) + line[1:])
     assert len(stack) == 1
-    return '\n'.join(result)
+    return result
 
 
 # Provide basestring in python3
     width = 80 - 15 - len(op) - 2  # 15 chars indentation, 1 space around op
     left_repr = py.io.saferepr(left, maxsize=int(width/2))
     right_repr = py.io.saferepr(right, maxsize=width-len(left_repr))
-    summary = '%s %s %s' % (left_repr, op, right_repr)
+    summary = u('%s %s %s') % (left_repr, op, right_repr)
 
     issequence = lambda x: (isinstance(x, (list, tuple, Sequence))
                             and not isinstance(x, basestring))
         elif op == 'not in':
             if istext(left) and istext(right):
                 explanation = _notin_text(left, right, verbose)
-    except py.builtin._sysex:
-        raise
-    except:
+    except Exception:
         excinfo = py.code.ExceptionInfo()
         explanation = [
-            '(pytest_assertion plugin: representation of details failed.  '
-            'Probably an object has a faulty __repr__.)', str(excinfo)]
+            u('(pytest_assertion plugin: representation of details failed.  '
+              'Probably an object has a faulty __repr__.)'),
+            u(excinfo)]
 
     if not explanation:
         return None
                 break
         if i > 42:
             i -= 10                 # Provide some context
-            explanation = ['Skipping %s identical leading '
-                           'characters in diff, use -v to show' % i]
+            explanation = [u('Skipping %s identical leading '
+                             'characters in diff, use -v to show') % i]
             left = left[i:]
             right = right[i:]
         if len(left) == len(right):
                     break
             if i > 42:
                 i -= 10     # Provide some context
-                explanation += ['Skipping %s identical trailing '
-                                'characters in diff, use -v to show' % i]
+                explanation += [u('Skipping %s identical trailing '
+                                  'characters in diff, use -v to show') % i]
                 left = left[:-i]
                 right = right[:-i]
     explanation += [line.strip('\n')
     explanation = []
     for i in range(min(len(left), len(right))):
         if left[i] != right[i]:
-            explanation += ['At index %s diff: %r != %r' %
-                            (i, left[i], right[i])]
+            explanation += [u('At index %s diff: %r != %r')
+                            % (i, left[i], right[i])]
             break
     if len(left) > len(right):
-        explanation += [
-            'Left contains more items, first extra item: %s' %
-            py.io.saferepr(left[len(right)],)]
+        explanation += [u('Left contains more items, first extra item: %s')
+                        % py.io.saferepr(left[len(right)],)]
     elif len(left) < len(right):
         explanation += [
-            'Right contains more items, first extra item: %s' %
+            u('Right contains more items, first extra item: %s') %
             py.io.saferepr(right[len(left)],)]
     return explanation  # + _diff_text(py.std.pprint.pformat(left),
                         #             py.std.pprint.pformat(right))
     diff_left = left - right
     diff_right = right - left
     if diff_left:
-        explanation.append('Extra items in the left set:')
+        explanation.append(u('Extra items in the left set:'))
         for item in diff_left:
             explanation.append(py.io.saferepr(item))
     if diff_right:
-        explanation.append('Extra items in the right set:')
+        explanation.append(u('Extra items in the right set:'))
         for item in diff_right:
             explanation.append(py.io.saferepr(item))
     return explanation
     common = set(left).intersection(set(right))
     same = dict((k, left[k]) for k in common if left[k] == right[k])
     if same and not verbose:
-        explanation += ['Omitting %s identical items, use -v to show' %
+        explanation += [u('Omitting %s identical items, use -v to show') %
                         len(same)]
     elif same:
-        explanation += ['Common items:']
+        explanation += [u('Common items:')]
         explanation += py.std.pprint.pformat(same).splitlines()
     diff = set(k for k in common if left[k] != right[k])
     if diff:
-        explanation += ['Differing items:']
+        explanation += [u('Differing items:')]
         for k in diff:
             explanation += [py.io.saferepr({k: left[k]}) + ' != ' +
                             py.io.saferepr({k: right[k]})]
     extra_left = set(left) - set(right)
     if extra_left:
-        explanation.append('Left contains more items:')
+        explanation.append(u('Left contains more items:'))
         explanation.extend(py.std.pprint.pformat(
             dict((k, left[k]) for k in extra_left)).splitlines())
     extra_right = set(right) - set(left)
     if extra_right:
-        explanation.append('Right contains more items:')
+        explanation.append(u('Right contains more items:'))
         explanation.extend(py.std.pprint.pformat(
             dict((k, right[k]) for k in extra_right)).splitlines())
     return explanation
     tail = text[index+len(term):]
     correct_text = head + tail
     diff = _diff_text(correct_text, text, verbose)
-    newdiff = ['%s is contained here:' % py.io.saferepr(term, maxsize=42)]
+    newdiff = [u('%s is contained here:') % py.io.saferepr(term, maxsize=42)]
     for line in diff:
-        if line.startswith('Skipping'):
+        if line.startswith(u('Skipping')):
             continue
-        if line.startswith('- '):
+        if line.startswith(u('- ')):
             continue
-        if line.startswith('+ '):
-            newdiff.append('  ' + line[2:])
+        if line.startswith(u('+ ')):
+            newdiff.append(u('  ') + line[2:])
         else:
             newdiff.append(line)
     return newdiff

File _pytest/capture.py

-""" per-test stdout/stderr capturing mechanisms, ``capsys`` and ``capfd`` function arguments.  """
+"""
+    per-test stdout/stderr capturing mechanisms,
+    ``capsys`` and ``capfd`` function arguments.
+"""
+# note: py.io capture was where copied from
+# pylib 1.4.20.dev2 (rev 13d9af95547e)
+import sys
+import os
+import tempfile
 
-import pytest, py
-import os
+import py
+import pytest
+
+try:
+    from io import StringIO
+except ImportError:
+    from StringIO import StringIO
+
+try:
+    from io import BytesIO
+except ImportError:
+    class BytesIO(StringIO):
+        def write(self, data):
+            if isinstance(data, unicode):
+                raise TypeError("not a byte value: %r" % (data,))
+            StringIO.write(self, data)
+
+if sys.version_info < (3, 0):
+    class TextIO(StringIO):
+        def write(self, data):
+            if not isinstance(data, unicode):
+                enc = getattr(self, '_encoding', 'UTF-8')
+                data = unicode(data, enc, 'replace')
+            StringIO.write(self, data)
+else:
+    TextIO = StringIO
+
+
+patchsysdict = {0: 'stdin', 1: 'stdout', 2: 'stderr'}
+
 
 def pytest_addoption(parser):
     group = parser.getgroup("general")
-    group._addoption('--capture', action="store", default=None,
+    group._addoption(
+        '--capture', action="store", default=None,
         metavar="method", choices=['fd', 'sys', 'no'],
         help="per-test capturing method: one of fd (default)|sys|no.")
-    group._addoption('-s', action="store_const", const="no", dest="capture",
+    group._addoption(
+        '-s', action="store_const", const="no", dest="capture",
         help="shortcut for --capture=no.")
 
+
 @pytest.mark.tryfirst
-def pytest_cmdline_parse(pluginmanager, args):
-    # we want to perform capturing already for plugin/conftest loading
-    if '-s' in args or "--capture=no" in args:
-        method = "no"
-    elif hasattr(os, 'dup') and '--capture=sys' not in args:
+def pytest_load_initial_conftests(early_config, parser, args, __multicall__):
+    ns = parser.parse_known_args(args)
+    method = ns.capture
+    if not method:
         method = "fd"
-    else:
+    if method == "fd" and not hasattr(os, "dup"):
         method = "sys"
     capman = CaptureManager(method)
-    pluginmanager.register(capman, "capturemanager")
+    early_config.pluginmanager.register(capman, "capturemanager")
+
+    # make sure that capturemanager is properly reset at final shutdown
+    def teardown():
+        try:
+            capman.reset_capturings()
+        except ValueError:
+            pass
+
+    early_config.pluginmanager.add_shutdown(teardown)
+
+    # make sure logging does not raise exceptions at the end
+    def silence_logging_at_shutdown():
+        if "logging" in sys.modules:
+            sys.modules["logging"].raiseExceptions = False
+    early_config.pluginmanager.add_shutdown(silence_logging_at_shutdown)
+
+    # finally trigger conftest loading but while capturing (issue93)
+    capman.resumecapture()
+    try:
+        try:
+            return __multicall__.execute()
+        finally:
+            out, err = capman.suspendcapture()
+    except:
+        sys.stdout.write(out)
+        sys.stderr.write(err)
+        raise
+
 
 def addouterr(rep, outerr):
     for secname, content in zip(["out", "err"], outerr):
         if content:
             rep.sections.append(("Captured std%s" % secname, content))
 
+
 class NoCapture:
     def startall(self):
         pass
+
     def resume(self):
         pass
+
     def reset(self):
         pass
+
     def suspend(self):
         return "", ""
 
+
 class CaptureManager:
     def __init__(self, defaultmethod=None):
         self._method2capture = {}
 
     def _maketempfile(self):
         f = py.std.tempfile.TemporaryFile()
-        newf = py.io.dupfile(f, encoding="UTF-8")
+        newf = dupfile(f, encoding="UTF-8")
         f.close()
         return newf
 
     def _makestringio(self):