Skip to content

Instantly share code, notes, and snippets.

@disconnect3d
Created September 4, 2017 13:29
Show Gist options
  • Save disconnect3d/4bfadf3cb43d043de0707f9463c169d1 to your computer and use it in GitHub Desktop.
Save disconnect3d/4bfadf3cb43d043de0707f9463c169d1 to your computer and use it in GitHub Desktop.
Is this the best way to return list like thing?
@pytest.fixture
def mock_time_in_ms(monkeypatch):
def _mock_time_in_ms(values_to_return):
idx = [0]
def _time():
v = values_to_return[idx[0]]
idx[0] += 1
return v
monkeypatch.setattr(some_module_that_uses_time_in_ms, 'time_in_ms', _time)
return _mock_time_in_ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment