Skip to content

Commit

Permalink
Merge pull request #486 from athossampayo/test_tabble_apply
Browse files Browse the repository at this point in the history
Added ValueError testing for util.table_apply as asked in issue #476
  • Loading branch information
adnanhemani authored Feb 11, 2021
2 parents cb81e9d + 066273c commit 618a7f7
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import datascience as ds
from datascience import util
import numpy as np
import pytest

def test_doctests():
results = doctest.testmod(util, optionflags=doctest.NORMALIZE_WHITESPACE)
Expand Down Expand Up @@ -50,6 +51,10 @@ def test_table_apply():
assert all(newtab['a'] == tab['a'])
assert all(newtab['b'] == tab['b'] + 1)

with pytest.raises(ValueError) as err:
util.table_apply(tab, lambda a: a+1, subset=['b', 'd'])
assert "Colum mismatch: ['d']" in str(err.value)


def _round_eq(a, b):
if hasattr(a, '__len__'):
Expand Down

0 comments on commit 618a7f7

Please sign in to comment.