l1test 3.3.0__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 (83) hide show
  1. l1test-3.3.0/LICENSE +21 -0
  2. l1test-3.3.0/PKG-INFO +62 -0
  3. l1test-3.3.0/README.md +18 -0
  4. l1test-3.3.0/l1test.egg-info/PKG-INFO +62 -0
  5. l1test-3.3.0/l1test.egg-info/SOURCES.txt +81 -0
  6. l1test-3.3.0/l1test.egg-info/dependency_links.txt +1 -0
  7. l1test-3.3.0/l1test.egg-info/requires.txt +1 -0
  8. l1test-3.3.0/l1test.egg-info/top_level.txt +1 -0
  9. l1test-3.3.0/pyproject.toml +28 -0
  10. l1test-3.3.0/setup.cfg +4 -0
  11. l1test-3.3.0/setup.py +55 -0
  12. l1test-3.3.0/thonnycontrib/ThonnyLogsGenerator.py +56 -0
  13. l1test-3.3.0/thonnycontrib/__init__.py +0 -0
  14. l1test-3.3.0/thonnycontrib/backend/__init__.py +0 -0
  15. l1test-3.3.0/thonnycontrib/backend/approx_comp.py +116 -0
  16. l1test-3.3.0/thonnycontrib/backend/ast_parser.py +450 -0
  17. l1test-3.3.0/thonnycontrib/backend/doctest_parser.py +945 -0
  18. l1test-3.3.0/thonnycontrib/backend/evaluator.py +148 -0
  19. l1test-3.3.0/thonnycontrib/backend/l1test_backend.py +105 -0
  20. l1test-3.3.0/thonnycontrib/backend/test_finder.py +143 -0
  21. l1test-3.3.0/thonnycontrib/backend/verdicts/ExampleVerdict.py +75 -0
  22. l1test-3.3.0/thonnycontrib/backend/verdicts/ExceptionVerdict.py +17 -0
  23. l1test-3.3.0/thonnycontrib/backend/verdicts/FailedVerdict.py +33 -0
  24. l1test-3.3.0/thonnycontrib/backend/verdicts/FailedWhenExceptionExpectedVerdict.py +20 -0
  25. l1test-3.3.0/thonnycontrib/backend/verdicts/PassedSetupVerdict.py +15 -0
  26. l1test-3.3.0/thonnycontrib/backend/verdicts/PassedVerdict.py +17 -0
  27. l1test-3.3.0/thonnycontrib/backend/verdicts/__init__.py +0 -0
  28. l1test-3.3.0/thonnycontrib/environement_vars.py +28 -0
  29. l1test-3.3.0/thonnycontrib/exceptions.py +124 -0
  30. l1test-3.3.0/thonnycontrib/frontend/__init__.py +22 -0
  31. l1test-3.3.0/thonnycontrib/frontend/docstring_generator/__init__.py +16 -0
  32. l1test-3.3.0/thonnycontrib/frontend/docstring_generator/doc_generator.py +449 -0
  33. l1test-3.3.0/thonnycontrib/frontend/docstring_generator/doc_template.py +87 -0
  34. l1test-3.3.0/thonnycontrib/frontend/l1test_error_view.py +74 -0
  35. l1test-3.3.0/thonnycontrib/frontend/l1test_outliner_menu.py +103 -0
  36. l1test-3.3.0/thonnycontrib/frontend/l1test_reporter.py +64 -0
  37. l1test-3.3.0/thonnycontrib/frontend/l1test_runner.py +518 -0
  38. l1test-3.3.0/thonnycontrib/frontend/l1test_treeview.py +932 -0
  39. l1test-3.3.0/thonnycontrib/frontend/main_generator/__init__.py +1 -0
  40. l1test-3.3.0/thonnycontrib/frontend/main_generator/main_generator.py +81 -0
  41. l1test-3.3.0/thonnycontrib/i18n/__init__.py +0 -0
  42. l1test-3.3.0/thonnycontrib/i18n/languages.py +28 -0
  43. l1test-3.3.0/thonnycontrib/i18n/locale/en_US/LC_MESSAGES/l1test.mo +0 -0
  44. l1test-3.3.0/thonnycontrib/i18n/locale/en_US/LC_MESSAGES/l1test.po +228 -0
  45. l1test-3.3.0/thonnycontrib/i18n/locale/fr_FR/LC_MESSAGES/l1test.mo +0 -0
  46. l1test-3.3.0/thonnycontrib/i18n/locale/fr_FR/LC_MESSAGES/l1test.po +269 -0
  47. l1test-3.3.0/thonnycontrib/i18n/locale/l1test.pot +235 -0
  48. l1test-3.3.0/thonnycontrib/img/error_icon.png +0 -0
  49. l1test-3.3.0/thonnycontrib/img/exception_red_chip.png +0 -0
  50. l1test-3.3.0/thonnycontrib/img/failed.png +0 -0
  51. l1test-3.3.0/thonnycontrib/img/failed_red_chip.png +0 -0
  52. l1test-3.3.0/thonnycontrib/img/l1test_icon.png +0 -0
  53. l1test-3.3.0/thonnycontrib/img/l1test_icon_old.png +0 -0
  54. l1test-3.3.0/thonnycontrib/img/outline_class.png +0 -0
  55. l1test-3.3.0/thonnycontrib/img/outline_method.gif +0 -0
  56. l1test-3.3.0/thonnycontrib/img/passed.png +0 -0
  57. l1test-3.3.0/thonnycontrib/img/pending_icon.png +0 -0
  58. l1test-3.3.0/thonnycontrib/img/restart_icon.png +0 -0
  59. l1test-3.3.0/thonnycontrib/img/success_green_chip.png +0 -0
  60. l1test-3.3.0/thonnycontrib/img/warning.png +0 -0
  61. l1test-3.3.0/thonnycontrib/l1test_configuration/__init__.py +0 -0
  62. l1test-3.3.0/thonnycontrib/l1test_configuration/l1test_options.py +122 -0
  63. l1test-3.3.0/thonnycontrib/plugin_loader.py +184 -0
  64. l1test-3.3.0/thonnycontrib/properties.py +77 -0
  65. l1test-3.3.0/thonnycontrib/tests/__init__.py +0 -0
  66. l1test-3.3.0/thonnycontrib/tests/fixtures/__init__.py +0 -0
  67. l1test-3.3.0/thonnycontrib/tests/fixtures/backend_mock.py +11 -0
  68. l1test-3.3.0/thonnycontrib/tests/fixtures/workbench_mock.py +47 -0
  69. l1test-3.3.0/thonnycontrib/tests/test_evaluator_source_tests.py +276 -0
  70. l1test-3.3.0/thonnycontrib/tests/tests_approx_comp.py +344 -0
  71. l1test-3.3.0/thonnycontrib/tests/tests_ast_parser.py +0 -0
  72. l1test-3.3.0/thonnycontrib/tests/tests_doc_generator.py +392 -0
  73. l1test-3.3.0/thonnycontrib/tests/tests_example_no_expected.py +140 -0
  74. l1test-3.3.0/thonnycontrib/tests/tests_example_with_exception.py +431 -0
  75. l1test-3.3.0/thonnycontrib/tests/tests_example_with_expected.py +604 -0
  76. l1test-3.3.0/thonnycontrib/tests/tests_float_prompt.py +153 -0
  77. l1test-3.3.0/thonnycontrib/tests/tests_l1TestRunner.py +176 -0
  78. l1test-3.3.0/thonnycontrib/tests/tests_l1test_options.py +64 -0
  79. l1test-3.3.0/thonnycontrib/tests/tests_main_generator.py +48 -0
  80. l1test-3.3.0/thonnycontrib/tests/tests_test_finder.py +201 -0
  81. l1test-3.3.0/thonnycontrib/tests/tests_utils.py +14 -0
  82. l1test-3.3.0/thonnycontrib/tests/tests_view.py +340 -0
  83. l1test-3.3.0/thonnycontrib/utils.py +486 -0
l1test-3.3.0/LICENSE ADDED
@@ -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.
l1test-3.3.0/PKG-INFO ADDED
@@ -0,0 +1,62 @@
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
+
45
+ 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.
46
+
47
+ Building
48
+
49
+ To build a wheel for the plugin you can use the Makefile in this directory:
50
+
51
+ ```
52
+ make build
53
+ ```
54
+
55
+ If you need to ensure Python 3 is used (for example when `python` points to Python 2), run:
56
+
57
+ ```
58
+ make build3
59
+ ```
60
+
61
+ Note: the `build3` Makefile target forces the build to use Python 3. Use
62
+ `make build3` on systems where `python` defaults to Python 2.
l1test-3.3.0/README.md ADDED
@@ -0,0 +1,18 @@
1
+ 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.
2
+
3
+ Building
4
+
5
+ To build a wheel for the plugin you can use the Makefile in this directory:
6
+
7
+ ```
8
+ make build
9
+ ```
10
+
11
+ If you need to ensure Python 3 is used (for example when `python` points to Python 2), run:
12
+
13
+ ```
14
+ make build3
15
+ ```
16
+
17
+ Note: the `build3` Makefile target forces the build to use Python 3. Use
18
+ `make build3` on systems where `python` defaults to Python 2.
@@ -0,0 +1,62 @@
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
+
45
+ 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.
46
+
47
+ Building
48
+
49
+ To build a wheel for the plugin you can use the Makefile in this directory:
50
+
51
+ ```
52
+ make build
53
+ ```
54
+
55
+ If you need to ensure Python 3 is used (for example when `python` points to Python 2), run:
56
+
57
+ ```
58
+ make build3
59
+ ```
60
+
61
+ Note: the `build3` Makefile target forces the build to use Python 3. Use
62
+ `make build3` on systems where `python` defaults to Python 2.
@@ -0,0 +1,81 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ setup.py
5
+ l1test.egg-info/PKG-INFO
6
+ l1test.egg-info/SOURCES.txt
7
+ l1test.egg-info/dependency_links.txt
8
+ l1test.egg-info/requires.txt
9
+ l1test.egg-info/top_level.txt
10
+ thonnycontrib/ThonnyLogsGenerator.py
11
+ thonnycontrib/__init__.py
12
+ thonnycontrib/environement_vars.py
13
+ thonnycontrib/exceptions.py
14
+ thonnycontrib/plugin_loader.py
15
+ thonnycontrib/properties.py
16
+ thonnycontrib/utils.py
17
+ thonnycontrib/backend/__init__.py
18
+ thonnycontrib/backend/approx_comp.py
19
+ thonnycontrib/backend/ast_parser.py
20
+ thonnycontrib/backend/doctest_parser.py
21
+ thonnycontrib/backend/evaluator.py
22
+ thonnycontrib/backend/l1test_backend.py
23
+ thonnycontrib/backend/test_finder.py
24
+ thonnycontrib/backend/verdicts/ExampleVerdict.py
25
+ thonnycontrib/backend/verdicts/ExceptionVerdict.py
26
+ thonnycontrib/backend/verdicts/FailedVerdict.py
27
+ thonnycontrib/backend/verdicts/FailedWhenExceptionExpectedVerdict.py
28
+ thonnycontrib/backend/verdicts/PassedSetupVerdict.py
29
+ thonnycontrib/backend/verdicts/PassedVerdict.py
30
+ thonnycontrib/backend/verdicts/__init__.py
31
+ thonnycontrib/frontend/__init__.py
32
+ thonnycontrib/frontend/l1test_error_view.py
33
+ thonnycontrib/frontend/l1test_outliner_menu.py
34
+ thonnycontrib/frontend/l1test_reporter.py
35
+ thonnycontrib/frontend/l1test_runner.py
36
+ thonnycontrib/frontend/l1test_treeview.py
37
+ thonnycontrib/frontend/docstring_generator/__init__.py
38
+ thonnycontrib/frontend/docstring_generator/doc_generator.py
39
+ thonnycontrib/frontend/docstring_generator/doc_template.py
40
+ thonnycontrib/frontend/main_generator/__init__.py
41
+ thonnycontrib/frontend/main_generator/main_generator.py
42
+ thonnycontrib/i18n/__init__.py
43
+ thonnycontrib/i18n/languages.py
44
+ thonnycontrib/i18n/locale/l1test.pot
45
+ thonnycontrib/i18n/locale/en_US/LC_MESSAGES/l1test.mo
46
+ thonnycontrib/i18n/locale/en_US/LC_MESSAGES/l1test.po
47
+ thonnycontrib/i18n/locale/fr_FR/LC_MESSAGES/l1test.mo
48
+ thonnycontrib/i18n/locale/fr_FR/LC_MESSAGES/l1test.po
49
+ thonnycontrib/img/error_icon.png
50
+ thonnycontrib/img/exception_red_chip.png
51
+ thonnycontrib/img/failed.png
52
+ thonnycontrib/img/failed_red_chip.png
53
+ thonnycontrib/img/l1test_icon.png
54
+ thonnycontrib/img/l1test_icon_old.png
55
+ thonnycontrib/img/outline_class.png
56
+ thonnycontrib/img/outline_method.gif
57
+ thonnycontrib/img/passed.png
58
+ thonnycontrib/img/pending_icon.png
59
+ thonnycontrib/img/restart_icon.png
60
+ thonnycontrib/img/success_green_chip.png
61
+ thonnycontrib/img/warning.png
62
+ thonnycontrib/l1test_configuration/__init__.py
63
+ thonnycontrib/l1test_configuration/l1test_options.py
64
+ thonnycontrib/tests/__init__.py
65
+ thonnycontrib/tests/test_evaluator_source_tests.py
66
+ thonnycontrib/tests/tests_approx_comp.py
67
+ thonnycontrib/tests/tests_ast_parser.py
68
+ thonnycontrib/tests/tests_doc_generator.py
69
+ thonnycontrib/tests/tests_example_no_expected.py
70
+ thonnycontrib/tests/tests_example_with_exception.py
71
+ thonnycontrib/tests/tests_example_with_expected.py
72
+ thonnycontrib/tests/tests_float_prompt.py
73
+ thonnycontrib/tests/tests_l1TestRunner.py
74
+ thonnycontrib/tests/tests_l1test_options.py
75
+ thonnycontrib/tests/tests_main_generator.py
76
+ thonnycontrib/tests/tests_test_finder.py
77
+ thonnycontrib/tests/tests_utils.py
78
+ thonnycontrib/tests/tests_view.py
79
+ thonnycontrib/tests/fixtures/__init__.py
80
+ thonnycontrib/tests/fixtures/backend_mock.py
81
+ thonnycontrib/tests/fixtures/workbench_mock.py
@@ -0,0 +1 @@
1
+ thonny>=4.0.0
@@ -0,0 +1 @@
1
+ thonnycontrib
@@ -0,0 +1,28 @@
1
+ [build-system]
2
+ requires = ["setuptools>61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "l1test"
7
+ version = "3.3.0"
8
+ authors = [
9
+ { name="Mirabelle NEBUT", email="mirabelle.nebut@univ-lille.fr" },
10
+ { name="Reda ID TALEB", email="reda@example.com"},
11
+ ]
12
+ description = "A basic unit testing tool for novice programmers provided as a Thonny plugin"
13
+ readme = "README.md"
14
+ license = { file="LICENSE" }
15
+ requires-python = ">=3.9"
16
+ classifiers = [
17
+ "Programming Language :: Python :: 3",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Operating System :: OS Independent",
20
+ "Development Status :: 4 - Beta",
21
+ "Topic :: Software Development :: Testing",
22
+ "Topic :: Education",
23
+ "Intended Audience :: Education",
24
+ "Intended Audience :: Developers"
25
+ ]
26
+ dependencies = ["thonny>=4.0.0"]
27
+
28
+
l1test-3.3.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
l1test-3.3.0/setup.py ADDED
@@ -0,0 +1,55 @@
1
+ # Auteur : Esteban COLLARD, Nordine EL AMMARI
2
+ # Modifications : Reda ID TALEB & Manal LAGHMICH
3
+
4
+ from setuptools import find_packages, setup
5
+ import os.path
6
+
7
+
8
+ def recursive_files(directory):
9
+ paths = []
10
+ for (path, _, filenames) in os.walk(directory):
11
+ for filename in filenames:
12
+ if not filename.endswith(".pyc"):
13
+ paths.append(os.path.join('..', path, filename))
14
+ return paths
15
+
16
+ packages = find_packages()
17
+
18
+ def get_packages_data(packages: list[str]=packages):
19
+ py_packs = dict([(p, ["*.py"]) for p in packages])
20
+ unpackaged = {"": recursive_files("thonnycontrib/i18n/locale") + recursive_files("thonnycontrib/img")}
21
+ return {**py_packs, **unpackaged}
22
+
23
+ setupdir = os.path.dirname(__file__)
24
+
25
+
26
+ requirements = []
27
+ for line in open(os.path.join(setupdir, "requirements.txt"), encoding="ASCII"):
28
+ if line.strip() and not line.startswith("#"):
29
+ requirements.append(line)
30
+
31
+ setup(
32
+ name="l1test",
33
+ version="3.3.0",
34
+ author="Mirabelle MARVIE-NEBUT, Reda ID TALEB",
35
+ description="A plug-in which adds a test framework",
36
+ long_description="""A plug-in for Thonny which allows you to test your doc examples
37
+
38
+ More info: https://gitlab.univ-lille.fr/mirabelle.nebut/thonny-tests""",
39
+ url="https://gitlab.univ-lille.fr/mirabelle.nebut/thonny-tests",
40
+ # keywords="IDE education programming tests in documentation",
41
+ classifiers=[
42
+ "Topic :: Education :: Testing",
43
+ "Programming Language :: Python :: 3",
44
+ "License :: OSI Approved :: MIT License",
45
+ "Operating System :: OS Independent",
46
+ "Development Status :: 4 - Beta",
47
+ "Intended Audience :: Education"
48
+ ],
49
+ platforms=["Windows", "macOS", "Linux"],
50
+ python_requires=">=3.9",
51
+ package_data=get_packages_data(),
52
+ install_requires=requirements,
53
+ packages=packages,
54
+ )
55
+
@@ -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__}")