pytest implementation

This commit is contained in:
iuvbio 2019-01-31 22:34:20 +01:00
parent 314ea3ff69
commit 8949578994
5 changed files with 25 additions and 18 deletions

6
.gitignore vendored
View File

@ -12,3 +12,9 @@
# PyCharm idea folder. # PyCharm idea folder.
/.idea/ /.idea/
# PyTest folder
/.pytest_cache/
# Dev .eggs folder
/.eggs/

View File

@ -6,33 +6,32 @@ from pandas_ods_reader import read_ods
root = os.path.dirname(os.path.abspath(__file__)) root = os.path.dirname(os.path.abspath(__file__))
rsc = os.path.join(root, "rsc")
class OdsReaderTest(object): class TestOdsReader(object):
def test_header_file_with_int(): def test_header_file_with_int(self):
example = "example_headers.ods" example = "example_headers.ods"
path = os.path.join(root, example) path = os.path.join(rsc, example)
# print("Test sheet by index")
df = read_ods(path, 1) df = read_ods(path, 1)
assert isinstance(df, pd.DataFrame) assert isinstance(df, pd.DataFrame)
def test_header_file_with_str(): def test_header_file_with_str(self):
example = "example_headers.ods" example = "example_headers.ods"
path = os.path.join(root, example) path = os.path.join(rsc, example)
df = read_ods(path, "Sheet1") df = read_ods(path, "Sheet1")
print(df)
assert isinstance(df, pd.DataFrame) assert isinstance(df, pd.DataFrame)
def test_no_header_file(): def test_no_header_file_no_cols(self):
example = "example_no_headers.ods" example = "example_no_headers.ods"
path = os.path.join(root, example) path = os.path.join(rsc, example)
print("Test sheet by index and default columns")
df = read_ods(path, 1, headers=False) df = read_ods(path, 1, headers=False)
print(df) assert list(df.columns) == [
print("Test sheet by name and default columns") "column_%s" % i for i in range(len(df.columns))]
df = read_ods(path, "Sheet1", headers=False)
print(df) def test_no_header_file_with_cols(self):
print("Test sheet by index and specific columns") example = "example_headers.ods"
path = os.path.join(rsc, example)
columns = ["A", "B", "C", "D", "E"] columns = ["A", "B", "C", "D", "E"]
df = read_ods(path, 1, headers=False, columns=columns) df = read_ods(path, 1, headers=False, columns=columns)
print(df) assert list(df.columns) == columns

View File

@ -1,7 +1,7 @@
from setuptools import setup, find_packages from setuptools import setup, find_packages
VERSION = "0.0.4" VERSION = "0.0.5"
with open("README.md", "r") as fh: with open("README.md", "r") as fh:
long_description = fh.read() long_description = fh.read()
@ -24,5 +24,7 @@ setup(name="pandas_ods_reader",
license="MIT", license="MIT",
packages=find_packages(), packages=find_packages(),
zip_safe=False, zip_safe=False,
install_requires=["ezodf", "pandas", "lxml"] install_requires=["ezodf", "pandas", "lxml"],
setup_requires=["pytest-runner"],
tests_require=["pytest"]
) )