-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add some tests, activate coverage report (hopefully)
- Loading branch information
Showing
3 changed files
with
47 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import pytest | ||
|
||
import pandas as pd | ||
|
||
from countess.utils.pandas import * | ||
|
||
df0 = pd.DataFrame([]) | ||
df1 = pd.DataFrame([ {'a': n, 'b': n*100 } for n in range(0,100) ]).set_index('a') | ||
df2 = pd.DataFrame([ {'a': n, 'b': n*100 } for n in range(100,1000) ]).set_index('a') | ||
df3 = pd.DataFrame([ {'a': n, 'b': n*100 } for n in range(1000,10000) ]).set_index('a') | ||
df4 = pd.DataFrame([ {'a': n, 'b': n*100 } for n in range(10000,10100) ]).set_index('a') | ||
df5 = pd.DataFrame([ {'a': n, 'b': n*100 } for n in range(10100,10200) ]).set_index('a') | ||
df6 = pd.DataFrame([ {'a': n, 'b': n*100 } for n in range(10200,10300) ]).set_index('a') | ||
|
||
def assert_iterable_of_dataframes_equal(a,b): | ||
|
||
assert pd.concat(a).sort_index().equals( | ||
pd.concat(b).sort_index() | ||
) | ||
|
||
def test_collect_dataframes_0(): | ||
|
||
x = list(collect_dataframes([df0,df0,None,df0].__iter__())) | ||
assert len(x) == 0 | ||
|
||
def test_collect_dataframes_1(): | ||
x = list(collect_dataframes([df1,df4,df5].__iter__(), 300)) | ||
assert_iterable_of_dataframes_equal([df1,df4,df5], x) | ||
assert min(len(y) for y in x) > 100 | ||
|
||
def test_collect_dataframes_2(): | ||
x = list(collect_dataframes([df1,df2,df4,df5].__iter__(), 300)) | ||
assert_iterable_of_dataframes_equal([df1,df2,df4,df5], x) | ||
assert min(len(y) for y in x) > 100 | ||
|
||
def test_collect_dataframes_3(): | ||
x = list(collect_dataframes([df1,df2,df4,df5,df6].__iter__(), 300)) | ||
assert_iterable_of_dataframes_equal([df1,df2,df4,df5,df6], x) | ||
assert len(x) < 5 |