Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Readme
A better mock for file I/O.
$ pip install mock-open
MockOpen
The MockOpen
class should work as a stand-in replacement for mock.mock_open
with
some added features (though it tries to conform to how the builtin open
works where the two
differ):
Multiple file support, including a mapping-like access to file mocks by path:
from mock_open import MockOpen
mock_open = MockOpen()
mock_open["/path/to/file"].read_data = "Data from a fake file-like object"
mock_open["/path/to/bad_file"].side_effect = IOError()
You can also configure behavior via the regular mock
library API:
mock_open = MockOpen()
mock_open.return_value.write.side_effect = IOError()
Persistent file contents between calls to open
:
with patch("builtins.open", MockOpen()):
with open("/path/to/file", "w") as handle:
handle.write("Some text")
with open("/path/to/file", "r") as handle:
assert "Some text" == handle.read()
All the regular file operations: read
, readline
, readlines
, write
, writelines
, seek
,
tell
.
This library uses modified versions of tests from the CPython source code as part of its test suite. The original tests are licensed under the PSF license agreement and are copyright of the Python Software Foundation.
FAQs
A better mock for file I/O
We found that mock-open demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.