diff --git a/sqlalchemy_utils/functions/__init__.py b/sqlalchemy_utils/functions/__init__.py index 4370e7d..7b25426 100644 --- a/sqlalchemy_utils/functions/__init__.py +++ b/sqlalchemy_utils/functions/__init__.py @@ -271,7 +271,7 @@ def create_mock_engine(bind, stream=None): text = re.sub(r'\n+', '\n', text) text = text.strip('\n').strip() - if stream.tell() > 0: + if not stream.seekable() or stream.tell() > 0: stream.write('\n') stream.write(text)