Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c2c2d4c

Browse files
TestOsOpsCommon is updated
New tests: - test_read_binary__spec__negative_offset - test_get_file_size
1 parent 75b0804 commit c2c2d4c

File tree

3 files changed

+26
-46
lines changed

3 files changed

+26
-46
lines changed

tests/test_local.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -114,29 +114,6 @@ def test_read_binary__spec__unk_file(self):
114114
match=re.escape("[Errno 2] No such file or directory: '/dummy'")):
115115
self.operations.read_binary("/dummy", 0)
116116

117-
def test_read_binary__spec__negative_offset(self):
118-
"""
119-
Test LocalOperations::read_binary with negative offset.
120-
"""
121-
122-
with pytest.raises(
123-
ValueError,
124-
match=re.escape("Negative 'offset' is not supported.")):
125-
self.operations.read_binary(__file__, -1)
126-
127-
def test_get_file_size(self):
128-
"""
129-
Test LocalOperations::get_file_size.
130-
"""
131-
filename = __file__ # current file
132-
133-
sz0 = os.path.getsize(filename)
134-
assert type(sz0) == int # noqa: E721
135-
136-
sz1 = self.operations.get_file_size(filename)
137-
assert type(sz1) == int # noqa: E721
138-
assert sz1 == sz0
139-
140117
def test_get_file_size__unk_file(self):
141118
"""
142119
Test LocalOperations::get_file_size.

tests/test_os_ops_common.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,32 @@ def test_read_binary__spec(self, os_ops: OsOperations):
120120
assert type(response5) == bytes # noqa: E721
121121
assert len(response5) == 0
122122

123+
def test_read_binary__spec__negative_offset(self, os_ops: OsOperations):
124+
"""
125+
Test RemoteOperations::read_binary with negative offset.
126+
"""
127+
assert isinstance(os_ops, OsOperations)
128+
129+
with pytest.raises(
130+
ValueError,
131+
match=re.escape("Negative 'offset' is not supported.")):
132+
os_ops.read_binary(__file__, -1)
133+
134+
def test_get_file_size(self, os_ops: OsOperations):
135+
"""
136+
Test RemoteOperations::get_file_size.
137+
"""
138+
assert isinstance(os_ops, OsOperations)
139+
140+
filename = __file__ # current file
141+
142+
sz0 = os.path.getsize(filename)
143+
assert type(sz0) == int # noqa: E721
144+
145+
sz1 = os_ops.get_file_size(filename)
146+
assert type(sz1) == int # noqa: E721
147+
assert sz1 == sz0
148+
123149
def test_isfile_true(self, os_ops: OsOperations):
124150
"""
125151
Test isfile for an existing file.

tests/test_remote.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -320,29 +320,6 @@ def test_read_binary__spec__unk_file(self):
320320
assert "No such file or directory" in str(x.value)
321321
assert "/dummy" in str(x.value)
322322

323-
def test_read_binary__spec__negative_offset(self):
324-
"""
325-
Test RemoteOperations::read_binary with negative offset.
326-
"""
327-
328-
with pytest.raises(
329-
ValueError,
330-
match=re.escape("Negative 'offset' is not supported.")):
331-
self.operations.read_binary(__file__, -1)
332-
333-
def test_get_file_size(self):
334-
"""
335-
Test RemoteOperations::get_file_size.
336-
"""
337-
filename = __file__ # current file
338-
339-
sz0 = os.path.getsize(filename)
340-
assert type(sz0) == int # noqa: E721
341-
342-
sz1 = self.operations.get_file_size(filename)
343-
assert type(sz1) == int # noqa: E721
344-
assert sz1 == sz0
345-
346323
def test_get_file_size__unk_file(self):
347324
"""
348325
Test RemoteOperations::get_file_size.

0 commit comments

Comments
 (0)