Unittest
Doctest
import pytest | |
def product_index(request): | |
limit = parse_parameter(request, 'limit', int, default=10) | |
offset = parse_parameter(request, 'offset', int, default=0) | |
return limit, offset | |
def parse_parameter(request, name, klass, default=None): | |
try: | |
return klass(request.GET.get(name, default)) |
pluto:~ $ ipython | |
Python 2.7.8 (default, Aug 24 2014, 21:26:19) | |
Type "copyright", "credits" or "license" for more information. | |
IPython 2.2.0 -- An enhanced Interactive Python. | |
? -> Introduction and overview of IPython's features. | |
%quickref -> Quick reference. | |
help -> Python's own help system. | |
object? -> Details about 'object', use 'object??' for extra details. |
require 'test_helper' | |
describe 'csv' do | |
describe 'encoder' do | |
it 'should properly enclose quotes and commas' do | |
# From http://www.yelp.com/healthscores | |
# | |
# Field values that contain quotation marks or commas must be enclosed | |
# within quotation marks. In addition, each quotation mark in the field | |
# value must be preceded with a quotation mark. This is consistent with |
#!/usr/bin/env python | |
from setuptools import setup, find_packages | |
import sys | |
if sys.argv[1] == 'test': | |
import multiprocessing, logging | |
from billiard import util | |
with open('requirements.txt') as f: | |
required = f.read().splitlines() |
Unittest
Doctest
pluto:~ $ mkdir project | |
pluto:~ $ cd !$ | |
cd project | |
pluto:~/project $ pyvenv venv | |
pluto:~/project $ ls | |
venv/ | |
pluto:~/project $ source venv/bin/activate | |
pluto:~/project $ which python | |
/Users/me/project/venv/bin/python | |
pluto:~/project $ python --version |
# -*- coding: utf-8 -*- | |
require 'digest/md5' | |
require 'set' | |
class String | |
ARTICLES = Set.new [ | |
'a','an','and','by','for','in','is','of','not','on','or','over','the','to','under', 'with'] | |
require 'types' | |
class RsvpController < ApplicationController | |
include Wicked::Wizard | |
steps :get_visitor_kind, :get_gender, :choose_events, :confirmation, :thank_you, :cancel_visit | |
before_filter :get_user, :except => :sign_in | |
def show | |
case step |
def show | |
map_query = CGI.escape("#{@business.name} #{@business.address} #{@business.city} #{STATE} #{@business.zipcode}") | |
@google_map_url = "https://www.google.com/maps/embed/v1/place?key=#{API_KEY}&q=#{map_query}" | |
@html_title = "#{@business.name} – health score #{@business.score}/100 – #{@business.city}, OR – Eaternet" | |
@html_description = "Health inspection history for the #{@business.name} at #{@business.address} in #{@business.city}, #{state}" | |
@inspection = @business.latest_inspection | |
@previous_inspections = @business.inspections.select { |i| i != @inspection } | |
@swiftype_meta_info = swiftype_metadata_json(@business) | |
expires_in(60.minutes, public: true) | |
end |
<div class="row"> | |
<div class="col-sm-7"> | |
<div class="page-header" itemscope itemtype="http://schema.org/Restaurant"> | |
<h1 style="margin-bottom:0" itemprop="name"> | |
<%= @business.name %> | |
</h1> | |
<address class="text-muted" itemprop="address" itemscope itemtype="http://schema.org/PostalAddress"> | |
<span itemprop="streetAddress"><%= @business.address %></span><br> | |
<span itemprop="addressLocality"><%= @business.city %></span>, <span itemprop="addressRegion">OR</span> <span itemprop="postalCode"><%= @business.zipcode %></span> |