Skip to content

Commit

Permalink
lint: fix override outer scope
Browse files Browse the repository at this point in the history
  • Loading branch information
tklockau committed Oct 28, 2024
1 parent 6cff4ef commit 8c82d85
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
26 changes: 13 additions & 13 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@

@pytest.fixture
def json_paths(request) -> t.Dict[str, Path]:
json_paths = _fetch_json_paths_from_cache(request)
out = _fetch_json_paths_from_cache(request)

if json_paths is None:
json_paths = {_get_file_identifier(p): p for p in _collect_json_paths()}
if out is None:
out = {_get_file_identifier(p): p for p in _collect_json_paths()}

return json_paths
return out

def _fetch_json_paths_from_cache(request) -> t.Optional[t.Dict[str, Path]]:
return request.config.cache.get("json_paths", None)

def _collect_json_paths() -> t.List[Path]:
json_paths = []
out = []

for dir in json_data_directories:
json_paths.extend([Path(p) for p in glob.glob(str(dir) + "/**/**.json", recursive=True)])
out.extend([Path(p) for p in glob.glob(str(dir) + "/**/**.json", recursive=True)])

return json_paths
return out

def _get_file_identifier(path: Path) -> str:
"""Return relative path from test asset dir as string."""
Expand All @@ -52,20 +52,20 @@ def _get_file_identifier(path: Path) -> str:

@pytest.fixture
def json_data(request) -> t.Dict[str, dict]:
json_data = _fetch_json_data_from_cache(request)
out = _fetch_json_data_from_cache(request)

if json_data is None:
json_data = {_get_file_identifier(p): _load_json_data(p) for p in _collect_json_paths()}
if out is None:
out = {_get_file_identifier(p): _load_json_data(p) for p in _collect_json_paths()}

return json_data
return out

def _fetch_json_data_from_cache(request) -> t.Optional[t.Dict[str, Path]]:
return request.config.cache.get("json_data", None)

def _load_json_data(path: Path) -> dict:
with path.open() as f:
json_data = json.load(f)
return json_data
out = json.load(f)
return out

@pytest.fixture
def empty_scene() -> raillabel.Scene:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
from raillabel_providerkit.convert.loader_classes.loader_understand_ai import LoaderUnderstandAi


def test_supports_true(json_data):
assert LoaderUnderstandAi().supports(json_data["understand_ai_real_life"])
def test_supports_true(json_data):
def test_supports__true(json_data):
assert LoaderUnderstandAi().supports(json_data["understand_ai_real_life"])


def test_supports_false(json_data):
def test_supports__false(json_data):
data = json_data["understand_ai_real_life"]
del data["metadata"]["project_id"]
assert not LoaderUnderstandAi().supports(data)
Expand All @@ -31,6 +29,6 @@ def test_validate_schema__real_life_file__errors(json_data):
assert len(actual) == 1
assert "topic" in actual[0]


if __name__ == "__main__":
pytest.main([__file__, "--disable-pytest-warnings", "--cache-clear"])

0 comments on commit 8c82d85

Please sign in to comment.