Skip to content

Instantly share code, notes, and snippets.

@jieniu
Last active January 26, 2019 08:08
Show Gist options
  • Save jieniu/b8e8ac48871e8eec54df89a1e66c690f to your computer and use it in GitHub Desktop.
Save jieniu/b8e8ac48871e8eec54df89a1e66c690f to your computer and use it in GitHub Desktop.
python gist
# mock side_effect
>>> iter_mock = mock.Mock(side_effect=[1, 2, 3])
>>> iter_mock()
1
>>> iter_mock()
2
>>> iter_mock()
3
# n days ago
from datetime import datetime, timedelta
date_N_days_ago = datetime.today() - timedelta(days=1)
str = date_N_days_ago.strftime('%Y%m%d')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment