Comments (4)
I'd think this is OK to leave as it is. A write to a non-binary filehandle in Python 3 results in an error:
Python 3.5.0 (default, Sep 23 2015, 04:42:00)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.72)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> byte_fractions = b'\xe2\x85\x93 \xe2\x85\x94 \xe2\x85\x95 \xe2\x85\x96'
>>> with open("/tmp/foo", 'w') as f:
... f.write(byte_fractions)
...
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
TypeError: write() argument must be str, not bytes
>>>
from pyfakefs.
Thank you for lending your expertise with binary files.
Indeed the test as it is now does not work with binary data in Python3. I was thinking that the test should be updated to write the file in mode 'wb' and read it in mode 'rb'.
When you do this, pyfakefs raises an exception, complaining that the data cannot be encoded as ascii. This is a bug in pyfakefs.
So I think that the solution it to change the modes in the test to 'wb' and 'rb', and then fixing pyfakes so that the test passes.
from pyfakefs.
OK, I see what you mean now. The changes I made in #60 should take care of the pyfakefs problem. I've just added the test case you suggested and another one to test Py3-specific behavior with writing in binary and reading in non-binary.
from pyfakefs.
Tests pass. Good thing I left it to the expert!
from pyfakefs.
Related Issues (20)
- pyfakefs is not suspended in reporting hooks HOT 6
- Shutting down patching during pytest report logging shall be more reliable
- `pyfakefs/tests/patched_packages_test.py::TestPatchedPackages::test_read_{csv,table}` fail if zstandard is used with CFFI backend, on Python 3.12 HOT 21
- Crash with pytest-subtests in Windows HOT 16
- Fake filesystem is paused after yielding in a fixture HOT 3
- FakeOsModule.walk return a (Path, list, list) generator instead of a (str, list, list) when a pathlib object is used as input HOT 5
- Running a sudo command in a fakefs reults in RecursionError HOT 3
- TypeError: unhashable type HOT 1
- Creating pytz `timezone` always returns `UnknownTimeZoneError` HOT 2
- Tests failing with pyfakefs and django after first test HOT 8
- python 3.9.18 + pyfakefs + pathlib + class variable: test failed HOT 4
- sdist is missing `tox.ini` HOT 3
- pyfakefs 5.3.4 + moto 4.2.13, test failed HOT 1
- Example usage docs using pathlib leads to errors HOT 2
- pyarrow.lib.ArrowKeyError: A type extension with name pandas.period already defined HOT 9
- Infinite loop with multiprocessing HOT 4
- EncodingWarnings raised (3) when using pyfakefs HOT 7
- Adding/removing directory entries does not respect directory ownership HOT 1
- Directory enumeration/search permissions mismatch Unix behavior HOT 3
- Wrong temporary directory created following a reset via `fs.os` HOT 4
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.
from pyfakefs.