let's move all this big string to files with resources.
you could have a CSV which can be load as fixture in the conftests. Or a JSON. Or anything that will be simple enough to maintain and that helps you to remove clutter out of the code.
Originally posted by @Edilmo in #68 (comment)
Proposed Solution
- Create a json file containing large texts that will be used to test different scrapers, ie
test_scraper_constants.json
{
"el-pitazo": {
"get-body-parse-ok": "super long text"
}
}
- Create a
conftest.py with the following contents
import pytest
@pytest.fixture
def get_body_for_parse_ok():
filename = "../../resources/tests/scraper/test_scraper_constants.json" # should be relative to repo's root
text_of_interest = _get_json_from_file['el-pitazo']['get-body-parse-ok']
return text_of_interest
- Use the fixture on the test file, ie:
test_some_name.py
def test_parse_ok(get_body_for_parse_ok):
conftest.py can be placed inside the folder where all tests needing to access such long text live.
let's move all this big string to files with resources.
you could have a CSV which can be load as fixture in the conftests. Or a JSON. Or anything that will be simple enough to maintain and that helps you to remove clutter out of the code.
Originally posted by @Edilmo in #68 (comment)
Proposed Solution
test_scraper_constants.json{ "el-pitazo": { "get-body-parse-ok": "super long text" } }conftest.pywith the following contentstest_some_name.pyconftest.pycan be placed inside the folder where all tests needing to access such long text live.