Commit c561df1c by Peter Weidenbach

test coverage increased

parent 4e061dde
# general things to ignore
.project
.pydevproject
.coverage
build/
dist/
*.egg-info/
......
[pytest]
addopts = --pep8 -v
addopts = --pep8 --cov=./ -v
pep8ignore =
*.py E501
read_test
\ No newline at end of file
......@@ -30,6 +30,10 @@ class Test_FailSafeFileOperations(unittest.TestCase):
none_existing_file_path = os.path.join(self.get_directory_of_current_file(), "data", "none_existing_file")
file_binary = get_binary_from_file(none_existing_file_path)
self.assertEqual(file_binary, b'', "content not correct")
# Test link
link_path = os.path.join(self.get_directory_of_current_file(), "data", "link_test")
file_binary = get_binary_from_file(link_path)
assert file_binary == 'symbolic link -> read_test'
def test_fail_safe_read_file_string_list(self):
test_file_path = os.path.join(self.get_directory_of_current_file(), "data", "multiline_test.txt")
......@@ -94,7 +98,8 @@ class Test_FailSafeFileOperations(unittest.TestCase):
result = get_files_in_dir(test_dir_path)
self.assertIn(os.path.join(test_dir_path, "read_test"), result, "file in root folder not found")
self.assertIn(os.path.join(test_dir_path, "test_folder/generic_test_file"), result, "file in sub folder not found")
self.assertEqual(len(result), 3, "number of found files not correct")
print(result)
self.assertEqual(len(result), 4, "number of found files not correct")
def test_get_files_in_dir_error(self):
result = get_files_in_dir("/none_existing/dir")
......
import unittest
from common_helper_files import human_readable_file_size
import pytest
import os
class Test_file_functions(unittest.TestCase):
from common_helper_files import human_readable_file_size, read_in_chunks, get_directory_for_filename
def test_human_readable_file_size(self):
self.assertEqual(human_readable_file_size(1024), '1.00 KiB')
self.assertEqual(human_readable_file_size(5000), '4.88 KiB')
TEST_DATA_DIR = os.path.join(get_directory_for_filename(__file__), 'data')
@pytest.mark.parametrize('input_data, expected', [
(1000, '1000.00 Byte'),
(1024, '1.00 KiB'),
(1024 * 1024, '1.00 MiB'),
(1234.1234, '1.21 KiB'),
])
def test_human_readable_file_size(input_data, expected):
assert human_readable_file_size(input_data) == expected
def test_read_in_chunks():
fp = open(TEST_DATA_DIR + '/read_test', 'rb')
test_buffer = b''
for chunk in read_in_chunks(fp):
test_buffer += chunk
assert test_buffer == b'this is a test'
from common_helper_files import get_version_string_from_git
def test_get_version_string_from_git():
result = get_version_string_from_git('.')
assert type(result) == str
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment