File: _trio_check_attrs_aliases.py

package info (click to toggle)
python-trio 0.29.0-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 2,920 kB
  • sloc: python: 28,766; sh: 144; makefile: 25
file content (22 lines) | stat: -rw-r--r-- 554 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
"""Plugins are executed by Pytest before test modules.

We use this to monkeypatch attrs.field(), so that we can detect if aliases are used for test_exports.
"""

from typing import Any

import attrs

orig_field = attrs.field


def field(**kwargs: Any) -> Any:
    original_args = kwargs.copy()
    metadata = kwargs.setdefault("metadata", {})
    metadata["trio_original_args"] = original_args
    return orig_field(**kwargs)


# Mark it as being ours, so the test knows it can actually run.
field.trio_modded = True  # type: ignore
attrs.field = field