l1test 3.3.0__py3-none-any.whl

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 (77) hide show
  1. l1test-3.3.0.dist-info/LICENSE +21 -0
  2. l1test-3.3.0.dist-info/METADATA +63 -0
  3. l1test-3.3.0.dist-info/RECORD +77 -0
  4. l1test-3.3.0.dist-info/WHEEL +5 -0
  5. l1test-3.3.0.dist-info/top_level.txt +1 -0
  6. thonnycontrib/ThonnyLogsGenerator.py +56 -0
  7. thonnycontrib/__init__.py +0 -0
  8. thonnycontrib/backend/__init__.py +0 -0
  9. thonnycontrib/backend/approx_comp.py +116 -0
  10. thonnycontrib/backend/ast_parser.py +450 -0
  11. thonnycontrib/backend/doctest_parser.py +945 -0
  12. thonnycontrib/backend/evaluator.py +148 -0
  13. thonnycontrib/backend/l1test_backend.py +105 -0
  14. thonnycontrib/backend/test_finder.py +143 -0
  15. thonnycontrib/backend/verdicts/ExampleVerdict.py +75 -0
  16. thonnycontrib/backend/verdicts/ExceptionVerdict.py +17 -0
  17. thonnycontrib/backend/verdicts/FailedVerdict.py +33 -0
  18. thonnycontrib/backend/verdicts/FailedWhenExceptionExpectedVerdict.py +20 -0
  19. thonnycontrib/backend/verdicts/PassedSetupVerdict.py +15 -0
  20. thonnycontrib/backend/verdicts/PassedVerdict.py +17 -0
  21. thonnycontrib/backend/verdicts/__init__.py +0 -0
  22. thonnycontrib/environement_vars.py +28 -0
  23. thonnycontrib/exceptions.py +124 -0
  24. thonnycontrib/frontend/__init__.py +22 -0
  25. thonnycontrib/frontend/docstring_generator/__init__.py +16 -0
  26. thonnycontrib/frontend/docstring_generator/doc_generator.py +449 -0
  27. thonnycontrib/frontend/docstring_generator/doc_template.py +87 -0
  28. thonnycontrib/frontend/l1test_error_view.py +74 -0
  29. thonnycontrib/frontend/l1test_outliner_menu.py +103 -0
  30. thonnycontrib/frontend/l1test_reporter.py +64 -0
  31. thonnycontrib/frontend/l1test_runner.py +518 -0
  32. thonnycontrib/frontend/l1test_treeview.py +932 -0
  33. thonnycontrib/frontend/main_generator/__init__.py +1 -0
  34. thonnycontrib/frontend/main_generator/main_generator.py +81 -0
  35. thonnycontrib/i18n/__init__.py +0 -0
  36. thonnycontrib/i18n/languages.py +28 -0
  37. thonnycontrib/i18n/locale/en_US/LC_MESSAGES/l1test.mo +0 -0
  38. thonnycontrib/i18n/locale/en_US/LC_MESSAGES/l1test.po +228 -0
  39. thonnycontrib/i18n/locale/fr_FR/LC_MESSAGES/l1test.mo +0 -0
  40. thonnycontrib/i18n/locale/fr_FR/LC_MESSAGES/l1test.po +269 -0
  41. thonnycontrib/i18n/locale/l1test.pot +235 -0
  42. thonnycontrib/img/error_icon.png +0 -0
  43. thonnycontrib/img/exception_red_chip.png +0 -0
  44. thonnycontrib/img/failed.png +0 -0
  45. thonnycontrib/img/failed_red_chip.png +0 -0
  46. thonnycontrib/img/l1test_icon.png +0 -0
  47. thonnycontrib/img/l1test_icon_old.png +0 -0
  48. thonnycontrib/img/outline_class.png +0 -0
  49. thonnycontrib/img/outline_method.gif +0 -0
  50. thonnycontrib/img/passed.png +0 -0
  51. thonnycontrib/img/pending_icon.png +0 -0
  52. thonnycontrib/img/restart_icon.png +0 -0
  53. thonnycontrib/img/success_green_chip.png +0 -0
  54. thonnycontrib/img/warning.png +0 -0
  55. thonnycontrib/l1test_configuration/__init__.py +0 -0
  56. thonnycontrib/l1test_configuration/l1test_options.py +122 -0
  57. thonnycontrib/plugin_loader.py +184 -0
  58. thonnycontrib/properties.py +77 -0
  59. thonnycontrib/tests/__init__.py +0 -0
  60. thonnycontrib/tests/fixtures/__init__.py +0 -0
  61. thonnycontrib/tests/fixtures/backend_mock.py +11 -0
  62. thonnycontrib/tests/fixtures/workbench_mock.py +47 -0
  63. thonnycontrib/tests/test_evaluator_source_tests.py +276 -0
  64. thonnycontrib/tests/tests_approx_comp.py +344 -0
  65. thonnycontrib/tests/tests_ast_parser.py +0 -0
  66. thonnycontrib/tests/tests_doc_generator.py +392 -0
  67. thonnycontrib/tests/tests_example_no_expected.py +140 -0
  68. thonnycontrib/tests/tests_example_with_exception.py +431 -0
  69. thonnycontrib/tests/tests_example_with_expected.py +604 -0
  70. thonnycontrib/tests/tests_float_prompt.py +153 -0
  71. thonnycontrib/tests/tests_l1TestRunner.py +176 -0
  72. thonnycontrib/tests/tests_l1test_options.py +64 -0
  73. thonnycontrib/tests/tests_main_generator.py +48 -0
  74. thonnycontrib/tests/tests_test_finder.py +201 -0
  75. thonnycontrib/tests/tests_utils.py +14 -0
  76. thonnycontrib/tests/tests_view.py +340 -0
  77. thonnycontrib/utils.py +486 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) [year] [fullname]
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,63 @@
1
+ Metadata-Version: 2.1
2
+ Name: l1test
3
+ Version: 3.3.0
4
+ Summary: A basic unit testing tool for novice programmers provided as a Thonny plugin
5
+ Home-page: https://gitlab.univ-lille.fr/mirabelle.nebut/thonny-tests
6
+ Author: Mirabelle MARVIE-NEBUT, Reda ID TALEB
7
+ Author-email: Mirabelle NEBUT <mirabelle.nebut@univ-lille.fr>, Reda ID TALEB <reda@example.com>
8
+ License: MIT License
9
+
10
+ Copyright (c) [year] [fullname]
11
+
12
+ Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ of this software and associated documentation files (the "Software"), to deal
14
+ in the Software without restriction, including without limitation the rights
15
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ copies of the Software, and to permit persons to whom the Software is
17
+ furnished to do so, subject to the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included in all
20
+ copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ SOFTWARE.
29
+
30
+ Platform: Windows
31
+ Platform: macOS
32
+ Platform: Linux
33
+ Classifier: Programming Language :: Python :: 3
34
+ Classifier: License :: OSI Approved :: MIT License
35
+ Classifier: Operating System :: OS Independent
36
+ Classifier: Development Status :: 4 - Beta
37
+ Classifier: Topic :: Software Development :: Testing
38
+ Classifier: Topic :: Education
39
+ Classifier: Intended Audience :: Education
40
+ Classifier: Intended Audience :: Developers
41
+ Requires-Python: >=3.9
42
+ Description-Content-Type: text/markdown
43
+ License-File: LICENSE
44
+ Requires-Dist: thonny>=4.0.0
45
+
46
+ L1Test is a plugin for the IDE Thonny, that provides a basic unit test tool for novice programmers (hence the name, L1 = CS1). For teaching purpose. Beta status.
47
+
48
+ Building
49
+
50
+ To build a wheel for the plugin you can use the Makefile in this directory:
51
+
52
+ ```
53
+ make build
54
+ ```
55
+
56
+ If you need to ensure Python 3 is used (for example when `python` points to Python 2), run:
57
+
58
+ ```
59
+ make build3
60
+ ```
61
+
62
+ Note: the `build3` Makefile target forces the build to use Python 3. Use
63
+ `make build3` on systems where `python` defaults to Python 2.
@@ -0,0 +1,77 @@
1
+ thonnycontrib/ThonnyLogsGenerator.py,sha256=0NpzUEpvx2UgR-hcNbR6ltB1eNLkiDT2NiNNBJQlkcs,2105
2
+ thonnycontrib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ thonnycontrib/environement_vars.py,sha256=b3hNzaYGtFBtYK5MrKtoXTQjiqdspZhV04LRRdp7QRI,1514
4
+ thonnycontrib/exceptions.py,sha256=QBpg2GQJdXIQj4D8Z6ylXrqMagGUZ5Wen1OBFSkTPAk,3665
5
+ thonnycontrib/plugin_loader.py,sha256=lHRMKPF22dV5uF5W_Ia0JRe-zntDUqeow6YPAg9XnIQ,8100
6
+ thonnycontrib/properties.py,sha256=D14AaAcItuqUT__UWIjX8-Nyf943ALnA4aB2p9J9kTA,3951
7
+ thonnycontrib/utils.py,sha256=PlxVZWlDI8cCWCk5a-K8m5BPUYWHM8fY0LBlm5TbMjI,18583
8
+ thonnycontrib/backend/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
+ thonnycontrib/backend/approx_comp.py,sha256=m4Qrie6WYefo72Px968bAv7RGpFGYDlBl3O0w_Y79Ho,4003
10
+ thonnycontrib/backend/ast_parser.py,sha256=MPqFYzpr72a6vWsLndETz3xCRqCD-vijDIBZ4EnDqb8,17635
11
+ thonnycontrib/backend/doctest_parser.py,sha256=-0KmJ-5SZYgsG3Qy7SHUZMqlpFw3gBIrnPFjNUaKw8M,41952
12
+ thonnycontrib/backend/evaluator.py,sha256=oBwHFDCH_sWNVenhXD-na-Y8Mu_bIJ3N7HEg0_9-VFw,6620
13
+ thonnycontrib/backend/l1test_backend.py,sha256=IAeyY5P3iSYCgWJ9v1qc5cvrcl5CZokAhbCuBxVuKjQ,4620
14
+ thonnycontrib/backend/test_finder.py,sha256=KXtOKnos6Jqr9u9mhg9v9x_Nzy8HOyCPk9piAkjd84s,5669
15
+ thonnycontrib/backend/verdicts/ExampleVerdict.py,sha256=H-1y7Aw70oylCXNeVMAU-HHZIobe20BErCJTNcQc0O4,2585
16
+ thonnycontrib/backend/verdicts/ExceptionVerdict.py,sha256=jkBaQDPi9aAe8BbYlhyAxvpOyR3FQ-FUq3lip3lG7MA,507
17
+ thonnycontrib/backend/verdicts/FailedVerdict.py,sha256=FsOKS83eyoZA9XLyZvl8l4bMj4wzZWR5LvoPdFhRQxw,1285
18
+ thonnycontrib/backend/verdicts/FailedWhenExceptionExpectedVerdict.py,sha256=euHZTDyCbTdulGh4R1sDdDBCslw5VZp-rW5r9foufsg,698
19
+ thonnycontrib/backend/verdicts/PassedSetupVerdict.py,sha256=kEAria97ZGsTp4JnJh6qcM5jDnklfPLWVxSGf7KD2is,419
20
+ thonnycontrib/backend/verdicts/PassedVerdict.py,sha256=5f9lbhaPIJBniCZpF-TDTTVUs7K0VWBJudr-K6CS_sU,493
21
+ thonnycontrib/backend/verdicts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
+ thonnycontrib/frontend/__init__.py,sha256=0SWcXo0ZJbaezvGUq4dme96u_P-0DwFWHRZ8ZsEBMNA,754
23
+ thonnycontrib/frontend/l1test_error_view.py,sha256=N9WktS0i1dJV_puojXUMNTrFkAxDoj-q6KhXMvWGYDk,2876
24
+ thonnycontrib/frontend/l1test_outliner_menu.py,sha256=fB7Oc5LLOZp2e-kwLJr9HOU1f_ObH-yOSm31Tnzw8bE,3965
25
+ thonnycontrib/frontend/l1test_reporter.py,sha256=02RmiwJxKfA9V6ejRkKruJrPqfrdMDeYm0oOdhw8KWY,2746
26
+ thonnycontrib/frontend/l1test_runner.py,sha256=buF0jWm10FqY53LLiKizBgbv78QKlPswcKm2kwlViyQ,26846
27
+ thonnycontrib/frontend/l1test_treeview.py,sha256=8tMTaDm0pwQ_0mDGVd89T-MKC1MWlddQgyi22X0bEf0,44908
28
+ thonnycontrib/frontend/docstring_generator/__init__.py,sha256=GHi42nSrZHfV34058uqJ75LcBzUk5AnEndg6WpqsYI4,585
29
+ thonnycontrib/frontend/docstring_generator/doc_generator.py,sha256=GY77k2Yfv55Xx_PE4jQHYEXHyrxvO7D6aKdO1A2IccY,19360
30
+ thonnycontrib/frontend/docstring_generator/doc_template.py,sha256=kXftyNABLAFmwlMsMpPwn4pbHZR1_usCqz-IsVKyfwA,3145
31
+ thonnycontrib/frontend/main_generator/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
32
+ thonnycontrib/frontend/main_generator/main_generator.py,sha256=RxcWIxuDt_P7lqCi_Jfkvgq5XPKUlmZN3B3tbjfDrCs,3207
33
+ thonnycontrib/i18n/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
34
+ thonnycontrib/i18n/languages.py,sha256=HA_0p_5WzC_TDd-Un2_KIHSbub-Q7Q1OVChXRN1dABg,702
35
+ thonnycontrib/i18n/locale/l1test.pot,sha256=1_i1ty8u7XQmdpgw8-CYMflEFcaulvsRPVLhL5L3aR0,5773
36
+ thonnycontrib/i18n/locale/en_US/LC_MESSAGES/l1test.mo,sha256=75gf0urdHA9ppNAs7g-aT9XJGpAdM2N7uSGzObSvnhE,365
37
+ thonnycontrib/i18n/locale/en_US/LC_MESSAGES/l1test.po,sha256=AJumS5mcFCq4q770NUy26QwxT-X4aG6VzR4NxHEPWcc,5528
38
+ thonnycontrib/i18n/locale/fr_FR/LC_MESSAGES/l1test.mo,sha256=1MK9qSmCRQfNAY_iBUq-FHVaaMAYqxg9O9K8odmJE_M,4876
39
+ thonnycontrib/i18n/locale/fr_FR/LC_MESSAGES/l1test.po,sha256=6Vwbr651ykMvgbSsm8CoS4mR9A1o8mSX4d5P4pyBKPY,8333
40
+ thonnycontrib/img/error_icon.png,sha256=QdzWc9y7jS8Fbqdq1ggDTOCNFSQGH6X4_CpqkwtQpAg,912
41
+ thonnycontrib/img/exception_red_chip.png,sha256=yXy0U8hRWselwqUJnlHJJrGI0MWTL7lc_Foy0S6-LYU,1778
42
+ thonnycontrib/img/failed.png,sha256=SA_A8SYgib1O3D4N4MLRNk_ajoWjWBfLwozqunBR22A,1275
43
+ thonnycontrib/img/failed_red_chip.png,sha256=bugmSUXowOKE-izUQ0jllvMDF-fbDcl3kxal9oOEEPg,1647
44
+ thonnycontrib/img/l1test_icon.png,sha256=_J4vsiurAzshR0BDtIkGA7AjZmvveBZdRNzSo2OvMOs,2130
45
+ thonnycontrib/img/l1test_icon_old.png,sha256=78wAbYSyPuR_IfBagDLO_NBOmBQy-K_nWJY_N0adOGY,2086
46
+ thonnycontrib/img/outline_class.png,sha256=J04g23VmEdyjgCJInSs9qJIJsV3WTHFSqerLlHYhAnM,628
47
+ thonnycontrib/img/outline_method.gif,sha256=2mlcRjS9IfWHpylJKHNyoZ0eNNTfYjkqzYR_r6pQVvQ,578
48
+ thonnycontrib/img/passed.png,sha256=s-ffI8n-w_MGm2m5vw1pqoo3vmtQ8HfR9uw979Oe_gw,1213
49
+ thonnycontrib/img/pending_icon.png,sha256=wxusE9533Jcm-zlPERakTXRjMq8oMTU9j3EtBbSY9II,2144
50
+ thonnycontrib/img/restart_icon.png,sha256=xz2wk4xU_2E-NLwd8s09EjbIRCXqHjK9vsiGPjtdeak,997
51
+ thonnycontrib/img/success_green_chip.png,sha256=yt8PX3pcW5mSrZ6EboAA_Pzmc8O7RU2qlsjNY53SnbM,1625
52
+ thonnycontrib/img/warning.png,sha256=_ZWOx68f1WeUB2C9SXWve4A4RiPoaAiQOUiYOcC7RnU,1073
53
+ thonnycontrib/l1test_configuration/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
54
+ thonnycontrib/l1test_configuration/l1test_options.py,sha256=_DG_CPAb4BUf_-u88Ttt7dndLfVOjPLTbP1pwfxg3EY,5357
55
+ thonnycontrib/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
56
+ thonnycontrib/tests/test_evaluator_source_tests.py,sha256=D4tSALZEDWi42SaqFn7g-0P38anW3sBWurkATm5NHjk,9254
57
+ thonnycontrib/tests/tests_approx_comp.py,sha256=-j8qSrgQ3jOkHHJS_AIVO7QEUnP5Y5Q9iTctSJ7hr7c,12067
58
+ thonnycontrib/tests/tests_ast_parser.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
59
+ thonnycontrib/tests/tests_doc_generator.py,sha256=eot3JxLzqorbnRcRYztVT8Q6UX1_3JHA4n3GDSAtvcs,18649
60
+ thonnycontrib/tests/tests_example_no_expected.py,sha256=Mc1e-XOy4F7URbDz5XlnW5_MI_PvsbliEYKBkPhESp4,5767
61
+ thonnycontrib/tests/tests_example_with_exception.py,sha256=JZ_7tcq7xstJhECVFdm8nQk89Mg6xOW1SBgptyVqFsY,18284
62
+ thonnycontrib/tests/tests_example_with_expected.py,sha256=nZokKHDP35vPQW4hrryiSgcs3vkt5eZT04xyUFPtV0M,23411
63
+ thonnycontrib/tests/tests_float_prompt.py,sha256=mQJ5K5HI0BKMOhkOgoeabHPS19qK8Fd-BJeAUbhgpS4,5715
64
+ thonnycontrib/tests/tests_l1TestRunner.py,sha256=W1_2UNqpK09HDIeSVdvWWRhsib3vbrsvcC_NxAPucew,7921
65
+ thonnycontrib/tests/tests_l1test_options.py,sha256=lE2kel-X9a11Wi7IJ5ikQu6-9hmChqNmYRk0qNsEFfU,2234
66
+ thonnycontrib/tests/tests_main_generator.py,sha256=_bQnwo_2GNfAgviB1wbBIl7WZBAvs-SXpLzRtgWzoEQ,1850
67
+ thonnycontrib/tests/tests_test_finder.py,sha256=FZjkh9TH1wEFarBAgHBIYB-uucwi0uGAmgedX51QEm0,6202
68
+ thonnycontrib/tests/tests_utils.py,sha256=HtwNvVsfzUg0ovVrCBvxwU4udYXNkS3MxCzRaKpoy0k,507
69
+ thonnycontrib/tests/tests_view.py,sha256=bfJjEghELBPxGTWxrlU5heKdSMWfLYwSPjIP3TPVO2o,14854
70
+ thonnycontrib/tests/fixtures/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
71
+ thonnycontrib/tests/fixtures/backend_mock.py,sha256=qZPsVuL7z716zvlgAT8lLpjwaIHcNkOqJNcwf-vVU-8,348
72
+ thonnycontrib/tests/fixtures/workbench_mock.py,sha256=3OxBetnMGPhV9xxpvE7h9Fhco4OyC3Uyc-JO-7E5qZM,1767
73
+ l1test-3.3.0.dist-info/LICENSE,sha256=ACwmltkrXIz5VsEQcrqljq-fat6ZXAMepjXGoe40KtE,1069
74
+ l1test-3.3.0.dist-info/METADATA,sha256=gFdQrm37YKOEoXh8dcgpzCsiuX--BVQZOBpSup4HrDQ,2639
75
+ l1test-3.3.0.dist-info/WHEEL,sha256=EWGgdj_eH-g9dwsWZOTG0kmGucEuKPxGzOKD-jAVUHs,92
76
+ l1test-3.3.0.dist-info/top_level.txt,sha256=thF9WQtY_lcNKOOR4SQeeWLAVWb4i8XhdGC7pEMAOHY,14
77
+ l1test-3.3.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: bdist_wheel (0.48.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ thonnycontrib
@@ -0,0 +1,56 @@
1
+ '''
2
+ Permet de générer pour le plugin de log une synthèse des tests exécutés.
3
+ Corentin.
4
+ '''
5
+
6
+ from typing import List
7
+ from thonny import get_workbench
8
+ from .backend.ast_parser import L1DocTest
9
+
10
+ #Attention si le nom change ici, il faut aussi le changer dans Thonny-LoggingPlugin
11
+ NOM_EVENT_TEST = "l1Tests"
12
+ NOM_EVENT_DOC = "l1Tests.DocGenerator"
13
+ wb = get_workbench()
14
+
15
+ # Modifié par Mathieu Bachelet, PJI 2022-2023, mais sur la V2 de L1test
16
+ # Modifié par Mirabelle pour adaptation à la V3 de L1test
17
+ def log_in_thonny(
18
+ test_results: List[L1DocTest],
19
+ filename: str,
20
+ selected,
21
+ status: bool = True,
22
+ error: str | None = None,
23
+ ):
24
+ tests_data = []
25
+ if status:
26
+ for l1doctest in test_results:
27
+ for example in l1doctest.get_examples():
28
+ # test:Example
29
+ verdict = example.get_verdict() # type ExampleVerdict
30
+ res = vars(verdict).copy() # pour récupérer les attributs filename, lineno, tested_line, expected_results, details
31
+ res['details'] = str(res['details']) # sinon on peut récupérer un entier
32
+ res['verdict'] = type(verdict).__name__ # pour connaître le verdict, qui n'est pas dans une champ quelconque mais ds le type lui-même
33
+ res['name'] = l1doctest.get_name() # nom fonction ou classe
34
+ res['status'] = verdict.isSuccess() # True si test au vert
35
+ tests_data.append(res)
36
+ wb.event_generate(
37
+ NOM_EVENT_TEST,
38
+ None,
39
+ selected=selected,
40
+ tests=tests_data,
41
+ filename=filename,
42
+ status=status,
43
+ error=error,
44
+ )
45
+
46
+
47
+ def log_doc_in_thonny(docstring_data:tuple):#node):
48
+ if wb:
49
+ selected_lineno, filename, source = docstring_data
50
+ wb.event_generate(NOM_EVENT_DOC,None, selected_lineno=selected_lineno, filename=filename, signature=source) # TODO : non
51
+
52
+
53
+ #La fonction anonyme car il faut une fonction pour bind, avec un argument parce qu'elle reçoit l'événement.
54
+ if wb:
55
+ wb.bind(NOM_EVENT_TEST, lambda x : 0, True)
56
+ wb.bind(NOM_EVENT_DOC, lambda x : 0, True)
File without changes
File without changes
@@ -0,0 +1,116 @@
1
+ # fonction approx pour comparer des flottants avec une précision fournie
2
+ # très largement inspiré du approx de pytest
3
+ # https://docs.pytest.org/en/4.6.x/_modules/_pytest/python_api.html#approx
4
+ # Auteur : Mirabelle
5
+
6
+ # La fonction approx crée un objet de type ApproxXXX
7
+ # Les objets ApproxXXX contiennent une méthode __eq__ qui prend en compte
8
+ # la tolérance passée en paramètre ou celle par défaut
9
+ # C'est ainsi que fait pytest. Ça marche car x == y est récrit en Python en
10
+ # x.__eq__(y) MAIS il semble que c'est finalement y.__eq__(x) qui est exécuté,
11
+ # peut-être quand le __eq__ de x ne sait pas répondre.
12
+ # Donc x == approx(y) exécute ApproxXXX(y).__eq__(x)
13
+ # démo :
14
+ # >>> class truc(object):
15
+ # ... def __eq__(self, other):
16
+ # ... print("eq truc")
17
+ # ...
18
+ # >>> t = truc()
19
+ # >>> 1 == t
20
+ # eq truc
21
+ # >>> "ert" == t
22
+ # eq truc
23
+ # >>> [] == t
24
+ # eq truc
25
+ # >>> None == t
26
+ # eq truc
27
+
28
+ from ..i18n.languages import tr
29
+
30
+ DEFAULT_TOLERANCE = 1e-6
31
+
32
+ def are_close(x:float, y:float, tol:float) -> bool:
33
+ """
34
+ Compare x et y avec une tolérance tol.
35
+ """
36
+ return abs(x - y) <= tol
37
+
38
+ from abc import ABC, abstractmethod
39
+
40
+ class ApproxBase(ABC):
41
+ DEFAULT_TOLERANCE = 1e-6
42
+
43
+ def __init__(self, expected, tol=None):
44
+ self.expected = expected
45
+ self.tolerance = tol if tol is not None else self.DEFAULT_TOLERANCE
46
+
47
+ def __eq__(self, actual) -> bool:
48
+ return self.compare(actual)
49
+
50
+ @abstractmethod
51
+ def compare(self, actual) -> bool:
52
+ """
53
+ Determines whether the actual value is approximately equal to the expected value, within the specified tolerance.
54
+
55
+ Args:
56
+ actual: The actual value to compare with the expected value.
57
+
58
+ Returns:
59
+ True if the actual value is approximately equal to the expected value, within the specified tolerance. False otherwise.
60
+ """
61
+ pass
62
+
63
+ def __repr__(self):
64
+ return "{} +- {}".format(self.expected, self.tolerance)
65
+
66
+
67
+ class ApproxSimple(ApproxBase):
68
+
69
+ def compare(self, actual) -> bool:
70
+ return are_close(self.expected, actual, self.tolerance)
71
+
72
+
73
+ class ApproxList(ApproxBase):
74
+
75
+ def compare(self, actual) -> bool:
76
+ if len(self.expected) != len(actual):
77
+ return False
78
+ return all(are_close(e, a, self.tolerance) for e, a in zip(self.expected, actual))
79
+
80
+
81
+ class ApproxDict(ApproxBase):
82
+
83
+ def compare(self, actual) -> bool:
84
+ if (len(self.expected) != len(actual)) or (set(self.expected.keys()) != set(actual.keys())):
85
+ return False
86
+ return all(are_close(self.expected[k], actual[k], self.tolerance) for k in self.expected.keys())
87
+
88
+
89
+ class ApproxTuple(ApproxBase):
90
+
91
+ def compare(self, actual) -> bool:
92
+ if len(self.expected) != len(actual):
93
+ return False
94
+ return all(are_close(e, a, self.tolerance) for e, a in zip(self.expected, actual))
95
+
96
+
97
+ def approx(expected, tol=None) -> ApproxBase:
98
+ """
99
+ Renvoie un objet qui saura comparer expected avec
100
+ une autre valeur (par __eq__) éventuellement avec une tolérance
101
+ tol.
102
+ """
103
+ if tol and tol<0:
104
+ raise ValueError("La tolérance doit être positive ou nulle : {}".format(tol))
105
+ if isinstance(expected, float) or isinstance(expected, int):
106
+ return ApproxSimple(expected, tol)
107
+ if isinstance(expected, list):
108
+ if all((isinstance(x, int) or isinstance(x, float)) for x in expected):
109
+ return ApproxList(expected, tol)
110
+ if isinstance(expected, dict):
111
+ if all((isinstance(x, int) or isinstance(x, float)) for x in expected.values()):
112
+ return ApproxDict(expected, tol)
113
+ if isinstance(expected,tuple):
114
+ if all((isinstance(x, int) or isinstance(x, float)) for x in expected):
115
+ return ApproxTuple(expected, tol)
116
+ raise TypeError("approx ne s'applique pas au type" + f" {type(expected).__name__}")