1
나는 pytest를 배우고 있으며, 필 린트로 코드를 보았습니다. pytest에서 다음과 같은 예를 들어
W0621: Redefining name %r from outer scope (line %s)
pytest fixtures 바깥 쪽 범위에서 이름 재정의 [pylint]
: 약 그러나 pylint 여전히 불만
# test_wallet.py
@pytest.fixture
def my_wallet():
'''Returns a Wallet instance with a zero balance'''
return Wallet()
@pytest.mark.parametrize("earned,spent,expected", [
(30, 10, 20),
(20, 2, 18),
])
def test_transactions(my_wallet, earned, spent, expected):
my_wallet.add_cash(earned)
my_wallet.spend_cash(spent)
assert my_wallet.balance == expected
외부 범위 이름 my_wallet
재정의.
_my_wallet
에 _
접두어를 붙이면 해결 방법을 찾았습니다.
조명기를 함수와 동일한 파일에 유지하려면 어떻게하면 좋을까요?
- 모든 설비 앞에
_
을 붙이시겠습니까? - 사용 안함
pylint
테스트를 확인 하시겠습니까? - 더 나은 제안이 있습니까?