Skip to content
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
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
Enhancements and Fixes
----------------------

- Clear stale _ex before each execute_stream call [#751]

- Support VOTableFile in accessible_table and broadcast_samp [#745]

- Declaratively define new-style standard IDs in Servicetype constraint [#744]
Expand Down
1 change: 1 addition & 0 deletions pyvo/dal/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ def execute_stream(self, *, post=False):
No exceptions are raised here because non-2xx responses might still
contain payload. They can be raised later by calling ``raise_if_error``
"""
self._ex = None
response = self.submit(post=post)

try:
Expand Down
25 changes: 25 additions & 0 deletions pyvo/dal/tests/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,31 @@ def test_execute_raw(self):
assert raw.startswith(b'<?xml')
assert raw.strip().endswith(b'</VOTABLE>')

def test_execute_stream_clears_stale_ex_on_success(self, mocker):
query = DALQuery('http://example.com/query/basic')
with mocker.register_uri('GET', '//example.com/query/basic',
text='Server Error', status_code=500):
query.execute_stream()
assert query._ex is not None

with mocker.register_uri('GET', '//example.com/query/basic',
content=get_pkg_data_contents('data/query/basic.xml')):
query.execute_stream()
assert query._ex is None

def test_execute_votable_raises_parse_error_not_stale_http_error(self, mocker):
query = DALQuery('http://example.com/query/basic')
with mocker.register_uri('GET', '//example.com/query/basic',
text='Server Error', status_code=500):
query.execute_stream()
assert query._ex is not None

with mocker.register_uri('GET', '//example.com/query/basic',
content=b'not valid votable xml',
status_code=200):
with pytest.raises(DALFormatError):
query.execute_votable()


@pytest.mark.filterwarnings('ignore::astropy.io.votable.exceptions.W03')
@pytest.mark.filterwarnings('ignore::astropy.io.votable.exceptions.W06')
Expand Down
Loading