text: 
  
  TITLE
  [testing] making network tests more reliable
  
  COMMENTS
  24
  
  REACTIONS
  +1: 0
  -1: 0
  laugh: 0
  hooray: 0
  heart: 0
  rocket: 0
  eyes: 0
  
  BODY
  We have a group of tests that require a reliable network, which is never 100% so they fail for many months.
  
  I propose that those tests will be rewritten with unstable network in mind and include:
  
  1. `time.sleep(3)`
  2. retry 3-5 times
  
  e.g. one of the candidates is:
  
  `tests/test_hf_api.py::HfApiEndpointsTest::test_list_repos_objs`
  
  but also recent tests that push to hub.
  
  Perhaps a simple retry context manager can be added to `testing_utils.py`, which would trap exceptions and retry after a pause. And then simply wrap the content of existing tests into that context manager, e.g.:
  
  ```
  with RetryAfterSleepTest():
      # normal test code
  ```
  
  it could accept the number of retries and sleep time between retries for optional arguments.
  
  Of course, it's probably even better to make it also a decorator. e.g. `@unreliable_network_retry`
  
  @LysandreJik 