pauldex / sqlalchemy-firebird

A Firebird dialect for SQLAlchemy using the firebird-driver and/or fdb python Firebird driver
MIT License
22 stars 15 forks source link

[QUESTION] How can be run tests? #57

Closed LukeSavefrogs closed 9 months ago

LukeSavefrogs commented 1 year ago

Hi @pauldex, I wanted to try to contribute to your project but something is not clear to me...

I cloned and installed the project via pip install -r .\requirements_dev.txt but when I run pytest it fails with to the following stacktrace:

================================== sqlalchemy installation ==================================
SQLAlchemy 2.0.20 (user site loaded)
Path: D:\Progetti\sqlalchemy-firebird\.venv\lib\site-packages\sqlalchemy\__init__.py
compiled extension enabled, e.g. D:\Progetti\sqlalchemy-firebird\.venv\lib\site-packages\sqlalchemy\cyextension\util.cp39-win_amd64.pyd
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "D:\Progetti\sqlalchemy-firebird\.venv\lib\site-packages\_pytest\main.py", line 269, in wrap_session
INTERNALERROR>     config.hook.pytest_sessionstart(session=session)
INTERNALERROR>   File "D:\Progetti\sqlalchemy-firebird\.venv\lib\site-packages\pluggy\_hooks.py", line 493, in __call__
INTERNALERROR>     return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)     
INTERNALERROR>   File "D:\Progetti\sqlalchemy-firebird\.venv\lib\site-packages\pluggy\_manager.py", line 115, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)       
INTERNALERROR>   File "D:\Progetti\sqlalchemy-firebird\.venv\lib\site-packages\pluggy\_callers.py", line 152, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "D:\Progetti\sqlalchemy-firebird\.venv\lib\site-packages\pluggy\_result.py", line 114, in get_result
INTERNALERROR>     raise exc.with_traceback(exc.__traceback__)
INTERNALERROR>   File "D:\Progetti\sqlalchemy-firebird\.venv\lib\site-packages\pluggy\_callers.py", line 77, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "D:\Progetti\sqlalchemy-firebird\.venv\lib\site-packages\sqlalchemy\testing\plugin\pytestplugin.py", line 165, in pytest_sessionstart
INTERNALERROR>     asyncio._assume_async(plugin_base.post_begin)
INTERNALERROR>   File "D:\Progetti\sqlalchemy-firebird\.venv\lib\site-packages\sqlalchemy\testing\asyncio.py", line 53, in _assume_async
INTERNALERROR>     return _util_async_run(fn, *args, **kwargs)
INTERNALERROR>   File "D:\Progetti\sqlalchemy-firebird\.venv\lib\site-packages\sqlalchemy\util\_concurrency_py3k.py", line 242, in _util_async_run
INTERNALERROR>     return loop.run_until_complete(greenlet_spawn(fn, *args, **kwargs))        
INTERNALERROR>   File "C:\Python39\lib\asyncio\base_events.py", line 642, in run_until_complete
INTERNALERROR>     return future.result()
INTERNALERROR>   File "D:\Progetti\sqlalchemy-firebird\.venv\lib\site-packages\sqlalchemy\util\_concurrency_py3k.py", line 179, in greenlet_spawn
INTERNALERROR>     result = context.switch(*args, **kwargs)
INTERNALERROR>   File "D:\Progetti\sqlalchemy-firebird\.venv\lib\site-packages\sqlalchemy\testing\plugin\plugin_base.py", line 295, in post_begin
INTERNALERROR>     fn(options, file_config)
INTERNALERROR>   File "D:\Progetti\sqlalchemy-firebird\.venv\lib\site-packages\sqlalchemy\testing\plugin\plugin_base.py", line 443, in _engine_uri
INTERNALERROR>     db_urls.append(file_config.get("db", "default"))
INTERNALERROR>   File "C:\Python39\lib\configparser.py", line 781, in get
INTERNALERROR>     d = self._unify_values(section, vars)
INTERNALERROR>   File "C:\Python39\lib\configparser.py", line 1152, in _unify_values
INTERNALERROR>     raise NoSectionError(section) from None
INTERNALERROR> configparser.NoSectionError: No section: 'db'

As far as I understand, this is caused by SqlAlchemy testing suite which does not find any db section in the setup.cfg or test.cfg files.

Did you configure something that is only on your local workstation or am I missing something?

pauldex commented 1 year ago

Hi, thanks for looking into contributing to our project.

No, you're not missing anything. The checked in code (1 Oct 23, version 2.0.1) will output the error you report when running pytest without additional parameters.

I run the tests by passing a -db or -dburi parameter on the pytest command line. For example, using an embedded Firebird server on Windows: pytest --dburi="firebird+firebird://sysdba@/E:/Project/.data/fb4/sqla_test.fdb?charset=UTF8&fb_client_library=E:/Project/.data/fb40/fbclient.dll"

I will update the source to include a clean exit for your use case.

fdcastel commented 9 months ago

This really needs an improvement. Current codebase is very unfriendly for new developers.

I spent months working on this code some months ago. And today it took me some good time to grasp everything again 😉.

I will work on some PRs for this on next days.

@pauldex Does your primary development machine for this project runs Windows?

fdcastel commented 9 months ago

For reference: There is no requirements_dev.txt anymore.

To install a development environment use:

python -m venv .venv
.venv/Scripts/activate
pip install .[dev]
fdcastel commented 9 months ago

@pauldex @LukeSavefrogs please give a look at PR #60.

pauldex commented 9 months ago

@fdcastel, yes I use Windows as my primary development machine.

fdcastel commented 9 months ago

Nice. So please take a look at this commit when you can.

Also, #64! 😄