Mockio is a mini helper that allows you to mock `open` method with StringIO.
Python
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
mockio
.gitignore
README.md
requirements.pip
setup.py
tests.py

README.md

Mockio

Mockio is a mini helper that allows you to mock open method with StringIO.

Example:

class TestNginxParser(unittest.TestCase):
    files = {
        "/etc/nginx/sites-enabled/foo.conf": "server foo {}",
        "/etc/nginx/sites-enabled/bar.conf": ""
    }

    @mockio(files)
    def test_read(self):
        conf = open("/etc/nginx/sites-enabled/foo.conf").read()
        self.assertEqual(conf, "server foo {}")
        # ...