diff --git a/.gitignore b/.gitignore index 8eb6378..26e8796 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,9 @@ # PyCharm idea folder. /.idea/ + +# PyTest folder +/.pytest_cache/ + +# Dev .eggs folder +/.eggs/ diff --git a/pandas_ods_reader/tests/example_headers.ods b/pandas_ods_reader/tests/rsc/example_headers.ods similarity index 100% rename from pandas_ods_reader/tests/example_headers.ods rename to pandas_ods_reader/tests/rsc/example_headers.ods diff --git a/pandas_ods_reader/tests/example_no_headers.ods b/pandas_ods_reader/tests/rsc/example_no_headers.ods similarity index 100% rename from pandas_ods_reader/tests/example_no_headers.ods rename to pandas_ods_reader/tests/rsc/example_no_headers.ods diff --git a/pandas_ods_reader/tests/test_read_ods.py b/pandas_ods_reader/tests/test_read_ods.py index 52d1738..56b0235 100644 --- a/pandas_ods_reader/tests/test_read_ods.py +++ b/pandas_ods_reader/tests/test_read_ods.py @@ -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 diff --git a/setup.py b/setup.py index f4b08d8..7d4bc71 100644 --- a/setup.py +++ b/setup.py @@ -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"] )