Skip to content

Commit

Permalink
Avoid skipping entire tests when pandas is not installed (#574)
Browse files Browse the repository at this point in the history
  • Loading branch information
claudep committed Dec 21, 2023
1 parent 92a7535 commit 65b6d7b
Showing 1 changed file with 4 additions and 8 deletions.
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

0 comments on commit 65b6d7b

Please sign in to comment.