metagriffin / fso Goto Github PK
View Code? Open in Web Editor NEWFile System Overlay - filesystem layering for unit testing.
License: GNU General Public License v3.0
File System Overlay - filesystem layering for unit testing.
License: GNU General Public License v3.0
When opening a file with or without fso the file name property is stored differently:
import fso
with open('/tmp/test.txt', 'w') as file:
print file
print file.name # <----
with fso.push() as overlay:
with open('/tmp/test.txt', 'w') as file:
print file
print file.path # <----
In Ubuntu 16.4 returns:
<open file '/tmp/test.txt', mode 'w' at 0x7f09d6b61540>
/tmp/test.txt
<fso.filesystemoverlay.OverlayFileStream instance at 0x7f09d6a295a8>
/tmp/test.txt
In MacOS High Sierra returns:
<open file '/tmp/test.txt', mode 'w' at 0x10ae3f390>
/tmp/test.txt
<fso.filesystemoverlay.OverlayFileStream instance at 0x10ae5bd40>
/private/tmp/test.txt
Without fso we can use file.name
. Can you make fso also allow for the name
property? In addition can you make sure the paths match in macos?
Your library is very nice, thank you!
Kind regards.
I'm not 100% convinced that this is an issue with fso, but it looks like a call to tempfile.mkdtemp
will fail if the fso is active and tempfile.mkdtemp
hasn't been called.
simplest repro for me:
[ted@localhost]$ venv/bin/python
>>> import tempfile, fso
>>> fso.push()
<fso.filesystemoverlay.FileSystemOverlay object at 0x7f7279b26490>
>>> tempfile.mkdtemp()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python2.7/tempfile.py", line 331, in mkdtemp
dir = gettempdir()
File "/usr/lib64/python2.7/tempfile.py", line 275, in gettempdir
tempdir = _get_default_tempdir()
File "/usr/lib64/python2.7/tempfile.py", line 200, in _get_default_tempdir
with _io.open(fd, 'wb', closefd=False) as fp:
TypeError: coercing to Unicode: need string or buffer, int found
And all subsequent calls while the fso remains active will fail.
But when I went to confirm that mkdtemp was working at all I found this:
[ted@localhost]$ venv/bin/python
>>> import tempfile, fso
>>> tempfile.mkdtemp()
'/tmp/tmpPPE6VM'
>>> fso.push()
<fso.filesystemoverlay.FileSystemOverlay object at 0x7f219ac07490>
>>> tempfile.mkdtemp()
'/tmp/tmpWrHhoT'
I can even fso.push()
, see it fail, fso.pop()
, see it succeed, fso.push()
, see it continue succeeding.
Started to look at the tempfile code to see if I could track this down, but don't have the time at this moment, and have a workaround ^.
Even a confirmation that this couldn't possibly be fso's fault would be helpful. Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.