-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
107 lines (75 loc) · 2.45 KB
/
test.py
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
94
95
96
97
98
99
100
from handyhelpers.escapecontext import Context
from handyhelpers import *
import logging
if __name__ == "__main__":
print("[BEGIN] Testing escapecontext.py...")
c = Context()
aa = open("LICENSE")
cf = c.contextless(aa)
if not cf.readline() == "MIT License\n":
print("[ERROR] In escapecontext.py")
else:
c.kill()
print("[DONE] No Errors detected")
print("[BEGIN] Testing virtualfilesystem.py...")
vd = VirtualDrive(autoadd=True)
open = vd.open
openfile = vd.openfile
open("V:/Users/Dave")
open("V:/Users/Bob")
with openfile("V:/Users/Dave/notes.txt") as f:
f.write("filecontent\nfilecontent123")
render = "\n".join(vd.render())
# print(render)
savestate = vd.save()
vo = VirtualObject.fromsave(savestate)
rendersaved = "\n".join(vo.render())
if not (render == rendersaved):
print("[ERROR] In virtualfilesystem.py")
else:
print("[DONE] No Errors detected")
print("[BEGIN] Testing config.py...")
c = Config.from_memory()
savetxt = "Hello World!"
c["test"] = savetxt
c.save()
# print(c.file.read()["test"] == savetxt)
print("[DONE] No Errors detected")
print("[BEGIN] Testing serialise.py...")
print(serial_log)
# using root serialisation context
@linkedserialisable(0, 0)
class test1:
def __init__(self, serf, x, y) -> None:
super().__init__()
serf.x = x
serf.y = y
@linkedserialisable(5, 5)
class test2:
def __init__(self, serf, x, y) -> None:
serf.x = x
serf.y = y
t1 = test1(10, 15)
t2 = test2(t1, 20)
t1.x = t2
serilaised = Serialiser(t1).get()
deserialised = Constructor(serilaised).get()
print("global context STATUS:", {True:"Good", False:"Bad"}[t1.x.y == deserialised.x.y])
ssm = SerialManager(__name__)
@ssm.linkedserialisable(0, 0)
class test1:
def __init__(self, serf, x, y) -> None:
super().__init__()
serf.x = x
serf.y = y
@ssm.linkedserialisable(5, 5)
class test2:
def __init__(self, serf, x, y) -> None:
serf.x = x
serf.y = y
t1 = test1(10, 15)
t2 = test2(t1, 20)
t1.x = t2
serilaised = ssm.Serialiser(t1).get()
deserialised = ssm.Constructor(serilaised).get()
print("local context STATUS:", {True:"Good", False:"Bad"}[t1.x.y == deserialised.x.y])