Pytest:为函数指定多种命名约定



我想测试类中的函数,但由于某些原因,我无法将它们命名为test_*。我的课是这样的:

class SegmentationSuite:
"""Benchmark for segmentation routines in scikit-image."""
def setup(self):
self.image = np.random.random((400, 400, 100))
self.image[:200, :200, :] += 1
self.image[300:, 300:, :] += 0.5
def time_slic_basic(self):
segmentation.slic(self.image, enforce_connectivity=False)
def peakmem_setup(self):
pass
def peakmem_slic_basic(self):
segmentation.slic(self.image, enforce_connectivity=False)

因此,有三组函数:time_*setuppeakmem。在查看pytest文档后,我发现https://docs.pytest.org/en/latest/example/pythoncollection.html#changing-命名约定

因此,我创建了一个setup.cfg文件,并添加了以下内容:

[tool:pytest]
python_files=benchmark_*.py
python_classes=*Suite
python_functions=time_*, setup, peakmem*

但它不起作用。

我该怎么做?

谢谢。

我就是这样做的python_functions=time_* setup peakmem*。指定用空格分隔的多个glob图案。