2017-09-07 18 views
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_ 접두어를 붙이면 해결 방법을 찾았습니다.

조명기를 함수와 동일한 파일에 유지하려면 어떻게하면 좋을까요?

  1. 모든 설비 앞에 _을 붙이시겠습니까?
  2. 사용 안함 pylint 테스트를 확인 하시겠습니까?
  3. 더 나은 제안이 있습니까?

답변

0

대개 비활성화됩니다 (1, 2).

일부 문제를 해결하기 위해 시도한 pylint-pytest 플러그인이 있습니다. 그러나 오류 W0621은 아직 해결되지 않았으며 플러그인은 포기 된 것 같습니다 (마지막 업데이트는 2013 년).