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.
/.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__))
rsc = os.path.join(root, "rsc")
class OdsReaderTest(object):
def test_header_file_with_int():
class TestOdsReader(object):
def test_header_file_with_int(self):
example = "example_headers.ods"
path = os.path.join(root, example)
# print("Test sheet by index")
path = os.path.join(rsc, example)
df = read_ods(path, 1)
assert isinstance(df, pd.DataFrame)
def test_header_file_with_str():
def test_header_file_with_str(self):
example = "example_headers.ods"
path = os.path.join(root, example)
path = os.path.join(rsc, example)
df = read_ods(path, "Sheet1")
print(df)
assert isinstance(df, pd.DataFrame)
def test_no_header_file():
def test_no_header_file_no_cols(self):
example = "example_no_headers.ods"
path = os.path.join(root, example)
print("Test sheet by index and default columns")
path = os.path.join(rsc, example)
df = read_ods(path, 1, headers=False)
print(df)
print("Test sheet by name and default columns")
df = read_ods(path, "Sheet1", headers=False)
print(df)
print("Test sheet by index and specific columns")
assert list(df.columns) == [
"column_%s" % i for i in range(len(df.columns))]
def test_no_header_file_with_cols(self):
example = "example_headers.ods"
path = os.path.join(rsc, example)
columns = ["A", "B", "C", "D", "E"]
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
VERSION = "0.0.4"
VERSION = "0.0.5"
with open("README.md", "r") as fh:
long_description = fh.read()
@ -24,5 +24,7 @@ setup(name="pandas_ods_reader",
license="MIT",
packages=find_packages(),
zip_safe=False,
install_requires=["ezodf", "pandas", "lxml"]
install_requires=["ezodf", "pandas", "lxml"],
setup_requires=["pytest-runner"],
tests_require=["pytest"]
)