Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when testing dialect with an exclusion #4249

Closed
sqlalchemy-bot opened this issue May 10, 2018 · 15 comments
Closed

Error when testing dialect with an exclusion #4249

sqlalchemy-bot opened this issue May 10, 2018 · 15 comments
Labels
bug Something isn't working tests
Milestone

Comments

@sqlalchemy-bot
Copy link
Collaborator

Migrated issue, originally created by Patrick Buxton

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. (MonetDB/sqlalchemy-monetdb#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.

@sqlalchemy-bot
Copy link
Collaborator Author

Changes by Patrick Buxton:

  • edited description

@sqlalchemy-bot
Copy link
Collaborator Author

Michael Bayer (@zzzeek) wrote:

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.

@sqlalchemy-bot
Copy link
Collaborator Author

Michael Bayer (@zzzeek) wrote:

oh sorry, I meant: https://github.com/zzzeek/sqlalchemy/blob/master/README.dialects.rst

@sqlalchemy-bot
Copy link
Collaborator Author

Patrick Buxton wrote:

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.

@sqlalchemy-bot
Copy link
Collaborator Author

Changes by Patrick Buxton:

  • edited description

@sqlalchemy-bot
Copy link
Collaborator Author

Michael Bayer (@zzzeek) wrote:

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?

@sqlalchemy-bot
Copy link
Collaborator Author

Patrick Buxton wrote:

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.

@sqlalchemy-bot
Copy link
Collaborator Author

Patrick Buxton wrote:

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

@sqlalchemy-bot
Copy link
Collaborator Author

Michael Bayer (@zzzeek) wrote:

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

@sqlalchemy-bot
Copy link
Collaborator Author

Michael Bayer (@zzzeek) wrote:

easy to reproduce, thanks!

@sqlalchemy-bot
Copy link
Collaborator Author

Michael Bayer (@zzzeek) wrote:

here we are:

https://gerrit.sqlalchemy.org/#/q/I9124d3ac5484941081127274e6eb71f392fb94f7

just return an empty tuple for now instead of None

@sqlalchemy-bot
Copy link
Collaborator Author

Changes by Michael Bayer (@zzzeek):

  • set milestone to "1.2.x"

@sqlalchemy-bot
Copy link
Collaborator Author

Michael Bayer (@zzzeek) wrote:

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
(cherry picked from commit 29ce872)

97e828f

@sqlalchemy-bot
Copy link
Collaborator Author

Changes by Michael Bayer (@zzzeek):

  • changed status to closed

@sqlalchemy-bot
Copy link
Collaborator Author

Michael Bayer (@zzzeek) wrote:

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

29ce872

@sqlalchemy-bot sqlalchemy-bot added bug Something isn't working tests labels Nov 27, 2018
@sqlalchemy-bot sqlalchemy-bot added this to the 1.2.x milestone Nov 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working tests
Projects
None yet
Development

No branches or pull requests

1 participant