Download tasks/swe-next-4d4ba5eb3310787bdb56/environment/source/tests/conftest.py from FineEnvs/repo2rlenv-swe-next: direct link, hf CLI and curl.
- Browser
- Download file 1.57 kB
-
https://huggingface.co/datasets/FineEnvs/repo2rlenv-swe-next/resolve/main/tasks/swe-next-4d4ba5eb3310787bdb56/environment/source/tests/conftest.py
- Command line
-
hf download hf://datasets/FineEnvs/repo2rlenv-swe-next/tasks/swe-next-4d4ba5eb3310787bdb56/environment/source/tests/conftest.py
-
curl -L -o conftest.py https://huggingface.co/datasets/FineEnvs/repo2rlenv-swe-next/resolve/main/tasks/swe-next-4d4ba5eb3310787bdb56/environment/source/tests/conftest.py
1.57 kB
| """Helpers for testing.""" | |
| import io | |
| import os | |
| import pytest | |
| DIR_PATH = os.path.dirname(__file__) | |
| FILES_DIR = os.path.join(DIR_PATH, 'files') | |
| def filepath(): | |
| """Returns full file path for test files.""" | |
| def make_filepath(filename): | |
| # https://stackoverflow.com/questions/18011902/py-test-pass-a-parameter-to-a-fixture-function | |
| # Alternate solution is to use parametrization `indirect=True` | |
| # https://stackoverflow.com/questions/18011902/py-test-pass-a-parameter-to-a-fixture-function/33879151#33879151 | |
| # Syntax is noisy and requires specific variable names | |
| return os.path.join(FILES_DIR, filename) | |
| return make_filepath | |
| def load_file(filepath): | |
| """Opens filename with encoding and return its contents.""" | |
| def make_load_file(filename, encoding='utf-8'): | |
| # https://stackoverflow.com/questions/18011902/py-test-pass-a-parameter-to-a-fixture-function | |
| # Alternate solution is to use parametrization `indirect=True` | |
| # https://stackoverflow.com/questions/18011902/py-test-pass-a-parameter-to-a-fixture-function/33879151#33879151 | |
| # Syntax is noisy and requires specific variable names | |
| # And seems to be limited to only 1 argument. | |
| with open(filepath(filename), encoding=encoding) as f: | |
| return f.read().strip() | |
| return make_load_file | |
| def get_stream(filepath): | |
| def make_stream(filename, encoding='utf-8'): | |
| return open(filepath(filename), encoding=encoding) | |
| return make_stream | |