File: conftest.py

package info (click to toggle)
python-emoji 2.14.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,664 kB
  • sloc: python: 3,120; javascript: 262; makefile: 14
file content (31 lines) | stat: -rw-r--r-- 804 bytes parent folder | download
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
from typing import List
import random
import functools

import pytest


def pytest_sessionstart():
    # Increase cache size to unlimited size to avoid cache misses during tests
    import emoji.unicode_codes

    emoji.unicode_codes.get_emoji_by_name = functools.lru_cache(maxsize=None)(
        emoji.unicode_codes.get_emoji_by_name.__wrapped__
    )


def pytest_addoption(parser: pytest.Parser):
    parser.addoption(
        '--shuffle',
        dest='shuffle',
        action='store_true',
        default=False,
        help='Run tests in random order',
    )


def pytest_collection_modifyitems(session: pytest.Session, items: List[pytest.Item]):
    if session.config.getoption('shuffle'):
        print('')
        print('Shuffling items for a random test order')
        random.shuffle(items)