File: conftest.py

package info (click to toggle)
dataclass-wizard 0.39.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,112 kB
  • sloc: python: 19,560; makefile: 126; javascript: 23
file content (38 lines) | stat: -rw-r--r-- 789 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
32
33
34
35
36
37
38
"""
Common test fixtures and utilities.
"""
from dataclasses import dataclass
from uuid import UUID

import pytest


# Ref: https://docs.pytest.org/en/6.2.x/example/parametrize.html#parametrizing-conditional-raising
from contextlib import nullcontext as does_not_raise


@dataclass
class SampleClass:
    """Sample dataclass model for various test scenarios."""
    f1: str
    f2: int


class MyUUIDSubclass(UUID):
    """
    Simple UUID subclass that calls :meth:`hex` when ``str()`` is invoked.
    """

    def __str__(self):
        return self.hex


@pytest.fixture
def mock_log(caplog):
    caplog.set_level('INFO', logger='dataclass_wizard')
    return caplog

@pytest.fixture
def mock_debug_log(caplog):
    caplog.set_level('DEBUG', logger='dataclass_wizard')
    return caplog