% 100 pytest kod kalıbı gibi görünüyor
görmek:
https://docs.pytest.org/en/latest/fixture.html#conftest-py-sharing-fixture-functions
Ben de aynı sorunu vardı, bu yüzden bu yazı bulundu;)
# ./tests/test_twitter1.py
import os
import pytest
from mylib import db
# ...
@pytest.fixture
def twitter():
twitter_ = db.Twitter()
twitter_._debug = True
return twitter_
@pytest.mark.parametrize("query,expected", [
("BANCO PROVINCIAL", 8),
("name", 6),
("castlabs", 42),
])
def test_search(twitter: db.Twitter, query: str, expected: int):
for query in queries:
res = twitter.search(query)
print(res)
assert res
Ve uyarır This inspection detects shadowing names defined in outer scopes.
Bunu düzeltmek için twitter
fikstürünüzü./tests/conftest.py
# ./tests/conftest.py
import pytest
from syntropy import db
@pytest.fixture
def twitter():
twitter_ = db.Twitter()
twitter_._debug = True
return twitter_
Ve twitter
fikstürü./tests/test_twitter2.py
# ./tests/test_twitter2.py
import os
import pytest
from mylib import db
# ...
@pytest.mark.parametrize("query,expected", [
("BANCO PROVINCIAL", 8),
("name", 6),
("castlabs", 42),
])
def test_search(twitter: db.Twitter, query: str, expected: int):
for query in queries:
res = twitter.search(query)
print(res)
assert res
Bu mutlu QA, Pycharm ve herkesi mutlu edecek