Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test end-of-space errors #28

Open
giovannipizzi opened this issue Jun 19, 2020 · 1 comment
Open

Test end-of-space errors #28

giovannipizzi opened this issue Jun 19, 2020 · 1 comment

Comments

@giovannipizzi
Copy link
Member

One of the most common errors that users will face is a full disk. We need to assess that the implementation is at least robust against these errors.

We should check if using pyfakefs can help in testing these cases, and add tests for those.

@giovannipizzi
Copy link
Member Author

An example pytest with pyfakefs:

import errno
import os
import pytest

## Note: you need to install pyfakefs==4.0.2 to make the 'fs' fixture available

def test_fakefs(fs):  # pytest: disable=invalid-name
    # "fs" is the reference to the fake file system
    fs.set_disk_usage(100) # bytes
    fname = '/var/data/xx1.txt'
    fs.create_file(fname)
    assert os.path.exists(fname)
    with open(fname, 'w') as fhandle:
        fhandle.write("a" * 80)

    with pytest.raises(OSError) as excinfo:
        with open(fname, 'w') as fhandle:
            fhandle.write("a" * 120)

    print(dir(excinfo))
    assert excinfo.value.errno == errno.ENOSPC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant