-
-
Notifications
You must be signed in to change notification settings - Fork 380
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
Using moto 1.1.25 with smart_open raises ValueError: file descriptor cannot be a negative integer (-1) #160
Comments
@matt-pazien I tried to reproduce, works fine for
import unittest
import boto
import smart_open
from moto import mock_s3_deprecated
class TestSimpleSmartOpen(unittest.TestCase):
@mock_s3_deprecated
def test_write_encoding(self):
conn = boto.connect_s3()
conn.create_bucket('bucket')
key = "s3://bucket/key.txt"
text = u'Hello there'
with smart_open.smart_open(key, 'w', encoding='utf-8') as fout:
fout.write(text)
with smart_open.smart_open(key, encoding='utf-8') as fin:
actual = fin.read()
self.assertEqual(text, actual)
if __name__ == '__main__':
unittest.main() @mpenkov wdyt about this problem? |
We pin the moto version for a reason: newer versions of moto treat boto and boto3 mocks differently. Our tests are older and use boto to mock the data, but our newer implementation uses boto3 to read the mocked data. Therefore, we expect our tests not to work under newer versions of moto. In order for them to work, we'd have to move to boto3 entirely and rewrite our tests. That is issue #43. I recommend we close the current issue as a duplicate, and add update moto to the scope of #43. |
@mpenkov I understand - but it's harder to integrate smart_open into other projects if we want to test it ourselves with moto. |
@matt-pazien I understand. We will work on this issue as part of #43. Unfortunately, dealing with this change of behavior between old & new moto versions will require some effort. |
Smart open uses an older version of moto to test - using a later release causes test issues.
Creating a simple unit test case using smart_open
smart-open==1.5.5
moto==1.1.25
This raises an error
The text was updated successfully, but these errors were encountered: