-
Notifications
You must be signed in to change notification settings - Fork 13
/
conftest.py
43 lines (34 loc) · 1.11 KB
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import pytest
import tempfile
from PIL import Image
from django.core.files import File as DjangoFile
# Include the various pytest fixtures from all of our Django apps tests
# directories
pytest_plugins = [
"core.tests.fixtures",
"libraries.tests.fixtures",
"news.tests.fixtures",
"users.tests.fixtures",
"versions.tests.fixtures",
]
@pytest.fixture
def temp_image_file():
image = Image.new("RGB", (100, 100))
tmp_file = tempfile.NamedTemporaryFile(suffix=".jpg")
image.save(tmp_file)
tmp_file.seek(0)
file_obj = DjangoFile(open(tmp_file.name, mode="rb"), name="tmp_file")
yield file_obj.seek(0)
def pytest_collection_modifyitems(config, items):
"""
Adds support for skipping tests based on the presence of markers:
- asciidoctor
"""
keywordexpr = config.option.keyword
markexpr = config.option.markexpr
if keywordexpr or markexpr:
return # let pytest handle this
skip_asciidoctor = pytest.mark.skip(reason="asciidoctor not selected")
for item in items:
if "asciidoctor" in item.keywords:
item.add_marker(skip_asciidoctor)