sassoftware / saspy

A Python interface module to the SAS System. It works with Linux, Windows, and Mainframe SAS as well as with SAS in Viya.
https://sassoftware.github.io/saspy
Other
367 stars 149 forks source link

Improve Unittest File for STATS Products #519

Closed dmsenter89 closed 1 year ago

dmsenter89 commented 1 year ago

Prefixed all tests with test_ so that they will run with the unittests. This revealed some issues with the tests that I have fixed, including missing imports and tests that called the wrong functions. I also updated the messages to print out a useful error message in the event of a failed test. A skip has been added to test_regResult4 that deserves further investigation - the test fails due to the function returning a NoneType. When I manually run this scenario in Jupyter, I also get the NoneType but the output displays the HTML correctly as expected. The test test_strdset2 is skipped because it doesn't seem to function properly.

This PR fixes #515 .

tomweber-sas commented 1 year ago

Thanks @dmsenter89, that's looking good. One thing though. SASPy isn't dependent on either Pandas or IPython, so we can't unconditionally import them, else the whole test table can fail. Looks like there are only a couple places trying to use these for type checks. We could validate the tests in a different way than checking the type for these, and then not have to import them. You can use dataframe methods (df.shape, df.dtypes, ...) without needing to import pandas. Or conditionally import them (try:except:) and then just skip those if they didn't import. HTML that's returned is just a string, but depending upon the interface being used it may or may not have anything to do with IPython (it does in Jupyter, but not in Zeppelin or Databricks, ...).

So if we can not import them and just change the couple test that are using them explicitly, all should be well.

Thanks! Tom

tomweber-sas commented 1 year ago

Sweet! Thanks Michael!

dmsenter89 commented 1 year ago

I updated the affected tests to run conditionally on IPython or Pandas being available, and tested the different combinations with a nix-shell. This should be ok to merge now. Let me know if you need any other fixes for this to be ok to move in!