This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import random | |
| import unittest | |
| from unittest.mock import patch | |
| class TryMockUsingContextManagerTest(unittest.TestCase): | |
| def test_mock_random_twice(self): | |
| with patch('__main__.random.randrange') as mock_randrange: | |
| with patch('__main__.random.randint') as mock_randint: | |
| try_mock_using_context_manager() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from contextlib import ExitStack | |
| import random | |
| import unittest | |
| from unittest.mock import patch | |
| class TryMockUsingExitStackTest(unittest.TestCase): | |
| def test_mock_random_twice(self): | |
| with ExitStack() as stack: | |
| mock_randrange = stack.enter_context( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| version: '3.4' | |
| services: | |
| redis: | |
| image: 'redis:alpine' | |
| ports: | |
| - 6379:6379 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import time | |
| from celery import Celery | |
| app = Celery('tasks', broker='redis://localhost:6379') | |
| @app.task | |
| def hello(name): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Hello |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Woohoo I added a gist using tavern! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| default_app_config = 'myapp.auth.apps.MyAuthAppConfig' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import cv2 | |
| image = cv2.imread('simplesat.png') | |
| print(type(image)) # <class 'numpy.ndarray'> | |
| print(image.shape) # (224, 224, 3) | |
| b, g, r = image[46, 46] | |
| print(b, g, r) # 152 222 148 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """Python implementation of Conway's Game of Life | |
| Somewhat inspired by Jack Diederich's talk `Stop Writing Classes` | |
| http://pyvideo.org/video/880/stop-writing-classes | |
| Ironically, as I extended the functionality of this module it seems obvious | |
| that the next step would be to refactor board into a class with advance and | |
| constrain as methods and print_board as __str__. | |
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| object HelloWorld { | |
| def main(args: Array[String]): Unit = { | |
| println("From Zero to Hello World!") | |
| } | |
| } |