-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Massive improvements to testing infrastructure
- Loading branch information
Sterling Paramore
committed
Sep 2, 2017
1 parent
b827cf2
commit 27c458a
Showing
14 changed files
with
1,753 additions
and
691 deletions.
There are no files selected for viewing
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,111 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"ename": "AssertionError", | ||
"evalue": "DataFrame are different\n\nDataFrame shape mismatch\n[left]: (2, 4)\n[right]: (1, 4)", | ||
"output_type": "error", | ||
"traceback": [ | ||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", | ||
"\u001b[0;31mAssertionError\u001b[0m Traceback (most recent call last)", | ||
"\u001b[0;32m<ipython-input-5-0d5fbcebcabc>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 31\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 32\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 33\u001b[0;31m \u001b[0massert_frame_equal\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mexpected\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mactual\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", | ||
"\u001b[0;32m~/miniconda3/envs/pemi/lib/python3.6/site-packages/pandas/util/testing.py\u001b[0m in \u001b[0;36massert_frame_equal\u001b[0;34m(left, right, check_dtype, check_index_type, check_column_type, check_frame_type, check_less_precise, check_names, by_blocks, check_exact, check_datetimelike_compat, check_categorical, check_like, obj)\u001b[0m\n\u001b[1;32m 1397\u001b[0m \u001b[0;34m'DataFrame shape mismatch'\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1398\u001b[0m \u001b[0;34m'({0}, {1})'\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mformat\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0mleft\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mshape\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1399\u001b[0;31m '({0}, {1})'.format(*right.shape))\n\u001b[0m\u001b[1;32m 1400\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1401\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mcheck_like\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", | ||
"\u001b[0;32m~/miniconda3/envs/pemi/lib/python3.6/site-packages/pandas/util/testing.py\u001b[0m in \u001b[0;36mraise_assert_detail\u001b[0;34m(obj, message, left, right, diff)\u001b[0m\n\u001b[1;32m 1147\u001b[0m \u001b[0mmsg\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mmsg\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0;34m\"\\n[diff]: {diff}\"\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mformat\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdiff\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mdiff\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1148\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1149\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mAssertionError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmsg\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1150\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1151\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", | ||
"\u001b[0;31mAssertionError\u001b[0m: DataFrame are different\n\nDataFrame shape mismatch\n[left]: (2, 4)\n[right]: (1, 4)" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"import importlib\n", | ||
"import pemi.testing\n", | ||
"importlib.reload(pemi.testing)\n", | ||
"\n", | ||
"from pandas.util.testing import assert_frame_equal\n", | ||
"\n", | ||
"schema = {\n", | ||
" 'alpha': { 'type': 'string' },\n", | ||
" 'beta': { 'type': 'integer' },\n", | ||
" 'gamma': { 'type': 'date', 'in_format': '%m/%d/%Y' }\n", | ||
"}\n", | ||
"\n", | ||
"expected = pemi.testing.MarkdownTable(\n", | ||
" '''\n", | ||
" | alpha | beta | gamma | delta |\n", | ||
" | - | - | - | - |\n", | ||
" | one | 2 | 5/3/2017 | purple |\n", | ||
" | one | 2 | 5/3/2017 | purple |\n", | ||
" ''',\n", | ||
" schema\n", | ||
").df\n", | ||
"\n", | ||
"actual = pemi.testing.MarkdownTable(\n", | ||
" '''\n", | ||
" | alpha | beta | gamma | delta |\n", | ||
" | - | - | - | - |\n", | ||
" | one | 2 | 5/3/2017 | purple |\n", | ||
" ''',\n", | ||
" schema\n", | ||
").df\n", | ||
"\n", | ||
"\n", | ||
"assert_frame_equal(expected, actual)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 9, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"1\n", | ||
"2\n", | ||
"3\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"class Mofo():\n", | ||
" def __init__(self):\n", | ||
" self.x = 0\n", | ||
" \n", | ||
" @property\n", | ||
" def happypants(self):\n", | ||
" self.x += 1\n", | ||
" print(self.x)\n", | ||
" \n", | ||
"m = Mofo()\n", | ||
"m.happypants\n", | ||
"m.happypants\n", | ||
"m.happypants " | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.6.1" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
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,12 @@ | ||
beer_id,sold_at,quantity,id,name,style_id,abv,price,style | ||
1,2017-01-01,3,1,SpinCycle,1,7.2,4.99,IPA | ||
1,2017-01-04,2,1,SpinCycle,1,7.2,4.99,IPA | ||
1,2017-01-16,4,1,SpinCycle,1,7.2,4.99,IPA | ||
1,2017-01-20,2,1,SpinCycle,1,7.2,4.99,IPA | ||
2,2017-01-06,7,2,OldStyle,2,4.2,3.99,Pale | ||
2,2017-01-16,3,2,OldStyle,2,4.2,3.99,Pale | ||
4,2017-01-06,8,4,AbstRedRibbon,7,3.2,1.99,Unknown id 7 | ||
4,2017-01-17,5,4,AbstRedRibbon,7,3.2,1.99,Unknown id 7 | ||
3,2017-01-14,1,3,Pipewrench,1,8.3,10.99,IPA | ||
3,2017-01-15,3,3,Pipewrench,1,8.3,10.99,IPA | ||
3,2017-01-20,1,3,Pipewrench,1,8.3,10.99,IPA |
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,5 @@ | ||
id|name|style_id|abv|price | ||
1|SpinCycle|1|7.2|4.99 | ||
2|OldStyle|2|4.2|3.99 | ||
3|Pipewrench|1|8.3|10.99 | ||
4|AbstRedRibbon|7|3.2|1.99 |
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,12 @@ | ||
beer_id|sold_at|quantity | ||
1|01/01/2017|3 | ||
1|01/04/2017|2 | ||
2|01/06/2017|7 | ||
4|01/06/2017|8 | ||
3|01/14/2017|1 | ||
3|01/15/2017|3 | ||
2|01/16/2017|3 | ||
1|01/16/2017|4 | ||
4|01/17/2017|5 | ||
1|01/20/2017|2 | ||
3|01/20/2017|1 |
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
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 |
---|---|---|
|
@@ -3,3 +3,4 @@ jupyter | |
nose2(pip) | ||
dask | ||
graphviz pip | ||
faker(pip) |
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
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
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
Oops, something went wrong.