Skip to content

Commit

Permalink
Improved error message
Browse files Browse the repository at this point in the history
when calling symget on a dead session
  • Loading branch information
Sam Leeman-Munk authored and Sam Leeman-Munk committed Jan 8, 2024
1 parent 29199c9 commit cc18927
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions saspy/sasbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -2093,6 +2093,8 @@ def symexist(self, name: str):
ll = self._io.submit("%put " + name + "BEGIN=%symexist(" + name + ") "+ name+"END=;\n")
l2 = ll['LOG'].rpartition(name + "BEGIN=")[2].rpartition(name+"END=")[0].strip().replace('\n','')

if l2 == '':
raise ValueError("Failed to execute symexist. Your session may be dead.")
var = int(l2)

return bool(var)
Expand Down
18 changes: 18 additions & 0 deletions saspy/tests/test_symget.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import unittest
import saspy


class TestSASViyaML(unittest.TestCase):

def testSymgetOnDeadSession(self):
sas = saspy.SASsession()

results = sas.submit("endsas;")

try:
sas.SYSINFO()
except ValueError as e:
self.assertFalse(str(e)!="Failed to execute symexist. Your session may be dead.")

if __name__ == '__main__':
unittest.main()

0 comments on commit cc18927

Please sign in to comment.