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
# -*- coding:utf-8 -*- | |
import unittest | |
import your_logic as logic | |
class LogicTest(unittest.TestCase): | |
def test_logic(self): | |
self.assertEquals('expect', logic.do_logic()) | |
if __name__ == '__main__': |
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
# -*- coding:utf-8 -*- | |
def do_logic(): | |
# your logic | |
return 'expect' |
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
# -*- coding:utf-8 -*- | |
import time | |
import sys | |
import boto.sqs | |
from boto.sqs.message import Message | |
# tokyo region | |
DEFAULT_REGION = 'ap-northeast-1' | |
Q_NAME = 'myqueue' |
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
class ExampleWithClass: | |
def __init__(self): | |
print('__init__') | |
def __del__(self): | |
print('__del__') | |
def __enter__(self): | |
print('__enter__') | |
#raise ValueError # [LABEL C] |
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
def capture_stderr(&block) | |
original = $stderr | |
captured = $stderr = StringIO.new | |
begin | |
yield | |
ensure | |
$stderr = original | |
end |
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
# -*- coding:utf-8 -*- | |
import json | |
import urllib3 | |
def get_temperature(http): | |
# city=400040 Kurume city in Fukuoka. | |
resp = http.request('GET', 'http://weather.livedoor.com/forecast/webservice/json/v1?city=400040') | |
json_data = json.loads(resp.data.decode('utf-8')) | |
NewerOlder