提交 03a90024 编写于 作者: L Lukáš Doktor

avocado.core.test: Check for basename length, not full path

only the basename of the `self.filename` has to be shorter than
maxsize-5, not the full path.

Also the IOError in selftest is rather misleading as it relates to
missing source file. Let's just check the path is correctly set and
additionally verify `_record_reference_*` is not crashing when filename
not associated.
Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>
上级 a951a6cd
......@@ -174,7 +174,8 @@ class Test(unittest.TestCase):
Returns the path to the directory that contains test data files
"""
# Maximal allowed file name length is 255
if self.filename is not None and len(self.filename) < 251:
if (self.filename is not None and
len(os.path.basename(self.filename)) < 251):
return self.filename + '.data'
else:
return None
......
......@@ -67,12 +67,14 @@ class TestClassTestUnit(unittest.TestCase):
self.assertEqual(os.path.basename(test.workdir),
os.path.basename(test.logdir))
flexmock(test)
test.should_receive('filename').and_return("a"*250)
self.assertEqual("a"*250 + ".data", test.datadir)
self.assertRaises(IOError, test._record_reference_stdout)
self.assertRaises(IOError, test._record_reference_stderr)
test.should_receive('filename').and_return(os.path.join(self.tmpdir,
"a"*250))
self.assertEqual(os.path.join(self.tmpdir, "a"*250 + ".data"),
test.datadir)
test.should_receive('filename').and_return("a"*251)
self.assertFalse(test.datadir)
test._record_reference_stdout # Should does nothing
test._record_reference_stderr # Should does nothing
test._record_reference_stdout()
test._record_reference_stderr()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册