Skip to content

Python properties on test classes are executed during test collection #2234

Closed
@bluetech

Description

@bluetech
  • Include a detailed description of the bug or suggestion

A test suite with a test file such as the following fails during test collection:

class TestIt:
    @property
    def prop(self):
        raise NotImplementedError()

I expect the property (or other types of custom descriptors) to not be executed during collection.

For comparison, unittest, from which I am migrating, does not execute properties (unless the tests use them of course).

  • pip list of the virtual environment you are using
Package    Version
---------- -------
pip        9.0.1  
py         1.4.32 
pytest     3.0.6  
setuptools 28.8.0 
  • pytest and operating system versions
$ uname -a
Linux 4.9.6-1-ARCH #1 SMP PREEMPT Thu Jan 26 09:22:26 CET 2017 x86_64 GNU/Linux
$ python --version
Python 3.6.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions