MCPcopy Create free account
hub / github.com/bleachbit/bleachbit / setUpClass

Method setUpClass

tests/TestNetwork.py:65–85  ·  view source on GitHub ↗
(cls)

Source from the content-addressed store, hash-verified

63
64 @classmethod
65 def setUpClass(cls):
66 super(NetworkTestCase, cls).setUpClass()
67 status_generators = list(cls.status_generators)
68 random.shuffle(status_generators)
69 for generator in status_generators:
70 url = generator.format(200)
71 try:
72 response = fetch_url(url, timeout=5, max_retries=0)
73 if response.status_code == 200:
74 cls.status_generator_url = generator
75 logger.info('Using status generator: %s',
76 cls.status_generator_url)
77 return
78 else:
79 logger.warning('Status generator %s returned %s',
80 generator, response.status_code)
81 except requests.exceptions.RequestException as e:
82 logger.warning('Status generator failed: %s (%s)',
83 generator.format('...'), e)
84 if not cls.status_generator_url:
85 raise RuntimeError('No working HTTP status code generator found.')
86
87 def setUp(self):
88 """Set up the test environment before each test method."""

Callers

nothing calls this directly

Calls 1

fetch_urlFunction · 0.90

Tested by

no test coverage detected