提交 a1db8fe8 编写于 作者: N Nicolas Hennion

Add unitest script

上级 ae12132b
Version 1.4.1
=============
* Per core CPU stats (if space is available)
Version 1.4
===========
......
#!/usr/bin/env python
#
# Glances unitary test
#
# Syntax:
# ./unitest.py
#
# or ./unitest.py -v
#
# Copyright (C) Nicolargo 2012 <nicolas@nicolargo.com>
#
# under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Glances is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.";
#
import unittest
import glances
import multiprocessing
class TestGlancesStat(unittest.TestCase):
def setUp(self):
self.stats = glances.glancesStats()
self.stats.update()
def test_Glances_getCore(self):
self.assertEqual(self.stats.getCore(), multiprocessing.cpu_count())
def test_Glances_getCpu(self):
self.stats.update()
self.assertEqual(len(self.stats.getCpu()), 4)
def test_Glances_getPerCpu(self):
self.stats.update()
self.assertEqual(len(self.stats.getPerCpu()), multiprocessing.cpu_count())
def test_Glances_getMem(self):
self.stats.update()
self.assertTrue(len(self.stats.getMem()) > 2)
def test_Glances_getMemSwap(self):
self.stats.update()
self.assertTrue(len(self.stats.getMemSwap()) > 2)
if __name__ == '__main__':
unittest.main()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册