-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
pynamodb startswith works with moto but not under pytest #1996
Comments
Can you please add the code needed to reproduce this to the issue text? Thanks |
Also running into this issue. Here's a small example (using pynamodb for table declaration)
Python 3.7.3 |
I think that might be the same as #416 Can you try activating the mock in your setUp with a manual mock. |
Like this? (I get the keyerror with the startswith, but doing a plain query works fine)
|
Can you print the traceback for the KeyError? It sounds like it might be a different issue, but at least the mock is being activated. |
(sorry, I've not been getting notifications of this thread, so my responses have been a bit delayed) |
Does the traceback go deeper than that? That particular line in responses.py seems unusual to throw a KeyError. |
Nope, sorry.
is the last thing returned. |
Can you put a pdb inside of dynamodb2/responses.py:query and step through it until the exception happens? I'm trying to isolate where this is coming from and I'm struggling to reproduce it. |
...
...
Looks like it was expecting the Doing some more digging (eg comparing to the tests in test_dynamodb2/test_dynamodb_table_with_range_key.py), and in my test case, there ends up being a space after "begins_with".... whereas
vs
|
Ah, got it. So it sounds like we are being too strict in what we are parsing. I'm going to set this as a feature to make the parsing be looser. |
I have this problem too, any news here? |
A query fails if it has a space between `begins_with` and `(`, for example: ```begins_with (getmoto#1, :1)``` Fix getmoto#1996
Same issue, same lines, except that in my case, I'm querying a GSI.
|
Hi @klawson, might be worth upgrading moto to the latest version. |
affirmative. Updating to 2.x resolved this issue. Thank you! |
environment:
windows 10 64 bit python 3.6
see zip for code to reproduce issue.
do a virtualenv and install requirements. model, test_model and test_dynamodb contain the same code, except that the 2nd and 3rd are wrapped in order for pytest to work. The 3rd, doesn't use moto, but a dynamodb local listening on localhost 8000.
If you execute
python model.py,
everything works correctly.
if, in the test dir, you execute
pytest
the 'query' call using moto mock which uses the startswith, fails with
============================= test session starts =============================
platform win32 -- Python 3.6.4, pytest-4.0.2, py-1.7.0, pluggy-0.8.0
rootdir: C:\Users\FIM514, inifile: pytest.ini
collected 1 item
test_model.py F [100%]
================================== FAILURES ===================================
______________________________ MyTest.test_main _______________________________
self = <test.test_model.MyTest testMethod=test_main>
test_model.py:24:
..\envs\temp\lib\site-packages\pynamodb\pagination.py:173: in next
self._get_next_page()
..\envs\temp\lib\site-packages\pynamodb\pagination.py:158: in _get_next_page
page = next(self.page_iter)
..\envs\temp\lib\site-packages\pynamodb\pagination.py:103: in next
page = self._operation(*self._args, **self._kwargs)
..\envs\temp\lib\site-packages\pynamodb\connection\table.py:257: in query
select=select)
..\envs\temp\lib\site-packages\pynamodb\connection\base.py:1409: in query
return self.dispatch(QUERY, operation_kwargs)
..\envs\temp\lib\site-packages\pynamodb\connection\base.py:313: in dispatch
data = self._make_api_call(operation_name, operation_kwargs)
..\envs\temp\lib\site-packages\pynamodb\connection\base.py:362: in _make_api_call
proxies=proxies,
..\envs\temp\lib\site-packages\requests\sessions.py:646: in send
r = adapter.send(request, **kwargs)
..\envs\temp\lib\site-packages\responses.py:622: in unbound_on_send
return self._on_request(adapter, request, *a, **kwargs)
..\envs\temp\lib\site-packages\responses.py:600: in _on_request
response = adapter.build_response(request, match.get_response(request))
..\envs\temp\lib\site-packages\moto\core\models.py:151: in get_response
result = self.callback(request)
..\envs\temp\lib\site-packages\moto\core\utils.py:173: in call
result = self.callback(request, request.url, request.headers)
..\envs\temp\lib\site-packages\moto\core\responses.py:117: in dispatch
return cls()._dispatch(*args, **kwargs)
..\envs\temp\lib\site-packages\moto\core\responses.py:200: in _dispatch
return self.call_action()
..\envs\temp\lib\site-packages\moto\core\utils.py:264: in _wrapper
response = f(*args, **kwargs)
..\envs\temp\lib\site-packages\moto\dynamodb2\responses.py:64: in call_action
response = getattr(self, endpoint)()
self = <moto.dynamodb2.responses.DynamoHandler object at 0x000002DC6554C6D8>
E KeyError: '(#1,'
..\envs\temp\lib\site-packages\moto\dynamodb2\responses.py:382: KeyError
---------------------------- Captured stdout call -----------------------------
table<1, 2>
the query call in test_dynamodb, once I start dynamodb-local so I don't use moto mock, works correctly.
I expect the 2nd case to be working correctly too.
test.zip
The text was updated successfully, but these errors were encountered: