Coverage expects a test case for an @abstractmethod

38 Views Asked by At

As you can see in the picture below, coverage wants me to write a test case for the method inside the abc. But I dont know how to do it, I mean as far as I can see there is nothing to test.

enter image description here

Code:

from abc import ABC, abstractmethod


class BaseVPS(ABC):
    @abstractmethod
    def create_server(self):
        ...
1

There are 1 best solutions below

0
John Smith On BEST ANSWER

Since testing something like an @abstractmethod is unnecessary, we can add this configuration file to the root of our project to add exclusions to the coverage.

pyproject.toml:

[tool.coverage.report]
exclude_also = [
    "@(abc\\.)?abstractmethod",
    ]