/usr/share/pyshared/guiqwt/tests/styles.py is in python-guiqwt 2.3.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | # -*- coding: utf-8 -*-
#
# Copyright © 2009-2010 CEA
# Pierre Raybaut
# Licensed under the terms of the CECILL License
# (see guiqwt/__init__.py for details)
"""Styles unit tests"""
SHOW = False # Do not show test in GUI-based test launcher
import unittest
from guidata.qt.QtCore import Qt, QSize
from guidata.qt.QtGui import QPen, QBrush
from guiqwt.transitional import QwtSymbol
from guidata.config import UserConfig, _
from guiqwt.styles import SymbolParam, LineStyleParam
CONF = UserConfig({})
CONF.set_application('guidata', version='0.0.0', load=False )
class TestSymbol(unittest.TestCase):
def test_default(self):
sym = SymbolParam(_("Symbol"))
_obj = sym.build_symbol()
def test_update(self):
obj = QwtSymbol( QwtSymbol.Rect, QBrush(Qt.black), QPen(Qt.yellow),
QSize(3, 3) )
sym = SymbolParam(_("Symbol"))
sym.update_param( obj )
self.assertEqual(sym.marker, "Rect")
self.assertEqual(sym.size, 3)
self.assertEqual(sym.edgecolor, "#ffff00")
self.assertEqual(sym.facecolor, "#000000")
def test_saveconfig(self):
sym = SymbolParam(_("Symbol"))
sym.write_config(CONF, "sym", "" )
sym = SymbolParam(_("Symbol"))
sym.read_config(CONF, "sym", "" )
def test_changeconfig(self):
obj = QwtSymbol( QwtSymbol.Rect, QBrush(Qt.black), QPen(Qt.yellow),
QSize(3, 3) )
sym = SymbolParam(_("Symbol"))
sym.update_param( obj )
sym.write_config(CONF, "sym", "" )
sym = SymbolParam(_("Symbol"))
sym.read_config(CONF, "sym", "" )
self.assertEqual(sym.marker, "Rect")
self.assertEqual(sym.size, 3)
self.assertEqual(sym.edgecolor, "#ffff00")
self.assertEqual(sym.facecolor, "#000000")
sym.build_symbol()
class TestLineStyle(unittest.TestCase):
def test_default(self):
ls = LineStyleParam(_("Line style"))
_obj = ls.build_pen()
def test_update(self):
obj = QPen( Qt.red, 2, Qt.SolidLine )
ls = LineStyleParam(_("Line style"))
ls.update_param( obj )
self.assertEqual(ls.width, 2)
self.assertEqual(ls.style, "SolidLine")
self.assertEqual(ls.color, "#ff0000")
def test_saveconfig(self):
ls = LineStyleParam(_("Line style"))
ls.write_config(CONF, "ls", "" )
ls = LineStyleParam(_("Line style"))
ls.read_config(CONF, "ls", "" )
def test_changeconfig(self):
obj = QPen( Qt.red, 2, Qt.SolidLine )
ls = LineStyleParam(_("Line style"))
ls.update_param( obj )
ls.write_config(CONF, "ls", "" )
ls = LineStyleParam(_("Line style"))
ls.read_config(CONF, "ls", "" )
self.assertEqual(ls.width, 2)
self.assertEqual(ls.style, "SolidLine")
self.assertEqual(ls.color, "#ff0000")
if __name__=="__main__":
unittest.main()
|