Skip to content

Instantly share code, notes, and snippets.

View klrmn's full-sized avatar

Leah Klearman klrmn

View GitHub Profile
import ConfigParser
from selenium import webdriver
class WebdriverFactory(object):
def setup_selenium_from_config(self, config):
"""Start selenium with values from config file, or defaults
rather than requiring the command-line options. File must be
ConfigParser compliant and have a section called 'SELENIUM'.
"""
#!/usr/bin/env python
import unittest
from testresources import OptimisingTestSuite
from subunit.run import SubunitTestProgram, SubunitTestRunner, get_default_formatter
import io, sys, os, logging
import fixtures
from testtools import content
from testtools.testcase import gather_details
"""
This plugin replaces the built-in FinalizingSuiteWrapper with
testresources.OptimisingTestSuite.
"""
from nose.plugins.base import Plugin
from nose.suite import FinalizingSuiteWrapper
from nose.case import Test
from nose.plugins.manager import DefaultPluginManager
from testresources import OptimisingTestSuite
import unittest2
@klrmn
klrmn / exercise_swift.py
Last active July 19, 2019 18:15
exercise_swift
#!/opt/ss/bin/python
import swiftclient
import logging
import signal
import time
from optparse import OptionParser
import json
METHODS = [
@klrmn
klrmn / gist:5572827
Created May 14, 2013 01:00
an __exit__ that does stuff before letting the error do it's thing
class ScreenshotTaker():
def __init__(self, webdriver, logger=None):
self.wd = webdriver
self.logger = logger
def __enter__(self):
pass
def __exit__(self, exec_type, value, tb):
@klrmn
klrmn / gist:4678644
Created January 31, 2013 00:11
proxying for virtualbox
or set up apache to proxy (instructions for ubuntu)
insert into /etc/apache2/apache2.conf
ProxyPass / http://localhost:8000/
ProxyPassReverse / http://localhost:8000/
cd etc/apache2
sudo ln -s ../mods-available/proxy_http.load /etc/apache2/mods-enabled
sudo ln -s ../mods-available/proxy.load /etc/apache2/mods-enabled
sudo service apache2 restart
@klrmn
klrmn / gist:4218762
Created December 5, 2012 19:31
tests.case.api.ApiCrudCases
from tests.case.api import ApiTestCase
class ApiCrudCases(ApiTestCase):
"""Re-usable test cases for Create, Read, Update, and Delete"""
def test_create(self):
pass
def test_create_fails_with_wrong_perms(self):
pass
@klrmn
klrmn / .env
Created October 4, 2012 21:16
You need to specify NAME in your Django settings file.
# put local variants on settings.py here to be used by foreman
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'soundfit',
'USER': 'postgres',
'PASSWORD': 'obscured',
'HOST': '',
'PORT': '',
@klrmn
klrmn / conftest.py
Created August 31, 2012 16:56
run this before and after installing pytest-xdist in the environment
def pytest_terminal_summary(terminalreporter):
config = terminalreporter.config
if not test_cases or config.option.verbose < 1:
return
tw = terminalreporter._tw
tw.sep('-', 'this line will not show up with -n 1')
tw.line('this line should show up')
@klrmn
klrmn / run.py
Created August 16, 2012 22:36
snippet
no_proxy_json = r'{"avoid-proxy":true}'
if options.run_everywhere:
browsers = [
('--platform=LINUX --browsername=firefox --browserver=13 --capabilities=' + no_proxy_json + ' ', 'linux_firefox_13'),
('--platform=LINUX --browsername=opera --browserver=12 ', 'linux_opera_12'),
('--platform=MAC --browsername=firefox --browserver=14 --capabilities=' + no_proxy_json + ' ', 'mac_firefox_14'),
('--platform=VISTA --browsername=chrome --capabilities=' + no_proxy_json + ' ', 'vista_chrome'),
('--platform=VISTA --browsername=firefox --browserver=13 --capabilities=' + no_proxy_json + ' ', 'vista_firefox_13'),
('--platform=VISTA --browsername="internet explorer" --browserver=9 ', 'vista_ie_9'),