import json from urllib.parse import urlparse from urllib.request import urlopen from pathlib import Path import pytest json_url = "https://raw.githubusercontent.com/norweeg/portable-computing-toolkit-installer/initial_dev/portable_computing_toolkit_installer/resources/supported_tools.json" class TestJSON(object): def test_json_url_valid(self): global json_url parsed = urlparse(json_url) assert len(parsed) == 6 assert Path(parsed.path).suffix == ".json" def test_json_accessible(self): global json_url json_file = urlopen(json_url) assert json_file.code < 400 json_file.close() def test_json_valid(self): global json_url with urlopen(json_url) as json_file: json_data = json.load(json_file) assert json_data