physicsLab 1.6.1__tar.gz → 1.6.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. {physicslab-1.6.1 → physicslab-1.6.2}/PKG-INFO +1 -1
  2. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab/web/api.py +16 -8
  3. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab.egg-info/PKG-INFO +1 -1
  4. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab.egg-info/SOURCES.txt +1 -5
  5. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab.egg-info/top_level.txt +0 -1
  6. {physicslab-1.6.1 → physicslab-1.6.2}/setup.py +2 -2
  7. physicslab-1.6.1/test_pl/__init__.py +0 -2
  8. physicslab-1.6.1/test_pl/base.py +0 -32
  9. physicslab-1.6.1/test_pl/test_physicsLab.py +0 -348
  10. physicslab-1.6.1/test_pl/test_pl_web.py +0 -25
  11. {physicslab-1.6.1 → physicslab-1.6.2}/LICENSE +0 -0
  12. {physicslab-1.6.1 → physicslab-1.6.2}/README.md +0 -0
  13. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab/Experiment.py +0 -0
  14. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab/__init__.py +0 -0
  15. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab/_colorUtils.py +0 -0
  16. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab/_element_base.py +0 -0
  17. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab/_tools.py +0 -0
  18. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab/celestial/__init__.py +0 -0
  19. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab/celestial/_element.py +0 -0
  20. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab/celestial/_experiment.py +0 -0
  21. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab/celestial/_planetbase.py +0 -0
  22. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab/celestial/planets.py +0 -0
  23. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab/chart.py +0 -0
  24. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab/circuit/__init__.py +0 -0
  25. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab/circuit/_element.py +0 -0
  26. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab/circuit/_experiment.py +0 -0
  27. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab/circuit/elementXYZ.py +0 -0
  28. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab/circuit/elements/__init__.py +0 -0
  29. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab/circuit/elements/_circuitbase.py +0 -0
  30. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab/circuit/elements/artificialCircuit.py +0 -0
  31. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab/circuit/elements/basicCircuit.py +0 -0
  32. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab/circuit/elements/logicCircuit.py +0 -0
  33. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab/circuit/elements/otherCircuit.py +0 -0
  34. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab/circuit/elements/sensor.py +0 -0
  35. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab/circuit/wire.py +0 -0
  36. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab/electromagnetism/__init__.py +0 -0
  37. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab/electromagnetism/_electromagnetismBase.py +0 -0
  38. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab/electromagnetism/_element.py +0 -0
  39. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab/electromagnetism/_experiment.py +0 -0
  40. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab/electromagnetism/elements.py +0 -0
  41. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab/element.py +0 -0
  42. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab/enums.py +0 -0
  43. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab/errors.py +0 -0
  44. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab/lib/__init__.py +0 -0
  45. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab/lib/edge_trigger.py +0 -0
  46. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab/lib/logic.py +0 -0
  47. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab/lib/wires.py +0 -0
  48. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab/music/__init__.py +0 -0
  49. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab/music/music.py +0 -0
  50. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab/plAR.py +0 -0
  51. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab/savTemplate.py +0 -0
  52. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab/typehint.py +0 -0
  53. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab/utils.py +0 -0
  54. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab/web/__init__.py +0 -0
  55. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab/web/_async_tool.py +0 -0
  56. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab/web/webutils.py +0 -0
  57. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab.egg-info/dependency_links.txt +0 -0
  58. {physicslab-1.6.1 → physicslab-1.6.2}/physicsLab.egg-info/requires.txt +0 -0
  59. {physicslab-1.6.1 → physicslab-1.6.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: physicsLab
3
- Version: 1.6.1
3
+ Version: 1.6.2
4
4
  Summary: Python API for Quantum-Physics App
5
5
  Home-page: https://github.com/GoodenoughPhysicsLab/physicsLab
6
6
  Author: Arendelle
@@ -6,8 +6,11 @@
6
6
  '''
7
7
 
8
8
  import os
9
+ import sys
10
+ import types
9
11
  import asyncio
10
12
  import requests
13
+ import functools
11
14
  import threading
12
15
 
13
16
  from concurrent.futures import thread
@@ -38,16 +41,21 @@ def _check_response(response: requests.Response, err_callback: Optional[Callable
38
41
  )
39
42
 
40
43
  async def _async_wrapper(func: Callable, *args, **kwargs):
41
- # run_in_executor会注册_python_exit到threading._threading_atexits
42
- # 而_python_exit调用join会导致win上的异常无法及时被抛出
44
+ # run_in_executor 会注册 _python_exit threading._threading_atexits
43
45
  _res = await asyncio.get_running_loop().run_in_executor(None, func, *args, **kwargs)
44
46
 
45
- # NOTE: 依赖于asyncio与concurrent.futures.thread的实现细节
46
- _threading_atexits = []
47
- for fn in threading._threading_atexits:
48
- if fn.func is not thread._python_exit:
49
- _threading_atexits.append(fn)
50
- threading._threading_atexits = _threading_atexits
47
+ # python3.14之前, threading.Thread.join 在 Windows 上会阻塞异常的传播
48
+ # 也就是说, 在join结束之前, Python无法及时抛出 KeyboardInterrupt
49
+ # python 并未提供公开的方法操作 threading._threading_atexit
50
+ # NOTE: 依赖于 asyncio 与 concurrent.futures.thread 的实现细节
51
+ if sys.version_info < (3, 14) and hasattr(threading, "_threading_atexits"):
52
+ _threading_atexits = []
53
+ for fn in threading._threading_atexits:
54
+ if isinstance(fn, types.FunctionType) and fn is not thread._python_exit:
55
+ _threading_atexits.append(fn)
56
+ elif isinstance(fn, functools.partial) and fn.func is not thread._python_exit:
57
+ _threading_atexits.append(fn)
58
+ threading._threading_atexits = _threading_atexits
51
59
 
52
60
  return _res
53
61
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: physicsLab
3
- Version: 1.6.1
3
+ Version: 1.6.2
4
4
  Summary: Python API for Quantum-Physics App
5
5
  Home-page: https://github.com/GoodenoughPhysicsLab/physicsLab
6
6
  Author: Arendelle
@@ -50,8 +50,4 @@ physicsLab/music/music.py
50
50
  physicsLab/web/__init__.py
51
51
  physicsLab/web/_async_tool.py
52
52
  physicsLab/web/api.py
53
- physicsLab/web/webutils.py
54
- test_pl/__init__.py
55
- test_pl/base.py
56
- test_pl/test_physicsLab.py
57
- test_pl/test_pl_web.py
53
+ physicsLab/web/webutils.py
@@ -3,7 +3,7 @@ import setuptools
3
3
 
4
4
  setuptools.setup(
5
5
  name="physicsLab",
6
- version="1.6.1",
6
+ version="1.6.2",
7
7
  license="MIT",
8
8
  author="Arendelle",
9
9
  author_email="2381642961@qq.com",
@@ -11,7 +11,7 @@ setuptools.setup(
11
11
  long_description="show description in [github](https://github.com/GoodenoughPhysicsLab/physicsLab)",
12
12
  long_description_content_type="text/markdown",
13
13
  url="https://github.com/GoodenoughPhysicsLab/physicsLab",
14
- packages=setuptools.find_packages(),
14
+ packages=setuptools.find_packages(include=["physicsLab", "physicsLab.*"]),
15
15
  install_requires=["mido", "typing-extensions", "requests", "colorama"],
16
16
  classifiers=[
17
17
  "Programming Language :: Python :: 3",
@@ -1,2 +0,0 @@
1
- from .test_physicsLab import BasicTest
2
- from .test_pl_web import WebTest
@@ -1,32 +0,0 @@
1
- from unittest import TestCase
2
- from physicsLab import *
3
-
4
- USE_VIZTRACER: bool = False
5
-
6
- if USE_VIZTRACER:
7
- from viztracer import VizTracer
8
-
9
- class TestError(Exception):
10
- def __init__(self, err_msg: str = "Test fail", no_pop: bool=False) -> None:
11
- self.err_msg: str = err_msg
12
- self.no_pop = no_pop
13
-
14
- def __str__(self) -> str:
15
- if not self.no_pop:
16
- get_current_experiment().exit()
17
- return self.err_msg
18
-
19
- class PLTestBase(TestCase):
20
- if USE_VIZTRACER:
21
- @classmethod
22
- def setUpClass(cls):
23
- tracer = VizTracer()
24
- tracer.start()
25
-
26
- cls.tracer = tracer
27
-
28
- @classmethod
29
- def tearDownClass(cls):
30
- tracer = cls.tracer
31
- tracer.stop()
32
- tracer.save() # also takes output_file as an optional argument
@@ -1,348 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- import os
3
- from .base import *
4
- from physicsLab.lib import *
5
- from physicsLab.Experiment import _ExperimentStack
6
-
7
- def my_test_dec(method: Callable):
8
- def result(*args, **kwarg):
9
- method(*args, **kwarg)
10
-
11
- if len(_ExperimentStack.data) != 0:
12
- print(f"File {os.path.abspath(__file__)}, line {method.__code__.co_firstlineno} : "
13
- f"test fail due to len(stack_Experiment) != 0")
14
- _ExperimentStack.data.clear()
15
- raise TestError
16
- return result
17
-
18
- class BasicTest(PLTestBase):
19
- @my_test_dec
20
- def test_experiment1(self):
21
- expe: Experiment = Experiment().crt("__test__", force_crt=True)
22
- a = Yes_Gate(0, 0, 0)
23
- self.assertEqual(count_elements(expe), 1)
24
- self.assertEqual(a.get_position(), (0, 0, 0))
25
- crt_wire(a.o, a.i)
26
- self.assertEqual(count_wires(), 1)
27
- clear_wires()
28
- self.assertEqual(count_wires(), 0)
29
- self.assertEqual(count_elements(expe), 1)
30
- crt_wire(a.o, a.i)
31
- crt_element(expe, 'Logic Input')
32
- self.assertEqual(count_elements(expe), 2)
33
- get_element_from_position(expe, 0, 0, 0)
34
- expe.exit()
35
-
36
- @my_test_dec
37
- def test_read_Experiment(self):
38
- expe: Experiment = Experiment().crt("__test__", force_crt=True)
39
-
40
- self.assertEqual(count_elements(expe), 0)
41
- self.assertEqual(count_wires(), 0)
42
- Logic_Input(0, 0, 0)
43
- expe.write()
44
-
45
- exp2: Experiment = Experiment().open("__test__")
46
- read_plsav(exp2)
47
- self.assertEqual(count_elements(exp2), 1)
48
- exp2.delete()
49
-
50
- @my_test_dec
51
- def test_crt_Experiment(self):
52
- try:
53
- exp: Experiment = Experiment().crt("__test__", force_crt=True)
54
- exp.write()
55
- Experiment().crt("__test__") # will fail
56
- except ExperimentHasExistError:
57
- Experiment("__test__").delete()
58
- else:
59
- raise TestError
60
-
61
- @my_test_dec
62
- def test_crt_wire(self):
63
- with experiment("__test__", is_exit=True, force_crt=True):
64
- a = Or_Gate(0, 0, 0)
65
- crt_wire(a.o, a.i_up, "red")
66
- self.assertEqual(count_wires(), 1)
67
-
68
- del_wire(a.o, a.i_up)
69
- self.assertEqual(count_wires(), 0)
70
-
71
- def test_same_crt_wire(self):
72
- with experiment("__test__", is_exit=True, force_crt=True):
73
- a = Or_Gate(0, 0, 0)
74
- crt_wire(a.o, a.i_up, "red")
75
- crt_wire(a.i_up, a.o, "blue")
76
- self.assertEqual(count_wires(), 1)
77
-
78
- @my_test_dec
79
- def test_union_Sum(self):
80
- expe: Experiment = Experiment().crt("__test__", force_crt=True)
81
- lib.Sum(0, -1, 0, bitnum=64)
82
- self.assertEqual(count_elements(expe), 64)
83
- self.assertEqual(count_wires(), 63)
84
- clear_elements(expe)
85
- self.assertEqual(count_wires(), 0)
86
- self.assertEqual(count_elements(expe), 0)
87
- expe.exit()
88
-
89
- @my_test_dec
90
- def test_get_Element(self):
91
- expe: Experiment = Experiment().crt("__test__", force_crt=True)
92
- Or_Gate(0, 0, 0)
93
- crt_wire(
94
- get_element_from_position(expe, 0, 0, 0).o,
95
- get_element_from_index(expe, index=1).i_up
96
- )
97
- crt_wire(
98
- get_element_from_position(expe, 0, 0, 0).i_low,
99
- get_element_from_index(expe, index=1).o
100
- )
101
- self.assertEqual(count_wires(), 2)
102
- expe.exit()
103
-
104
- # 测逝用例未写完
105
- @my_test_dec
106
- def test_set_O(self):
107
- expe: Experiment = Experiment().crt("__test__", force_crt=True)
108
- set_O(-1, -1, 0)
109
- for x in range(10):
110
- for y in range(10):
111
- Yes_Gate(x, y, 0, True)
112
- self.assertEqual(count_elements(expe), 100)
113
- expe.exit()
114
-
115
- @my_test_dec
116
- def test_errors(self):
117
- try:
118
- with experiment("__test__", delete=True, force_crt=True):
119
- pass # 确保__test__实验不存在
120
- Experiment().open('__test__') # do not exist
121
- except ExperimentNotExistError:
122
- pass
123
- else:
124
- raise TestError
125
-
126
- # 测试元件坐标系2
127
- @my_test_dec
128
- def test_aTest(self):
129
- expe: Experiment = Experiment().crt("__test__", force_crt=True)
130
- set_elementXYZ(True)
131
- set_O(-1, -1, 0)
132
- for x in range(10):
133
- for y in range(10):
134
- Yes_Gate(x, y, 0)
135
- for x in range(10):
136
- for y in [y * 2 + 10 for y in range(5)]:
137
- Multiplier(x, y, 0)
138
-
139
- crt_wire(get_element_from_index(expe, 1).o, get_element_from_position(expe, 0, 1, 0).i)
140
- get_element_from_index(expe, 2).i - get_element_from_index(expe, 3).o - get_element_from_index(expe, 4).i
141
- self.assertEqual(count_wires(), 3)
142
- self.assertEqual(count_elements(expe), 150)
143
- expe.exit()
144
-
145
- @my_test_dec
146
- def test_open_many_Experiment(self):
147
- exp: Experiment = Experiment().crt("__test__", force_crt=True)
148
- with experiment('__test__', is_exit=True, force_crt=True) as expe:
149
- Logic_Input(0, 0, 0)
150
- self.assertEqual(1, count_elements(expe))
151
- exp.exit()
152
-
153
- @my_test_dec
154
- def test_with_and_coverPosition(self):
155
- with experiment("__test__", is_exit=True, force_crt=True) as expe:
156
- Logic_Input(0, 0, 0)
157
- Or_Gate(0, 0, 0)
158
- self.assertEqual(len(get_element_from_position(expe, 0, 0, 0)), 2)
159
-
160
- @my_test_dec
161
- def test_del_Element(self):
162
- with experiment("__test__", is_exit=True, force_crt=True) as expe:
163
- Logic_Input(0, 0, 0).o - Or_Gate(0, 0, 0).o
164
- del_element(expe, get_element_from_index(expe, 2))
165
- self.assertEqual(count_elements(expe), 1)
166
- self.assertEqual(count_wires(), 0)
167
-
168
- # 测逝模块化电路连接导线
169
- @my_test_dec
170
- def test_wires(self):
171
- with experiment("__test__", is_exit=True, elementXYZ=True, force_crt=True) as expe:
172
- a = lib.Inputs(0, 0, 0, bitnum=8)
173
- b = lib.Outputs(0.6, 0, 0, bitnum=8, elementXYZ=False)
174
- Logic_Output(0.6, 0, 0.1, elementXYZ=False)
175
- c = lib.D_WaterLamp(1, 0, 0, bitnum=8)
176
- crt_wires(b.inputs, c.outputs)
177
- self.assertEqual(25, count_elements(expe))
178
- self.assertEqual(23, count_wires())
179
- del_wires(c.outputs, b.inputs)
180
- self.assertEqual(15, count_wires())
181
-
182
- # 测逝模块化加法电路
183
- @my_test_dec
184
- def test_union_Sum2(self):
185
- with experiment("__test__", is_exit=True, elementXYZ=True, force_crt=True):
186
- a = lib.Inputs(-1, 0, 0, bitnum=8)
187
- b = lib.Inputs(-2, 0, 0, bitnum=8)
188
- c = lib.Sum(0, 0, 0, bitnum=8)
189
- d = lib.Outputs(1, 0, 0, bitnum=8)
190
- a.outputs - c.inputs1
191
- b.outputs - c.inputs2
192
- c.outputs - d.inputs
193
-
194
- # 测试打开实验类型与文件不吻合
195
- @my_test_dec
196
- def test_ExperimentType(self):
197
- with experiment("__test__", experiment_type=ExperimentType.Electromagnetism, is_exit=True, force_crt=True):
198
- try:
199
- Positive_Charge(0, 0, 0)
200
- Logic_Input(0, 0, 0)
201
- except ExperimentTypeError:
202
- pass
203
- else:
204
- raise TestError
205
-
206
- @my_test_dec
207
- def test_ExperimentType3(self):
208
- with experiment("__test__", experiment_type=ExperimentType.Circuit, is_exit=True, force_crt=True):
209
- Logic_Input(0, 0, 0)
210
- with experiment("__test__", experiment_type=ExperimentType.Celestial, is_exit=True, force_crt=True):
211
- pass
212
- with experiment("__test__", experiment_type=ExperimentType.Electromagnetism, is_exit=True, force_crt=True):
213
- pass
214
-
215
- @my_test_dec
216
- def test_electromagnetism(self):
217
- with experiment("__test__", is_exit=True, experiment_type=ExperimentType.Electromagnetism, force_crt=True) as expe:
218
- Negative_Charge(-0.1, 0, 0)
219
- Positive_Charge(0.1, 0, 0)
220
- self.assertEqual(count_elements(expe), 2)
221
- try:
222
- count_wires()
223
- except ExperimentTypeError:
224
- pass
225
- else:
226
- raise TestError
227
-
228
- @my_test_dec
229
- def test_union_Sub(self):
230
- with experiment("__test__", is_exit=True, elementXYZ=True, force_crt=True) as expe:
231
- a = lib.Sub(0, 0, 0, bitnum=8, fold=False)
232
- crt_wires(lib.Inputs(-3, 0, 0, bitnum=8).outputs, a.minuend)
233
- crt_wires(lib.Inputs(-2, 0, 0, bitnum=8).outputs, a.subtrahend)
234
- crt_wires(lib.Outputs(2, 0, 0, bitnum=9).inputs, a.outputs)
235
- self.assertEqual(count_elements(expe), 42)
236
- self.assertEqual(count_wires(), 41)
237
-
238
- lib.Sub(-5, 0, 0, bitnum=4)
239
-
240
- # 测试简单乐器设置音高的三种方法
241
- @my_test_dec
242
- def test_Simple_Instrument(self):
243
- with experiment("__test__", is_exit=True, elementXYZ=True, force_crt=True):
244
- a = Simple_Instrument(0, 0, 0, pitch=48)
245
- a = Simple_Instrument(0, 0, 0).set_tonality(48)
246
- a = Simple_Instrument(0, 0, 0, pitch="C3")
247
- a = Simple_Instrument(0, 0, 0).set_tonality("C3")
248
- Logic_Input(-1, 0, 0).o - a.i
249
- a.o - Ground_Component(1, 0, 0).i
250
-
251
- @my_test_dec
252
- def test_getElementError(self):
253
- with experiment("__test__", is_exit=True, force_crt=True) as expe:
254
- Logic_Input(0, 0, 0)
255
- try:
256
- get_element_from_index(expe, 2)
257
- except ElementNotFound:
258
- pass
259
- else:
260
- raise TestError
261
-
262
- @my_test_dec
263
- def test_unionMusic(self):
264
- music.Note(2)
265
- try:
266
- music.Note(0)
267
- except TypeError:
268
- pass
269
- else:
270
- raise TestError
271
-
272
- @my_test_dec
273
- def test_is_bigElement(self):
274
- with experiment("__test__", force_crt=True, is_exit=True):
275
- self.assertEqual(Logic_Output.is_bigElement, False)
276
- self.assertEqual(Multiplier.is_bigElement, True)
277
- self.assertEqual(Or_Gate.is_bigElement, False)
278
- self.assertEqual(Logic_Input(0, 0, 0).is_bigElement, False)
279
- self.assertEqual(Full_Adder(0, 0, 0).is_bigElement, True)
280
- self.assertEqual(Xor_Gate(0, 0, 0).is_bigElement, False)
281
-
282
- @my_test_dec
283
- def test_musicPlayer(self):
284
- with experiment("__test__", is_exit=True, force_crt=True):
285
- l = (0, 2, 4, 5, 7, 9, 11)
286
-
287
- t = music.Piece()
288
- for i in range(7):
289
- for j in l:
290
- n = music.Note(1, pitch=12 * i + j + 21)
291
- t.append(n)
292
- n.append(music.Note(1, pitch=12 * i + j + 23))
293
- t.release(-1, -1, 0)
294
-
295
- @my_test_dec
296
- def test_mutiple_notes_in_Simple_Instrument(self):
297
- with experiment("__test__", force_crt=True, is_exit=True):
298
- Simple_Instrument(0, 0, 0).add_note(67) # type: ignore
299
-
300
- @my_test_dec
301
- def test_merge_Experiment(self):
302
- with experiment("__test__", force_crt=True, is_exit=True) as expe:
303
- Logic_Input(0, 0, 0).o - Logic_Output(1, 0, 0, elementXYZ=True).i
304
-
305
- with experiment("_Test", force_crt=True, is_exit=True) as exp2:
306
- Logic_Output(0, 0, 0.1)
307
- exp2.merge(expe, 1, 0, 0, elementXYZ=True)
308
-
309
- self.assertEqual(count_elements(exp2), 3)
310
-
311
- @my_test_dec
312
- def test_link_wire_in_two_experiment(self):
313
- with experiment("__test__", force_crt=True, is_exit=True):
314
- a = Logic_Input(0, 0, 0)
315
- with experiment("_Test", force_crt=True, is_exit=True):
316
- b = Logic_Output(0, 0, 0)
317
- try:
318
- a.o - b.i
319
- except ExperimentError:
320
- pass
321
- else:
322
- raise TestError
323
-
324
- @my_test_dec
325
- def test_merge_Experiment2(self):
326
- with experiment("__test__", force_crt=True, is_exit=True) as exp:
327
- e = Yes_Gate(0, 0, 0)
328
- e.i - e.o
329
-
330
- with experiment("_Test", force_crt=True, is_exit=True) as exp2:
331
- Logic_Output(0, 0, 0.1)
332
- exp2.merge(exp, 1, 0, 0, elementXYZ=True)
333
- a = get_element_from_position(exp2, 1, 0, 0)
334
- a.i - a.o
335
-
336
- self.assertEqual(count_elements(exp2), 2)
337
- self.assertEqual(count_wires(), 1)
338
-
339
- @my_test_dec
340
- def test_crt_self_wire(self):
341
- with experiment("__test__", force_crt=True, is_exit=True) as exp:
342
- e = Logic_Output(0, 0, 0)
343
- try:
344
- e.i - e.i
345
- except ExperimentError:
346
- pass
347
- else:
348
- raise TestError
@@ -1,25 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- from .base import *
3
-
4
- class WebTest(PLTestBase):
5
- def setUp(self) -> None: # test_login
6
- # NOTE: 暴露token与auth_code是危险的行为
7
- # 但 @AMDYES 主动暴露了自己的token与auth_code
8
- # 详见 <discussion=674ab7f4ce449cb493ced3a7>转让此号</discussion>
9
- self.user = web.User(
10
- token="yYReEg0oCtGlVmJqQwFr1zZXhL9NAvBH",
11
- auth_code="nENz1xlrueQUmkqjYZKtCG9SI53vF8Xc"
12
- )
13
-
14
- # TODO: 异步跑这些测试
15
- def test_get_start_page(self):
16
- web.get_start_page()
17
-
18
- def test_get_library(self):
19
- self.user.get_library()
20
-
21
- def test_query_experiments(self):
22
- self.user.query_experiments()
23
-
24
- def test_get_experiment(self):
25
- self.user.get_experiment("642cf37a494746375aae306a", Category.Discussion)
File without changes
File without changes
File without changes