Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid skipping entire tests when pandas is not installed #574

Merged
merged 1 commit into from
Dec 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions tests/test_tablib.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from pathlib import Path
from uuid import uuid4

import pytest
from openpyxl.reader.excel import load_workbook

import tablib
Expand Down Expand Up @@ -56,7 +55,7 @@ def _test_export_data_in_all_formats(self, dataset, exclude=()):
'latex', 'df', 'rst',
]
for format_ in all_formats:
if format_ in exclude:
if format_ in exclude or (format_ == 'df' and pandas is None):
continue
dataset.export(format_)

Expand Down Expand Up @@ -290,7 +289,6 @@ def test_str_no_columns(self):
'c|3'
])

@pytest.mark.skipif(pandas is None, reason="pandas is not installed")
def test_unicode_append(self):
"""Passes in a single unicode character and exports."""

Expand All @@ -299,7 +297,6 @@ def test_unicode_append(self):
data.append(new_row)
self._test_export_data_in_all_formats(data)

@pytest.mark.skipif(pandas is None, reason="pandas is not installed")
def test_datetime_append(self):
"""Passes in a single datetime and a single date and exports."""

Expand All @@ -311,7 +308,6 @@ def test_datetime_append(self):
data.append(new_row)
self._test_export_data_in_all_formats(data)

@pytest.mark.skipif(pandas is None, reason="pandas is not installed")
def test_separator_append(self):
for _ in range(3):
data.append_separator('foobar')
Expand Down Expand Up @@ -357,7 +353,6 @@ def test_empty_file(self):
dset = tablib.Dataset().load(tmp_file, 'yaml')
self.assertEqual(dset.json, '[]')

@pytest.mark.skipif(pandas is None, reason="pandas is not installed")
def test_auto_format_detect(self):
"""Test auto format detection."""
# html, jira, latex, rst are export only.
Expand All @@ -371,8 +366,9 @@ def test_auto_format_detect(self):
_ods = self.founders.export('ods')
self.assertEqual(tablib.detect_format(_ods), 'ods')

_df = self.founders.export('df')
self.assertEqual(tablib.detect_format(_df), 'df')
if pandas is not None:
_df = self.founders.export('df')
self.assertEqual(tablib.detect_format(_df), 'df')

_yaml = '- {age: 90, first_name: John, last_name: Adams}'
self.assertEqual(tablib.detect_format(_yaml), 'yaml')
Expand Down