Commit f663056c authored by Boudewijn Rempt's avatar Boudewijn Rempt

Eliakin tells me these tests were kind of useless

So let's remove them
parent 00285fde
#
# Tests the PyKrita API
#
import sys
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from krita import *
def __main__(args):
print("Arguments:", args)
Application.setBatchmode(True)
print("Batchmode: ", Application.batchmode())
print("Profiles:", Application.profiles("GRAYA", "U16"))
document = Application.openDocument(args[0])
print("Opened", document.fileName(), "WxH", document.width(), document.height(), "resolution", document.xRes(), document.yRes(), "in ppi", document.resolution())
node = document.rootNode()
print("Root", node.name(), "opacity", node.opacity())
for child in node.childNodes():
print("\tChild", child.name(), "opacity", node.opacity(), node.blendingMode())
# r = child.save(child.name() + ".png", document.xRes(), document.yRes());
# print("Saving result:", r)
for channel in child.channels():
print("Channel", channel.name(), "contents:", len(channel.pixelData(node.bounds())))
document.close()
document = Application.createDocument(100, 100, "test", "GRAYA", "U16", "")
document.setBatchmode(True)
# document.saveAs("test.kra")
import sys
inst_dir = sys.argv[2]
source_dir = sys.argv[3]
sys.path.insert(0, str("{0}/share/krita/pykrita/PyKrita").format(inst_dir))
import unittest
from krita import Action
from PyQt5.QtWidgets import QAction
class TestAction(unittest.TestCase):
def setUp(self):
self.instance = Action()
self.instance.triggered.connect(self.slotTriggered)
self.triggered = False
def testConstructor(self):
self.assertEqual(bool(self.instance), True)
def testConstructorWithStringQAction(self):
new_action = Action("test", QAction("test"))
self.assertEqual(bool(new_action), True)
def testConstructorInvalidParameter(self):
with self.assertRaises(TypeError):
Action(str(''))
def testEqualOperator(self):
new_action = self.instance
self.assertEqual(new_action == self.instance, True)
def testInequalityOperator(self):
new_action = Action()
self.assertEqual(new_action != self.instance, True)
def testTextProperties(self):
self.instance.setText("test")
self.assertEqual(self.instance.text() == "test", True)
def testNameProperties(self):
self.instance.setName("test")
self.assertEqual(self.instance.name() == "test", True)
def testCheckableInitialState(self):
self.assertEqual(self.instance.isCheckable(), False)
def testCheckableToTrue(self):
self.instance.setCheckable(True)
self.assertEqual(self.instance.isCheckable(), True)
def testCheckableToFalse(self):
self.instance.setCheckable(False)
self.assertEqual(self.instance.isCheckable(), False)
def testCheckedInitialState(self):
self.assertEqual(self.instance.isChecked(), False)
def testCheckedToTrue(self):
self.instance.setCheckable(True)
self.instance.setChecked(True)
self.assertEqual(self.instance.isChecked(), True)
def testCheckedToFalse(self):
self.instance.setChecked(False)
self.assertEqual(self.instance.isChecked(), False)
def testCheckedToFalseNotCheckable(self):
self.instance.setChecked(True)
self.assertEqual(self.instance.isChecked(), False)
def testVisibleInitialState(self):
self.assertEqual(self.instance.isVisible(), True)
def testVisibleToTrue(self):
self.instance.setVisible(True)
self.assertEqual(self.instance.isVisible(), True)
def testVisibleToFalse(self):
self.instance.setVisible(False)
self.assertEqual(self.instance.isVisible(), False)
def testTrigger(self):
self.instance.trigger()
self.assertEqual(self.triggered, True)
# helper method
def slotTriggered(self):
self.triggered = True
import unittest
from krita import Extension
from PyQt5.QtCore import QObject
class TestExtension(unittest.TestCase):
def testConstructorSubClass(self):
self.assertEqual(bool(SubClassExtension()), True)
def testConstructorSubClassWithParent(self):
self.assertEqual(bool(SubClassExtension(QObject())), True)
def testConstructorInvalidParameter(self):
with self.assertRaises(TypeError):
SubClassExtension(str(''))
def testConstructorAbstractClass(self):
with self.assertRaises(TypeError):
Extension()
def testExtensionHasMethodsetup(self):
setup = getattr(SubClassExtension(), "setup", None)
self.assertEqual(bool(callable(setup)), True)
class SubClassExtension(Extension):
def setup(self):
pass
import unittest
from krita import Filter, InfoObject
from PyQt5.QtCore import QObject
class TestFilter(unittest.TestCase):
def setUp(self):
self._instance = Filter()
def testConstructor(self):
self.assertTrue(Filter())
def testConstructorInvalidParameter(self):
with self.assertRaises(TypeError):
Filter(str(''))
def testEqualOperator(self):
sameFilter = self._instance
self.assertTrue(sameFilter == self._instance)
def testEmptyNameProperty(self):
self.assertFalse(self._instance.name())
# segmentation fault here, I need to verify that.
def testConfigurationProperties(self):
pass
# infoObject = InfoObject()
# f = Filter()
# f.setConfiguration(infoObject)
# self.assertEqual(f.configuration(), infoObject)
import unittest
from krita import InfoObject
from PyQt5.QtCore import QObject
class TestInfoObject(unittest.TestCase):
def setUp(self):
self._instance = InfoObject()
def testConstructor(self):
self.assertTrue(InfoObject())
def testConstructorWithParent(self):
self.assertTrue(InfoObject(QObject()))
def testConstructorInvalidParameter(self):
with self.assertRaises(TypeError):
InfoObject(str(''))
def testEqualOperator(self):
sameInfoObject = self._instance
self.assertTrue(sameInfoObject == self._instance)
def testInequalityOperator(self):
newInfoObject = InfoObject()
self.assertTrue(newInfoObject != self._instance)
def testPropertiesAcessorsOneProperty(self):
self._instance.setProperties({"test": "test"})
self.assertEqual(self._instance.properties(), {"test": "test"})
def testPropertiesAcessorsSetProperties(self):
self._instance.setProperties({"test": "test", "test1": 1})
self.assertEqual(self._instance.properties(), {"test": "test", "test1": 1})
def testPropertySlotsString(self):
self._instance.setProperty("key", "value")
self.assertEqual(self._instance.property("key"), "value")
def testPropertySlotsInvalidKey(self):
self._instance.setProperty("key", "value")
self.assertEqual(self._instance.property("keys"), None)
import unittest
import sys
inst_dir = sys.argv[2]
source_dir = sys.argv[3]
sys.path.insert(0, str("{0}/share/krita/pykrita/PyKrita").format(inst_dir))
from krita import *
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