Error when testing dialect with an exclusion

Issue #4249 resolved
Patrick Buxton
created an issue

The error shown below is seen when testing a dialect with:

    @property
    def json_type(self):
        return exclusions.closed()
=================================== ERRORS ====================================
___________ ERROR at setup of JSONTest.test_crit_against_int_basic ____________
Traceback (most recent call last):
  File "C:\Users\pat\Anaconda2\lib\site-packages\sqlalchemy\testing\plugin\pytestplugin.py", line 173, in pytest_runtest_setup
    class_setup(item.parent.parent)
  File "C:\Users\pat\Anaconda2\lib\site-packages\sqlalchemy\testing\plugin\pytestplugin.py", line 206, in class_setup
    plugin_base.start_test_class(item.cls)
  File "C:\Users\pat\Anaconda2\lib\site-packages\sqlalchemy\testing\plugin\plugin_base.py", line 452, in start_test_class
    _do_skips(cls)
  File "C:\Users\pat\Anaconda2\lib\site-packages\sqlalchemy\testing\plugin\plugin_base.py", line 567, in _do_skips
    for config_obj in config.Config.all_configs()
  File "C:\Users\pat\Anaconda2\lib\site-packages\sqlalchemy\testing\plugin\plugin_base.py", line 567, in <genexpr>
    for config_obj in config.Config.all_configs()
TypeError: 'NoneType' object is not iterable

I'm working on two dialects with this skip in place and it doesn't affect one of them, but I have seen that other people have also had this issue. (https://github.com/gijzelaerr/sqlalchemy-monetdb/issues/30)

The easiest way to reproduce will be to run the dialect tests:

git clone git@github.com:PlaidCloud/sqlalchemy-hana.git
cd sqlalchemy-hana
git checkout identity_column
python setup.py test

Just comment out line 62 in testing\provision.py if you don't have a HANA server to point at and you'll still get the error generated even if the tests fail.

Comments (13)

  1. Michael Bayer repo owner

    your setup.py seems to be defaulting to python unittest, which is not supported, on both Python 2 and Python 3 I get essentially this error:

    ImportError: Failed to import test module: test.test_suite
    Traceback (most recent call last):
      File "/usr/lib64/python2.7/unittest/loader.py", line 254, in _find_tests
        module = self._get_module_from_name(name)
      File "/usr/lib64/python2.7/unittest/loader.py", line 232, in _get_module_from_name
        __import__(name)
      File "/home/classic/dev/sqlalchemy-hana/test/test_suite.py", line 19, in <module>
        from sqlalchemy.testing.suite import *
      File "build/bdist.linux-x86_64/egg/sqlalchemy/testing/suite/__init__.py", line 2, in <module>
      File "build/bdist.linux-x86_64/egg/sqlalchemy/testing/suite/test_dialect.py", line 11, in <module>
      File "build/bdist.linux-x86_64/egg/sqlalchemy/testing/suite/test_dialect.py", line 29, in ExceptionTest
    AttributeError: 'NoneType' object has no attribute 'duplicate_key_raises_integrity_error'
    

    can't run with py.test because you don't have a [db] section in your setup.cfg. The test suite should be set up as documented at: https://github.com/zzzeek/sqlalchemy/blob/master/README.unittests.rst

    I tried putting a standalone @Property in a local test/reqriements.py like you have above and no error is generated, it skips the JSON tests as expected.

  2. Patrick Buxton reporter

    Apologies, I gave you incorrect info. Once the repo is cloned, please git checkout the identity_column branch where I had made the changes to the setup.cfg Hopefully you'll then see the error I'm getting.

  3. Michael Bayer repo owner

    still cant reproduce anything, I can change the URL in setup.cfg to something else and am not getting that error. A bunch of tests fail because it's running against MySQL or SQLite, but nothing goes wrong with the JSON tests.

    setup.py seems to indicate I need pyhdb, but the test suite wants to import hdbcli and according to https://blogs.sap.com/2017/07/26/sap-hana-2.0-sps02-new-client-interface-features/ I have to go through an enormous proprietary registration / download / install process which appears to be windows-specific in any case to get to this hdbcli.

    is it possible you can try testing against some other database that I have access towards and then get this error to reproduce? e.g. like mysql+pymysql, or even just sqlite://.

    is it possible this is a windows-related issue?

  4. Patrick Buxton reporter

    I changed to point at my Postgresql/Greenplum server and it skips the tests just fine - change back to point at HANA and I get the error. That's all happening on Linux.

    It's very strange because I can get it to happen in debug locally and I can watch the error occur but it makes no sense really. I can explain what appears to happen even though I don't know why yet:

    In plugin_base._do_skips it calls _possible_configs_for_cls which looks at the config, sees the one entry, determines is skipped and removes it from the set and returns When plugin_base._do_skips then immediately tries to build the 'unsupported on any DB implementation' message, the call to config.Config.all_configs() returns None because the entry in the config is no longer there.

    I'm sorry, I thought you'd be able to see the error straight away - I'll have to debug further and see if I can determine what's going wrong myself.

  5. Patrick Buxton reporter

    OK, I got it, it's because the dialect doesn't provide a server_version_info and line 564 in plugin_base.py expects it. Is the server_version_info a definite requirement? do_skips.PNG

  6. Michael Bayer repo owner

    ah, well yes it's sort of a thing you should have, if you don't have one then return like, (0, 0, 0) but also I can certainly try to smooth that out on this end. wow it's just the stringification too, OK

  7. Michael Bayer repo owner

    Default server_version_info to (0, )

    Fixed a bug in the test suite where if an external dialect returned None for server_version_info, the exclusion logic would raise an AttributeError.

    Change-Id: I9124d3ac5484941081127274e6eb71f392fb94f7 Fixes: #4249

    → <<cset 29ce87273e3f>>

  8. Log in to comment