Skip to content

Instantly share code, notes, and snippets.

View poliarush's full-sized avatar

Mykhailo Poliarush poliarush

View GitHub Profile
import pytest
from random import randint
def data_generator():
# some logic
return [_ * randint(0, 10) for _ in range(10)]
class TestClass(object):
from collections import Counter
from collections import OrderedDict
msg = """If web server returns any error message
for any query by application server
then application server should catch and display
these error messages appropriately to the users"""
items = OrderedDict([(_, Counter(_)) for _ in msg.split()])
cleared = zip(*filter(lambda (k, v): len(v.values()) == sum(v.values()), items.iteritems()))[0]
@poliarush
poliarush / base.py
Last active September 28, 2015 06:28
setup and tear down separation
import unittest
class BaseTest(unittest.TestCase):
def setUp(self):
print('setup')
def tearDown(self):
print('tear down')
import math
def convert_blocks_to_lists(list):
block_length = int(math.sqrt(len(list)))
squares = []
for i in range(0,len(list),block_length):
for j in range(0,len(list),block_length):
squares.append([item for x in range (i,i+block_length) for item in list[x][j:j+block_length]])
@poliarush
poliarush / common.py
Created April 29, 2015 07:45
pytest+webium
from selenium import webdriver
class Driver(object):
__instance = None
@classmethod
def get(cls, type='ff'):
if not cls.__instance:
cls.__instance = webdriver.Firefox()
@poliarush
poliarush / common.py
Created April 27, 2015 19:32
manage webdriver instance with pytest
import pytest
class BaseTest(object):
@pytest.fixture(scope="class", autouse=True)
def manage_driver(self, request, driver):
driver.start()
request.addfinalizer(driver.stop)
@poliarush
poliarush / app.cfg
Last active August 29, 2015 14:15
configparser issue
[sites]
base_site = testsite
@poliarush
poliarush / output.log
Last active January 10, 2020 08:35
json + http get\post\delete requests
test_data_creation (__main__.TestServerFunctionality) ... ok
test_data_creation_incorrect_header (__main__.TestServerFunctionality) ... ok
test_data_retrieve (__main__.TestServerFunctionality) ... ok
test_delete (__main__.TestServerFunctionality) ... ok
----------------------------------------------------------------------
Ran 4 tests in 3.170s
OK
@poliarush
poliarush / output
Created February 9, 2015 21:41
xml parsing
ApplicationState = None [ObjectifiedElement]
* xsi:noNamespaceSchemaLocation = 'ApplicationState.xsd'
appState = 'PRE_RACE' [StringElement]
eventId = 3625 [IntElement]
trackId = 713 [IntElement]
NextEventId = 3621 [IntElement]
PastEventId = 3627 [IntElement]
PRE_RACE
3625
713
import sys
import os
def main():
usage = """
You should pass at least 1 argument to %s
Arguments are folders full path separated by space.
""" % sys.argv[0]