Skip to content

Commit

Permalink
Now correctly resolve Warnings and Assumptions.
Browse files Browse the repository at this point in the history
Fixes #29
  • Loading branch information
jaraco committed Jun 1, 2024
1 parent 7051057 commit ea9a3b0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions newsfragments/29.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Now correctly resolve Warnings and Assumptions.
7 changes: 7 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ def test_properties(temp_result):
assert len(info) == len(pods) + len(warnings) + len(assumptions)


def test_assumptions(client):
res = client.query('pi')
(assumption,) = res.assumptions
assert assumption.word == 'pi'
assert assumption.type == 'Clash'


def test_pod_attributes(temp_result):
pod = next(temp_result.pods)
assert isinstance(pod.position, float)
Expand Down
12 changes: 7 additions & 5 deletions wolframalpha/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,14 @@ def _get_attr(self, name):
def _get_children(self, name):
if name not in self.__class__.children:
return

# some objects, like Assumptions and Warnings
# are found in a container with the plural name;
# others like Pods and Subpods appear directly in
# the parent (self).
container = self.get(name, self)
singular = name.rstrip('s')
try:
val = self._get_attr(singular)
except AttributeError:
val = None
return always_iterable(val, base_type=dict)
return always_iterable(container.get(singular), base_type=dict)


class Assumption(Document):
Expand Down

0 comments on commit ea9a3b0

Please sign in to comment.