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

Make tests robust to plugins adding new translators #2445

Merged
merged 2 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions glue/core/data_factories/tests/test_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def test_translator_from_data():

with pytest.raises(ValueError) as exc:
df = data.get_object()
assert exc.value.args[0] == ('Specify the object class to use with cls= - supported '
'classes are:\n\n* pandas.core.frame.DataFrame')
# Do not specify full error message in case plugins add new translations
assert 'Specify the object class to use with cls' in exc.value.args[0]

df = data.get_object(cls=DataFrame)
assert_equal(list(df.columns), ['a', 'b', 'c'])
Expand Down
10 changes: 4 additions & 6 deletions glue/core/tests/test_data_translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,8 @@ def test_get_object_explicit_class(self):

with pytest.raises(ValueError) as exc:
data.get_object()
assert exc.value.args[0] == ('Specify the object class to use with cls= - '
'supported classes are:\n\n* pandas.core.frame.DataFrame\n'
'* glue.core.tests.test_data_translation.FakeDataObject')
assert 'Specify the object class to use with cls' in exc.value.args[0]
assert 'glue.core.tests.test_data_translation.FakeDataObject' in exc.value.args[0]

obj = data.get_object(cls=FakeDataObject)
assert isinstance(obj, FakeDataObject)
Expand Down Expand Up @@ -142,9 +141,8 @@ def test_get_subset_object_explicit_class(self):

with pytest.raises(ValueError) as exc:
data.get_subset_object()
assert exc.value.args[0] == ('Specify the object class to use with cls= - '
'supported classes are:\n\n* pandas.core.frame.DataFrame\n'
'* glue.core.tests.test_data_translation.FakeDataObject')
assert 'Specify the object class to use with cls' in exc.value.args[0]
assert 'glue.core.tests.test_data_translation.FakeDataObject' in exc.value.args[0]

subset = data.get_subset_object(subset_id=0, cls=FakeDataObject)

Expand Down