ChimeraTK-ApplicationCore 04.06.00
Loading...
Searching...
No Matches
testPythonVersionNumber.py
Go to the documentation of this file.
1import datetime as dt
2import os.path
3import sys
4import traceback
5
6
7# fmt: off
8# Hack to insert the python path for the locally compiled module in the
9# test script
10sys.path.insert(0, os.path.abspath(os.path.join(os.curdir, "..")))
11import PyApplicationCore as ac # NOQA
12# fmt: on
13
14
15class TestRunner(ac.ApplicationModule):
16 def __init__(self, owner, name, description):
17 super().__init__(owner, name, description)
18
19 self.testError = ac.ScalarOutput(ac.DataType.string, self, "TestError", "", "")
20
21 def mainLoop(self):
22 try:
23 usedDate = dt.datetime.now() - dt.timedelta(hours=2)
24 version1 = ac.VersionNumber()
25 version2 = ac.VersionNumber()
26 version3 = ac.VersionNumber(usedDate)
27 version4 = ac.VersionNumber(None)
28
29 assert version1 < version2, "smaller"
30 assert version1 != version2, "not equal"
31 assert version1 == version1, "equal"
32
33 assert version4 < version1, "smaller 41"
34 assert version4 < version2, "smaller 42"
35 assert version4 < version3, "smaller 43"
36
37 assert version3.getTime() == usedDate, "Date roundtrip works"
38
39 except AssertionError as e:
40 self.testError.setAndWrite("\n".join(traceback.format_exception(e)))
41
42
43ac.app.testRunner = TestRunner(ac.app, "VersionTestRunner", "Simple module for testing the VersionNumber binding")
__init__(self, owner, name, description)
void mainLoop() override