Skip to content

Commit

Permalink
Merge pull request #200 from lvgig/feature/generic_tests_capping
Browse files Browse the repository at this point in the history
Generic Tests for CappingTransformer
  • Loading branch information
limlam96 authored Apr 15, 2024
2 parents beba8cd + 901b29d commit 7b8f03e
Show file tree
Hide file tree
Showing 7 changed files with 1,079 additions and 983 deletions.
27 changes: 0 additions & 27 deletions tests/base_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,33 +114,6 @@ def test_columns_non_string_or_list_error(
uninitialized_transformers[self.transformer_name](**args)


class ColumnsFromDictInitTests(GenericInitTests):
"""
Tests for BaseTransformer.init() behaviour specific to when a transformer reads columns from a dict.
Note this deliberately avoids starting with "Tests" so that the tests are not run on import.
"""

@pytest.mark.parametrize("non_string", [1, True, None])
def test_columns_list_element_error(
self,
non_string,
minimal_attribute_dict,
uninitialized_transformers,
):
"""Test an error is raised if columns list contains non-string elements."""

args = minimal_attribute_dict[self.transformer_name].copy()
args["mappings"][non_string] = {1: 2, 3: 4}

with pytest.raises(
TypeError,
match=re.escape(
f"{self.transformer_name}: each element of columns should be a single (string) column name",
),
):
uninitialized_transformers[self.transformer_name](**args)


class GenericFitTests:
"""
Generic tests for transformer.fit().
Expand Down
Loading

0 comments on commit 7b8f03e

Please sign in to comment.