Skip to content
Snippets Groups Projects
Commit ad6a0302 authored by vlorentz's avatar vlorentz
Browse files

Fix tests of special devices.

Regular files were created, as the 'mode' argument of os.mknod was missing.
However, creating devices requires root; so we can't reasonably do that in
tests.

Instead, we're using /dev/null instead of creating one.
And while we're at it, let's also use /dev/zero (which, if not handled
properly, will result in an infinite read).
parent 4c070f98
No related branches found
Tags v0.0.19
No related merge requests found
......@@ -102,7 +102,6 @@ class DataMixin:
self.specials = {
b'fifo': os.mkfifo,
b'devnull': lambda path: os.mknod(path, device=os.makedev(1, 3)),
}
self.empty_content = {
......@@ -507,7 +506,7 @@ class FileToContent(DataMixin, unittest.TestCase):
self.make_symlinks(self.tmpdir_name)
self.make_specials(self.tmpdir_name)
def test_file_to_content(self):
def test_symlink_to_content(self):
# Check whether loading the data works
for data in [True, False]:
for filename, symlink in self.symlinks.items():
......@@ -515,16 +514,25 @@ class FileToContent(DataMixin, unittest.TestCase):
conv_content = Content.from_file(path=path, data=data)
self.assertContentEqual(conv_content, symlink, check_data=data)
def test_file_to_content(self):
for data in [True, False]:
for filename, content in self.contents.items():
path = os.path.join(self.tmpdir_name, filename)
conv_content = Content.from_file(path=path, data=data)
self.assertContentEqual(conv_content, content, check_data=data)
def test_special_to_content(self):
for data in [True, False]:
for filename in self.specials:
path = os.path.join(self.tmpdir_name, filename)
conv_content = Content.from_file(path=path, data=data)
self.assertContentEqual(conv_content, self.empty_content)
for path in ['/dev/null', '/dev/zero']:
path = os.path.join(self.tmpdir_name, filename)
conv_content = Content.from_file(path=path, data=data)
self.assertContentEqual(conv_content, self.empty_content)
def test_symlink_max_length(self):
for max_content_length in [4, 10]:
for filename, symlink in self.symlinks.items():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment