Skip to content

staticmethod functions are not collected for testing #2528

@waisbrot

Description

@waisbrot

When using classes to group functions, I'm interested in this pattern:

"test_http_requests.py"

class TestGet:
  @staticmethod
  def test_simple_get():
    pass

  @staticmethod
  def test_query_string():
    pass

class TestPut:
  @staticmethod
  def test_no_data():
     pass

  @staticmethod
  def test_binary_data():
    pass

Using the @staticmethod decorator makes it clear that I'm not using the class for anything but grouping.

Unfortunately, pytest fails to collect any method so decorated. If I remove the decorator and add the self argument in the above example, pytest collects as expected.

Pytest 3.1.2, Python 2.7.13, no virtualenv, MacOS 10.12.5

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