示例工程 29-testing-pytest
29-testing-pytest/01-fixture-scopes/fixture_scopes.py
"""演示 fixture 作用域用到的资源对象。"""
from __future__ import annotations
class Resource:
opens = 0
def __init__(self) -> None:
Resource.opens += 1
def main() -> None:
Resource.opens = 0
first = Resource()
second = Resource()
print(f"created: {Resource.opens}")
print(f"distinct: {first is not second}")
print("scopes: see test_fixture_scopes.py")
if __name__ == "__main__":
main()