remove old testing system
This commit is contained in:
@ -6,7 +6,6 @@ python:
|
||||
script:
|
||||
- python scripts/lint.py
|
||||
- python scripts/readme.py
|
||||
- python scripts/tdd.py
|
||||
- python website/main.py
|
||||
- python scripts/auto-lint.py
|
||||
after_success:
|
||||
|
||||
@ -1,22 +0,0 @@
|
||||
import os,util
|
||||
|
||||
|
||||
snippets = util.read_snippets()
|
||||
for snippet in snippets:
|
||||
os.makedirs('test/' + snippet.name,exist_ok=True)
|
||||
file_to_write_to = open(f'test/{snippet.name}/{snippet.name}.py','w')
|
||||
file_to_write_to.write(snippet.read_code())
|
||||
file_to_write_to.close()
|
||||
if not os.path.isfile(f'test/{snippet.name}/{snippet.name}.test.py'):
|
||||
test_file = open(f'test/{snippet.name}/{snippet.name}.test.py','w')
|
||||
test_file.write(f'''
|
||||
import types,functools
|
||||
from pytape import test
|
||||
from {snippet.name} import {snippet.name}
|
||||
def {snippet.name}_test(t):
|
||||
t.true(isinstance({snippet.name}, (types.BuiltinFunctionType, types.FunctionType, functools.partial)),'{snippet} is a function')
|
||||
test('Testing {snippet.name}',{snippet.name}_test)
|
||||
'''.strip())
|
||||
test_file.close()
|
||||
else:
|
||||
pass
|
||||
@ -7,12 +7,12 @@ Explain briefly what the snippet does.
|
||||
|
||||
Explain briefly how the snippet works.
|
||||
|
||||
``` python
|
||||
```py
|
||||
def function_name(args):
|
||||
# code
|
||||
return 0
|
||||
```
|
||||
|
||||
``` python
|
||||
```py
|
||||
functionName(val) # result
|
||||
```
|
||||
|
||||
@ -1,2 +0,0 @@
|
||||
def all_unique(lst):
|
||||
return len(lst) == len(set(lst))
|
||||
@ -1,6 +0,0 @@
|
||||
import types,functools
|
||||
from pytape import test
|
||||
from all_unique import all_unique
|
||||
def all_unique(t):
|
||||
t.true(isinstance(all_unique, (types.BuiltinFunctionType, types.FunctionType, functools.partial)),'all_unique is a function')
|
||||
test('Testing all_unique',all_unique_test)
|
||||
@ -1,2 +0,0 @@
|
||||
def average(*args):
|
||||
return sum(args, 0.0) / len(args)
|
||||
@ -1,7 +0,0 @@
|
||||
import types,functools
|
||||
from pytape import test
|
||||
from average import average
|
||||
def average_test(t):
|
||||
t.true(isinstance(average, (types.BuiltinFunctionType, types.FunctionType, functools.partial)),'average is a function')
|
||||
t.equal(2,2,'equal')
|
||||
test('Testing average',average_test)
|
||||
@ -1,5 +0,0 @@
|
||||
def bubble_sort(lst):
|
||||
for passnum in range(len(lst) - 1, 0, -1):
|
||||
for i in range(passnum):
|
||||
if lst[i] > lst[i + 1]:
|
||||
lst[i], lst[i + 1] = lst[i + 1], lst[i]
|
||||
@ -1,15 +0,0 @@
|
||||
import types
|
||||
import functools
|
||||
from pytape import test
|
||||
from bubble_sort import bubble_sort
|
||||
|
||||
|
||||
def bubble_sort_test(t):
|
||||
t.true(
|
||||
isinstance(bubble_sort, (types.BuiltinFunctionType, types.FunctionType,
|
||||
functools.partial)),
|
||||
'<util.read_snippets.<locals>.snippet object at 0x7fc8ea4c6978> is a function'
|
||||
)
|
||||
|
||||
|
||||
test('Testing bubble_sort', bubble_sort_test)
|
||||
@ -1,2 +0,0 @@
|
||||
def byte_size(string):
|
||||
return(len(string.encode('utf-8')))
|
||||
@ -1,6 +0,0 @@
|
||||
import types,functools
|
||||
from pytape import test
|
||||
from byte_size import byte_size
|
||||
def byte_size_test(t):
|
||||
t.true(isinstance(byte_size, (types.BuiltinFunctionType, types.FunctionType, functools.partial)),'byte_size is a function')
|
||||
test('Testing byte_size',byte_size_test)
|
||||
@ -1,2 +0,0 @@
|
||||
def capitalize(string, lower_rest=False):
|
||||
return string[:1].upper() + (string[1:].lower() if lower_rest else string[1:])
|
||||
@ -1,6 +0,0 @@
|
||||
import types,functools
|
||||
from pytape import test
|
||||
from capitalize import capitalize
|
||||
def capitalize_test(t):
|
||||
t.true(isinstance(capitalize, (types.BuiltinFunctionType, types.FunctionType, functools.partial)),'capitalize is a function')
|
||||
test('Testing capitalize',capitalize_test)
|
||||
@ -1,2 +0,0 @@
|
||||
def capitalize_every_word(string):
|
||||
return string.title()
|
||||
@ -1,6 +0,0 @@
|
||||
import types,functools
|
||||
from pytape import test
|
||||
from capitalize_every_word import capitalize_every_word
|
||||
def capitalize_every_word_test(t):
|
||||
t.true(isinstance(capitalize_every_word, (types.BuiltinFunctionType, types.FunctionType, functools.partial)),'capitalize_every_word is a function')
|
||||
test('Testing capitalize_every_word',capitalize_every_word_test)
|
||||
@ -1,7 +0,0 @@
|
||||
from math import ceil
|
||||
|
||||
|
||||
def chunk(lst, size):
|
||||
return list(
|
||||
map(lambda x: lst[x * size:x * size + size],
|
||||
list(range(0, ceil(len(lst) / size)))))
|
||||
@ -1,6 +0,0 @@
|
||||
import types,functools
|
||||
from pytape import test
|
||||
from chunk import chunk
|
||||
def chunk_test(t):
|
||||
t.true(isinstance(chunk, (types.BuiltinFunctionType, types.FunctionType, functools.partial)),'chunk is a function')
|
||||
test('Testing chunk',chunk_test)
|
||||
@ -1,2 +0,0 @@
|
||||
def compact(lst):
|
||||
return list(filter(bool, lst))
|
||||
@ -1,6 +0,0 @@
|
||||
import types,functools
|
||||
from pytape import test
|
||||
from compact import compact
|
||||
def compact_test(t):
|
||||
t.true(isinstance(compact, (types.BuiltinFunctionType, types.FunctionType, functools.partial)),'compact is a function')
|
||||
test('Testing compact',compact_test)
|
||||
@ -1,6 +0,0 @@
|
||||
def count_by(arr, fn=lambda x: x):
|
||||
key = {}
|
||||
for el in map(fn, arr):
|
||||
key[el] = 0 if el not in key else key[el]
|
||||
key[el] += 1
|
||||
return key
|
||||
@ -1,6 +0,0 @@
|
||||
import types,functools
|
||||
from pytape import test
|
||||
from count_by import count_by
|
||||
def count_by_test(t):
|
||||
t.true(isinstance(count_by, (types.BuiltinFunctionType, types.FunctionType, functools.partial)),'count_by is a function')
|
||||
test('Testing count_by',count_by_test)
|
||||
@ -1,2 +0,0 @@
|
||||
def count_occurrences(lst, val):
|
||||
return len([x for x in lst if x == val and type(x) == type(val)])
|
||||
@ -1,6 +0,0 @@
|
||||
import types,functools
|
||||
from pytape import test
|
||||
from count_occurences import count_occurences
|
||||
def count_occurences_test(t):
|
||||
t.true(isinstance(count_occurences, (types.BuiltinFunctionType, types.FunctionType, functools.partial)),'count_occurences is a function')
|
||||
test('Testing count_occurences',count_occurences_test)
|
||||
@ -1,5 +0,0 @@
|
||||
import re
|
||||
|
||||
|
||||
def count_vowels(str):
|
||||
return len(len(re.findall(r'[aeiou]', str, re.IGNORECASE)))
|
||||
@ -1,6 +0,0 @@
|
||||
import types,functools
|
||||
from pytape import test
|
||||
from count_vowels import count_vowels
|
||||
def count_vowels_test(t):
|
||||
t.true(isinstance(count_vowels, (types.BuiltinFunctionType, types.FunctionType, functools.partial)),'count_vowels is a function')
|
||||
test('Testing count_vowels',count_vowels_test)
|
||||
@ -1,2 +0,0 @@
|
||||
def decapitalize(string, upper_rest=False):
|
||||
return str[:1].lower() + (str[1:].upper() if upper_rest else str[1:])
|
||||
@ -1,6 +0,0 @@
|
||||
import types,functools
|
||||
from pytape import test
|
||||
from decapitalize import decapitalize
|
||||
def decapitalize_test(t):
|
||||
t.true(isinstance(decapitalize, (types.BuiltinFunctionType, types.FunctionType, functools.partial)),'decapitalize is a function')
|
||||
test('Testing decapitalize',decapitalize_test)
|
||||
@ -1,15 +0,0 @@
|
||||
def spread(arg):
|
||||
ret = []
|
||||
for i in arg:
|
||||
if isinstance(i, list):
|
||||
ret.extend(i)
|
||||
else:
|
||||
ret.append(i)
|
||||
return ret
|
||||
|
||||
|
||||
def deep_flatten(lst):
|
||||
result = []
|
||||
result.extend(
|
||||
spread(list(map(lambda x: deep_flatten(x) if type(x) == list else x, lst))))
|
||||
return result
|
||||
@ -1,6 +0,0 @@
|
||||
import types,functools
|
||||
from pytape import test
|
||||
from deep_flatten import deep_flatten
|
||||
def deep_flatten_test(t):
|
||||
t.true(isinstance(deep_flatten, (types.BuiltinFunctionType, types.FunctionType, functools.partial)),'deep_flatten is a function')
|
||||
test('Testing deep_flatten',deep_flatten_test)
|
||||
@ -1,2 +0,0 @@
|
||||
def difference(a, b):
|
||||
return [item for item in a if item not in b]
|
||||
@ -1,6 +0,0 @@
|
||||
import types,functools
|
||||
from pytape import test
|
||||
from difference import difference
|
||||
def difference_test(t):
|
||||
t.true(isinstance(difference, (types.BuiltinFunctionType, types.FunctionType, functools.partial)),'difference is a function')
|
||||
test('Testing difference',difference_test)
|
||||
@ -1,3 +0,0 @@
|
||||
def difference_by(a, b, fn):
|
||||
b = set(map(fn, b))
|
||||
return [item for item in a if fn(item) not in b]
|
||||
@ -1,6 +0,0 @@
|
||||
import types,functools
|
||||
from pytape import test
|
||||
from difference_by import difference_by
|
||||
def difference_by_test(t):
|
||||
t.true(isinstance(difference_by, (types.BuiltinFunctionType, types.FunctionType, functools.partial)),'difference_by is a function')
|
||||
test('Testing difference_by',difference_by_test)
|
||||
@ -1,5 +0,0 @@
|
||||
def factorial(num):
|
||||
if not ((num >= 0) & (num % 1 == 0)):
|
||||
raise Exception(
|
||||
f"Number( {num} ) can't be floating point or negative ")
|
||||
return 1 if num == 0 else num * factorial(num - 1)
|
||||
@ -1,6 +0,0 @@
|
||||
import types,functools
|
||||
from pytape import test
|
||||
from factorial import factorial
|
||||
def factorial_test(t):
|
||||
t.true(isinstance(factorial, (types.BuiltinFunctionType, types.FunctionType, functools.partial)),'factorial is a function')
|
||||
test('Testing factorial',factorial_test)
|
||||
@ -1,21 +0,0 @@
|
||||
from functools import reduce
|
||||
|
||||
|
||||
def spread(arg):
|
||||
ret = []
|
||||
for i in arg:
|
||||
if isinstance(i, list):
|
||||
ret.extend(i)
|
||||
else:
|
||||
ret.append(i)
|
||||
return ret
|
||||
|
||||
|
||||
def gcd(*args):
|
||||
numbers = []
|
||||
numbers.extend(spread(list(args)))
|
||||
|
||||
def _gcd(x, y):
|
||||
return x if not y else gcd(y, x % y)
|
||||
|
||||
return reduce((lambda x, y: _gcd(x, y)), numbers)
|
||||
@ -1,6 +0,0 @@
|
||||
import types,functools
|
||||
from pytape import test
|
||||
from gcd import gcd
|
||||
def gcd_test(t):
|
||||
t.true(isinstance(gcd, (types.BuiltinFunctionType, types.FunctionType, functools.partial)),'gcd is a function')
|
||||
test('Testing gcd',gcd_test)
|
||||
@ -1,2 +0,0 @@
|
||||
def has_duplicates(lst):
|
||||
return len(lst) != len(set(lst))
|
||||
@ -1,6 +0,0 @@
|
||||
import types,functools
|
||||
from pytape import test
|
||||
from has_duplicates import has_duplicates
|
||||
def has_duplicates(t):
|
||||
t.true(isinstance(has_duplicates, (types.BuiltinFunctionType, types.FunctionType, functools.partial)),'has_duplicates is a function')
|
||||
test('Testing has_duplicates',has_duplicates_test)
|
||||
@ -1,9 +0,0 @@
|
||||
def insertion_sort(lst):
|
||||
|
||||
for i in range(1, len(lst)):
|
||||
key = lst[i]
|
||||
j = i - 1
|
||||
while j >= 0 and key < lst[j]:
|
||||
lst[j + 1] = lst[j]
|
||||
j -= 1
|
||||
lst[j + 1] = key
|
||||
@ -1,6 +0,0 @@
|
||||
import types,functools
|
||||
from pytape import test
|
||||
from insertion_sort import insertion_sort
|
||||
def insertion_sort_test(t):
|
||||
t.true(isinstance(insertion_sort, (types.BuiltinFunctionType, types.FunctionType, functools.partial)),'insertion_sort is a function')
|
||||
test('Testing insertion_sort',insertion_sort_test)
|
||||
@ -1,2 +0,0 @@
|
||||
def is_lower_case(string):
|
||||
return string == string.lower()
|
||||
@ -1,6 +0,0 @@
|
||||
import types,functools
|
||||
from pytape import test
|
||||
from is_lower_case import is_lower_case
|
||||
def is_lower_case_test(t):
|
||||
t.true(isinstance(is_lower_case, (types.BuiltinFunctionType, types.FunctionType, functools.partial)),'is_lower_case is a function')
|
||||
test('Testing is_lower_case',is_lower_case_test)
|
||||
@ -1,2 +0,0 @@
|
||||
def is_upper_case(string):
|
||||
return string == string.upper()
|
||||
@ -1,6 +0,0 @@
|
||||
import types,functools
|
||||
from pytape import test
|
||||
from is_upper_case import is_upper_case
|
||||
def is_upper_case_test(t):
|
||||
t.true(isinstance(is_upper_case, (types.BuiltinFunctionType, types.FunctionType, functools.partial)),'is_upper_case is a function')
|
||||
test('Testing is_upper_case',is_upper_case_test)
|
||||
@ -1,2 +0,0 @@
|
||||
def keys_only(flat_dict):
|
||||
return list(flat_dict.keys())
|
||||
@ -1,6 +0,0 @@
|
||||
import types,functools
|
||||
from pytape import test
|
||||
from keys_only import keys_only
|
||||
def keys_only_test(t):
|
||||
t.true(isinstance(keys_only, (types.BuiltinFunctionType, types.FunctionType, functools.partial)),'keys_only is a function')
|
||||
test('Testing keys_only',keys_only_test)
|
||||
@ -1,24 +0,0 @@
|
||||
from functools import reduce
|
||||
|
||||
|
||||
def spread(arg):
|
||||
ret = []
|
||||
for i in arg:
|
||||
if isinstance(i, list):
|
||||
ret.extend(i)
|
||||
else:
|
||||
ret.append(i)
|
||||
return ret
|
||||
|
||||
|
||||
def lcm(*args):
|
||||
numbers = []
|
||||
numbers.extend(spread(list(args)))
|
||||
|
||||
def _gcd(x, y):
|
||||
return x if not y else _gcd(y, x % y)
|
||||
|
||||
def _lcm(x, y):
|
||||
return x * y / _gcd(x, y)
|
||||
|
||||
return reduce((lambda x, y: _lcm(x, y)), numbers)
|
||||
@ -1,6 +0,0 @@
|
||||
import types,functools
|
||||
from pytape import test
|
||||
from lcm import lcm
|
||||
def lcm_test(t):
|
||||
t.true(isinstance(lcm, (types.BuiltinFunctionType, types.FunctionType, functools.partial)),'lcm is a function')
|
||||
test('Testing lcm',lcm_test)
|
||||
@ -1,2 +0,0 @@
|
||||
def max_n(lst, n=1, reverse=True):
|
||||
return sorted(lst, reverse=reverse)[:n]
|
||||
@ -1,6 +0,0 @@
|
||||
import types,functools
|
||||
from pytape import test
|
||||
from max_n import max_n
|
||||
def max_n_test(t):
|
||||
t.true(isinstance(max_n, (types.BuiltinFunctionType, types.FunctionType, functools.partial)),'max_n is a function')
|
||||
test('Testing max_n',max_n_test)
|
||||
@ -1,7 +0,0 @@
|
||||
from copy import deepcopy
|
||||
|
||||
|
||||
def min_n(lst, n=1):
|
||||
numbers = deepcopy(lst)
|
||||
numbers.sort()
|
||||
return numbers[:n]
|
||||
@ -1,6 +0,0 @@
|
||||
import types,functools
|
||||
from pytape import test
|
||||
from min_n import min_n
|
||||
def min_n_test(t):
|
||||
t.true(isinstance(min_n, (types.BuiltinFunctionType, types.FunctionType, functools.partial)),'min_n is a function')
|
||||
test('Testing min_n',min_n_test)
|
||||
@ -1,4 +0,0 @@
|
||||
def palindrome(string):
|
||||
from re import sub
|
||||
s = sub('[\W_]', '', string.lower())
|
||||
return s == s[::-1]
|
||||
@ -1,6 +0,0 @@
|
||||
import types,functools
|
||||
from pytape import test
|
||||
from palindrome import palindrome
|
||||
def palindrome_test(t):
|
||||
t.true(isinstance(palindrome, (types.BuiltinFunctionType, types.FunctionType, functools.partial)),'palindrome is a function')
|
||||
test('Testing palindrome',palindrome_test)
|
||||
@ -1,12 +0,0 @@
|
||||
from copy import deepcopy
|
||||
from random import randint
|
||||
|
||||
|
||||
def shuffle(lst):
|
||||
temp_lst = deepcopy(lst)
|
||||
m = len(temp_lst)
|
||||
while (m):
|
||||
m -= 1
|
||||
i = randint(0, m)
|
||||
temp_lst[m], temp_lst[i] = temp_lst[i], temp_lst[m]
|
||||
return temp_lst
|
||||
@ -1,6 +0,0 @@
|
||||
import types,functools
|
||||
from pytape import test
|
||||
from shuffle import shuffle
|
||||
def shuffle_test(t):
|
||||
t.true(isinstance(shuffle, (types.BuiltinFunctionType, types.FunctionType, functools.partial)),'shuffle is a function')
|
||||
test('Testing shuffle',shuffle_test)
|
||||
@ -1,8 +0,0 @@
|
||||
def spread(arg):
|
||||
ret = []
|
||||
for i in arg:
|
||||
if isinstance(i, list):
|
||||
ret.extend(i)
|
||||
else:
|
||||
ret.append(i)
|
||||
return ret
|
||||
@ -1,6 +0,0 @@
|
||||
import types,functools
|
||||
from pytape import test
|
||||
from spread import spread
|
||||
def spread_test(t):
|
||||
t.true(isinstance(spread, (types.BuiltinFunctionType, types.FunctionType, functools.partial)),'spread is a function')
|
||||
test('Testing spread',spread_test)
|
||||
@ -1,5 +0,0 @@
|
||||
def values_only(dict):
|
||||
lst = []
|
||||
for k, v in dict.items():
|
||||
lst.append(v)
|
||||
return lst
|
||||
@ -1,6 +0,0 @@
|
||||
import types,functools
|
||||
from pytape import test
|
||||
from values_only import values_only
|
||||
def values_only_test(t):
|
||||
t.true(isinstance(values_only, (types.BuiltinFunctionType, types.FunctionType, functools.partial)),'values_only is a function')
|
||||
test('Testing values_only',values_only_test)
|
||||
@ -1,8 +0,0 @@
|
||||
def zip(*args, fillvalue=None):
|
||||
max_length = max([len(lst) for lst in args])
|
||||
result = []
|
||||
for i in range(max_length):
|
||||
result.append([
|
||||
args[k][i] if i < len(args[k]) else None for k in range(len(args))
|
||||
])
|
||||
return result
|
||||
@ -1,6 +0,0 @@
|
||||
import types,functools
|
||||
from pytape import test
|
||||
from zip import zip
|
||||
def zip_test(t):
|
||||
t.true(isinstance(zip, (types.BuiltinFunctionType, types.FunctionType, functools.partial)),'zip is a function')
|
||||
test('Testing zip',zip_test)
|
||||
Reference in New Issue
Block a user