Skip to content

Move big string resources folder #73

@marianelamin

Description

@marianelamin

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

  1. 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"
        }
    }
  2. 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
  3. 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.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions