<aside>
</aside>
@pytest.fixture
๋ฐ์ฝ๋ ์ดํฐ ์ฌ์ฉ ๊ฐ๋จํ ํฝ์ค์ฒ ํจ์ ์ ์ํ๋ก์ ํธ ๊ตฌ์กฐ (๋ณ๊ฒฝ ์ฌํญ ๋ฐ์):
graph TD
A(my-pytest-project) --> B(.venv);
A --> C(mycalc);
A --> D(tests);
C --> C1(__init__.py);
C --> C2(calculator.py mycalc.py ๋์ ์ฌ์ฉ);
C --> C3(operations.py ์ญ์ ๋๋ calculator.py๋ก ํตํฉ ๊ฐ์ );
D --> D1(__init__.py);
D --> D2(test_calculator.py ๊ธฐ์กด ํ
์คํธ ํ์ผ ๋ฆฌํฉํ ๋ง);
D --> D3(conftest.py ํฝ์ค์ฒ ๊ณต์ ์ฉ ์ ํ ์ฌํญ);
style B fill:#eee,stroke:#333,stroke-dasharray: 5 5;
style C fill:#ccf,stroke:#333;
style D fill:#cfc,stroke:#333;
style C2 fill:#cce,stroke:#333;
style C3 fill:#cce,stroke:#333;
style D2 fill:#cef,stroke:#333;
style D3 fill:#fec,stroke:#333;
(๊ธฐ์กด mycalc.py
, operations.py
, test_mycalc.py
, test_operations.py
๋ calculator.py
, test_calculator.py
๋ก ๋ฆฌํฉํ ๋ง ๊ฐ์ )
mycalc/calculator.py
(์๋ก์ด ํด๋์ค ๊ธฐ๋ฐ ์ฝ๋):tests/test_calculator.py
(ํฝ์ค์ฒ ์ฌ์ฉ ์ - ๋ฌธ์ ์ ):tests/test_calculator.py
(ํฝ์ค์ฒ ์ฌ์ฉ ํ - ๊ฐ์ ):tests/conftest.py
(์ ํ ์ฌํญ - ํฝ์ค์ฒ ๊ณต์ ์):calculator_instance
ํฝ์ค์ฒ๋ฅผ ๋ค๋ฅธ ํ
์คํธ ํ์ผ๊ณผ ๊ณต์ ์, tests/conftest.py
์ ์ ์.(conftest.py
์ ์ ์ ์, ๋ค๋ฅธ ํ์ผ์์ import ์์ด ํด๋น ํฝ์ค์ฒ ์ฌ์ฉ ๊ฐ๋ฅ)