Skip to content

Commit

Permalink
bug fix patching #146 (#159)
Browse files Browse the repository at this point in the history
* remove sys.tracebacklimit to avoid `ERROR:root:Internal Python error in the inspect module`
* changed SyntaxError to TypeError to reserved SyntaxError for Pandas native syntax problems
  • Loading branch information
dorisjlee committed Nov 28, 2020
1 parent 3a8d9f9 commit 770a30d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 24 deletions.
6 changes: 2 additions & 4 deletions lux/vis/Vis.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,7 @@ def refresh_source(self, ldf): # -> Vis:
ldf.executor.execute([self], ldf)

def check_not_vislist_intent(self):
import sys

sys.tracebacklimit = 0
syntaxMsg = (
"The intent that you specified corresponds to more than one visualization. "
"Please replace the Vis constructor with VisList to generate a list of visualizations. "
Expand All @@ -328,9 +326,9 @@ def check_not_vislist_intent(self):
if type(self._intent[i]) != Clause and (
"|" in self._intent[i] or type(self._intent[i]) == list
):
raise SyntaxError(syntaxMsg)
raise TypeError(syntaxMsg)

if len(self._intent) > 2 or "?" in self._intent:
for i in range(len(self._intent)):
if type(self._intent[i]) != Clause:
raise SyntaxError(syntaxMsg)
raise TypeError(syntaxMsg)
26 changes: 6 additions & 20 deletions tests/test_error_warning.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,34 +39,20 @@ def test_bad_filter(global_var):

def test_multi_vis(global_var):
df = pytest.college_df
with pytest.raises(
SyntaxError,
match="The intent that you specified corresponds to more than one visualization.",
):
multivis_msg = "The intent that you specified corresponds to more than one visualization."
with pytest.raises(TypeError, match=multivis_msg):
Vis(["SATAverage", "AverageCost", "Geography=?"], df)

with pytest.raises(
SyntaxError,
match="The intent that you specified corresponds to more than one visualization.",
):
with pytest.raises(TypeError, match=multivis_msg):
Vis(["SATAverage", "?"], df)

with pytest.raises(
SyntaxError,
match="The intent that you specified corresponds to more than one visualization.",
):
with pytest.raises(TypeError, match=multivis_msg):
Vis(["SATAverage", "AverageCost", "Region=New England|Southeast"], df)

with pytest.raises(
SyntaxError,
match="The intent that you specified corresponds to more than one visualization.",
):
with pytest.raises(TypeError, match=multivis_msg):
Vis(["Region=New England|Southeast"], df)

with pytest.raises(
SyntaxError,
match="The intent that you specified corresponds to more than one visualization.",
):
with pytest.raises(TypeError, match=multivis_msg):
Vis(["FundingModel", ["Region", "ACTMedian"]], df)


Expand Down

0 comments on commit 770a30d

Please sign in to comment.