Comments (4)
Released fix for this in 2.6.1. Thanks for the report!
from pytest-mock-resources.
Thank you, @DanCardin, for the quick response!
However, I noticed we still have a problem when trying to use the same example:
When using db = create_redshift_fixture(session=True)
, it works fine, nonetheless, when using db = create_redshift_fixture(session=False)
, the following error appears:
============================================================ test session starts =============================================================
platform linux -- Python 3.9.12, pytest-6.2.5, py-1.11.0, pluggy-1.0.0 -- /home/zanini/repo/RecSys/.venv/bin/python
cachedir: .pytest_cache
rootdir: /home/zanini/repo/RecSys, configfile: tox.ini
plugins: mock-resources-2.6.1, mock-3.10.0, xdist-1.34.0, postgresql-4.1.1, cov-2.12.1, forked-1.4.0, anyio-3.6.2
collected 1 item
tests/test_temp.py::test_sql_sum === <class 'sqlalchemy.engine.base.Engine'>
FAILED
================================================================== FAILURES ==================================================================
________________________________________________________________ test_sql_sum ________________________________________________________________
db = Engine(postgresql+psycopg2://user:***@localhost:5532/pytest_mock_resource_db_1?sslmode=disable)
def test_sql_sum(db):
> sql_sum(db)
tests/test_temp.py:14:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
util/temp.py:5: in sql_sum
redshift_conn.execute("CREATE TEMP TABLE mytemp(c INT);")
<string>:2: in execute
???
../.venv/lib/python3.9/site-packages/sqlalchemy/util/deprecations.py:402: in warned
return fn(*args, **kwargs)
../.venv/lib/python3.9/site-packages/sqlalchemy/engine/base.py:3257: in execute
return connection.execute(statement, *multiparams, **params)
../.venv/lib/python3.9/site-packages/sqlalchemy/engine/base.py:1365: in execute
return self._exec_driver_sql(
../.venv/lib/python3.9/site-packages/sqlalchemy/engine/base.py:1669: in _exec_driver_sql
ret = self._execute_context(
../.venv/lib/python3.9/site-packages/sqlalchemy/engine/base.py:1842: in _execute_context
statement, parameters = fn(
../.venv/lib/python3.9/site-packages/pytest_mock_resources/patch/redshift/sqlalchemy.py:54: in receive_before_cursor_execute
normalized_statement = strip(statement).lower()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
input_string = <sqlalchemy.sql.elements.TextClause object at 0x7fd3db9461f0>
def strip(input_string):
"""Strip trailing whitespace, single/double quotes."""
> return input_string.strip().rstrip(";").strip('"').strip("'")
E AttributeError: 'TextClause' object has no attribute 'strip'
../.venv/lib/python3.9/site-packages/pytest_mock_resources/patch/redshift/mock_s3_copy.py:189: AttributeError
========================================================== short test summary info ===========================================================
FAILED tests/test_temp.py::test_sql_sum - AttributeError: 'TextClause' object has no attribute 'strip'
============================================================= 1 failed in 8.57s ==============================================================
I noticed the error I reported previously was also exclusive from the session=True
case.
from pytest-mock-resources.
@pliniozanini I dont suppose you'd mind checking out this branch #172 and testing to see if it solves your issue? I added tests of both sides and now don't see either issue
from pytest-mock-resources.
Just released 2.6.3 which hopefully fixes both directions of issue? We at least have some tests in either direction, so it should be a net-different issue if you're still encountering problems hopefully.
Feel free to keep commenting here if you do, and i can re-open again! Thanks!
from pytest-mock-resources.
Related Issues (20)
- Make use of built-in sqlite json and strict support
- Add support for MySQL 8 HOT 5
- Exception trying to unlink pmr.json when when ran with --pmr-multiprocess-safe HOT 3
- Add Redis the CLI HOT 3
- $round operation for MongoDB HOT 2
- SQLAlchemy 2.0 Support HOT 7
- Certain schema DDL is issued only once per test but should be once per metadata
- Dependabot warning for docker subdependency HOT 3
- [Support] Tests hang when using fixture HOT 7
- Error opening connection from redshift_connector HOT 5
- Add in Left/Right UDF's for Redshift HOT 2
- Support SQLAlchemy 1.4 future mode HOT 4
- Dependency on attrs package should be explicit HOT 3
- get_sqlalchemy_engine() not compatible with asyncpg HOT 5
- Allow defining run_args HOT 1
- Getting errors when using `create_redis_fixture` HOT 3
- Missing delete function in redis fixture HOT 1
- Redis Container dont start after update Docker for Desktop on windows. HOT 6
- `create_postgres_fixture` doesn't clean up after running tests. HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.