Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move big string resources folder #73

Open
marianelamin opened this issue May 2, 2021 · 0 comments
Open

Move big string resources folder #73

marianelamin opened this issue May 2, 2021 · 0 comments
Assignees

Comments

@marianelamin
Copy link
Collaborator

marianelamin commented May 2, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants