-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b7aa9df
commit e7bf88b
Showing
14 changed files
with
1,928 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[pytest] | ||
markers = | ||
database: mark a test needing access to database |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from setuptools import setup, find_packages | ||
|
||
setup( | ||
name='PackageName', | ||
version='0.1', | ||
author='YoursTruly', | ||
author_email='[email protected]', | ||
packages= ["src"], #find_packages(), | ||
description='Exemplatory package.', | ||
#long_description=open('README.md').read(), | ||
install_requires=[ | ||
"pytest", | ||
],) |
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
text = "modularity is the key" | ||
|
||
def f(arg): | ||
print(f'This function takes as an argument: {arg}') | ||
|
||
class AClass: | ||
pass |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
def test_sum(): | ||
assert sum([1,1]) == 2, "Should be 2" | ||
|
||
def test_len_vs__len__(): | ||
a_tuple = (1,2,3,5) | ||
assert len(a_tuple) == a_tuple.__len__(), "Function len returned differnt result than method __len__" | ||
|
||
if __name__ == "__main__": | ||
test_sum() | ||
test_len_vs__len__() | ||
print('All tests passed.') |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
def test_sum(): | ||
assert sum([1,1]) == 3, "Should be 2" | ||
|
||
def test_len_vs__len__(): | ||
a_tuple = (1,2,3,5) | ||
assert len(a_tuple) == a_tuple.__len__(), "Function len returned differnt result than method __len__" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
def test_sum(): | ||
assert sum([1,1]) == 2, "Should be 2" | ||
|
||
def test_len_vs__len__(): | ||
a_tuple = (1,2,3,5) | ||
assert len(a_tuple) == a_tuple.__len__(), "Function len returned differnt result than method __len__" | ||
|
||
if __name__ == "__main__": | ||
test_sum() | ||
test_len_vs__len__() | ||
print('All tests passed.') |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
def test_sum(): | ||
assert sum([1,1]) == 3, "Should be 2" | ||
|
||
def test_len_vs__len__(): | ||
a_tuple = (1,2,3,5) | ||
assert len(a_tuple) == a_tuple.__len__(), "Function len returned differnt result than method __len__" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import pytest | ||
|
||
@pytest.fixture | ||
def smtp(): | ||
"""Initialize and return SMTP client session object""" | ||
import smtplib | ||
return smtplib.SMTP("smtp.gmail.com") | ||
|
||
def test_ehlo(smtp): | ||
"""Test response from sending Extended Helo (EHLO) is 250.""" | ||
response, msg = smtp.ehlo() | ||
assert response == 250 | ||
# assert 0 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import pytest | ||
|
||
@pytest.fixture | ||
def data_names(): | ||
import pandas as pd | ||
df = pd.read_csv('tests/data/test_data_names.csv') | ||
return df | ||
|
||
def test_addressing(data_names): | ||
df = data_names | ||
titles = df['Title'] | ||
surnames = df['Surname'] | ||
expected = df['Addressing'] | ||
assert (titles + ' ' + expected == surnames).all() |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import pytest | ||
|
||
@pytest.mark.database | ||
def test_pg_read(): | ||
pass | ||
|
||
@pytest.mark.database | ||
def test_pg_write(): | ||
pass |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import pytest | ||
import unicodedata | ||
|
||
####### | ||
# Function we would like to test should be defined in package code, not here. | ||
######## | ||
def drop_diacritics(text: str) -> str: | ||
""" | ||
Strip accents from input String. | ||
:param text: The input string. | ||
:returns: The processed string. | ||
""" | ||
if not isinstance(text, str): | ||
raise TypeError(f'Input text should be a string, not %s', type(text)) | ||
|
||
# Return the normal form for the Unicode string | ||
# 'NFKD' stands for the normal form KD | ||
text = unicodedata.normalize('NFKD',text) | ||
output = '' | ||
|
||
for char in text: | ||
if not unicodedata.combining(char): | ||
output += char | ||
|
||
return output | ||
#### | ||
|
||
|
||
@pytest.mark.parametrize("test_input,expected", [("3+5", 8), ("2+4", 6), ("6*9", 42)]) | ||
def test_eval(test_input, expected): | ||
assert eval(test_input) == expected | ||
|
||
@pytest.mark.parametrize( | ||
'original,output', | ||
[ | ||
('řeřicha', 'rericha'), | ||
('čeština', 'cestina') | ||
] | ||
) | ||
def test_drop_diacritics(original:str, output:str) -> None: | ||
assert drop_diacritics(original) == output | ||
|