Skip to content
This repository has been archived by the owner on Jun 11, 2021. It is now read-only.

More helpful error messages #4

Closed
klahnakoski opened this issue Jan 29, 2018 · 7 comments
Closed

More helpful error messages #4

klahnakoski opened this issue Jan 29, 2018 · 7 comments

Comments

@klahnakoski
Copy link
Contributor

From klahnakoski/mo-logs#2 :

Traceback (most recent call last):
  File "/Users/andersh/Projects/moz-sql-parser/tests/test_simple.py", line 113, in test_bad_select1
    self.assertRaises('Expected select', lambda: parse("se1ect A, B, C from dual"))
  File "/Users/andersh/Projects/moz-sql-parser/venv/lib/python2.7/site-packages/mo_testing/fuzzytestcase.py", line 69, in assertRaises
    cause=f
  File "/Users/andersh/Projects/moz-sql-parser/venv/lib/python2.7/site-packages/mo_logs/__init__.py", line 398, in error
    raise e
Except: ERROR: expecting an exception returning "Expected select" got something else instead

That's a deeply unhelpful message. You should print what that "something else" is.

@boxed
Copy link

boxed commented Jan 29, 2018

You should probably move the entire test suite over to pytest and vastly simplify all that code.

@klahnakoski
Copy link
Contributor Author

On the subject of the error message: It is a result of a test not passing, and I can not think of anything more the error could say; it expects an exception, and it did not get one.

On the subject of pytest: pytest will not reduce the code complexity. The FuzzyTestCase does a fuzzy data- structure comparison between a test and an expected. I must review the tests in py2.7 to see if any "fuzzy" features are used. If not, then this dependency can be removed.

@boxed
Copy link

boxed commented Jan 29, 2018

, and I can not think of anything more the error could say; it expects an exception, and it did not get one.

No that's not the problem at all. Read more carefully. It expects an assertionerror that contains the string "Expected select". I was working on trying to expand moz-sql-parser to cover more SQL syntax.

I'm still pretty sure this error message is actually in the logging module where I first created the issue. The exception should have been "expected foo, found bar". It's just a string comparison!

@klahnakoski
Copy link
Contributor Author

Yes, the test on line 113 (test_bad_select1) is verifying that an exception is thrown when the first word in the SQL is not "select". Specifically, the third letter is the number one (1), not the letter L as would be expected.

test_bad_select1 is expecting "Expecting select" somewhere in the parsing exception. I believe "Expecting select" is a good message if the first word is not "select", and I believe test_bad_select1 can not get much clearer. Maybe you have a suggestion for a better error message?

Since I can not get pyparsing to work with Python3, maybe you can use python2 in the meantime?

#3

@boxed
Copy link

boxed commented Jan 29, 2018 via email

@klahnakoski
Copy link
Contributor Author

Please push your changes, and send me a link. I would like to see how far you got, and incorporate what you have done so it is less painful for the next person.

thank you for your time on this.

@boxed
Copy link

boxed commented Jan 29, 2018 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants