diff options
author | Jaime van Kessel <nallath@gmail.com> | 2019-08-30 17:32:11 +0300 |
---|---|---|
committer | Jaime van Kessel <nallath@gmail.com> | 2019-08-30 17:32:11 +0300 |
commit | 87e0b8629a1bacca337a3f3c89209d3d0eafaf99 (patch) | |
tree | ecc2bb3ff0652e37e9e969056c462617fe431b54 | |
parent | 9b45b56e61454f257ca52778474a0352624be1c0 (diff) |
Add convenience script for running complete coverage
6 files changed, 41 insertions, 5 deletions
diff --git a/plugins/LegacyProfileReader/tests/TestLegacyProfileReader.py b/plugins/LegacyProfileReader/tests/TestLegacyProfileReader.py index 480a61f301..05f49017a3 100644 --- a/plugins/LegacyProfileReader/tests/TestLegacyProfileReader.py +++ b/plugins/LegacyProfileReader/tests/TestLegacyProfileReader.py @@ -5,6 +5,9 @@ import configparser # An input for some functions we're testing. import os.path # To find the integration test .ini files. import pytest # To register tests with. import unittest.mock # To mock the application, plug-in and container registry out. +import os.path +import sys +sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..")) import UM.Application # To mock the application out. import UM.PluginRegistry # To mock the plug-in registry out. @@ -12,11 +15,13 @@ import UM.Settings.ContainerRegistry # To mock the container registry out. import UM.Settings.InstanceContainer # To intercept the serialised data from the read() function. import LegacyProfileReader as LegacyProfileReaderModule # To get the directory of the module. -from LegacyProfileReader import LegacyProfileReader # The module we're testing. @pytest.fixture def legacy_profile_reader(): - return LegacyProfileReader() + try: + return LegacyProfileReaderModule.LegacyProfileReader() + except TypeError: + return LegacyProfileReaderModule.LegacyProfileReader.LegacyProfileReader() test_prepareDefaultsData = [ { diff --git a/plugins/VersionUpgrade/VersionUpgrade25to26/tests/TestVersionUpgrade25to26.py b/plugins/VersionUpgrade/VersionUpgrade25to26/tests/TestVersionUpgrade25to26.py index 9d7c7646cc..45cdaebe87 100644 --- a/plugins/VersionUpgrade/VersionUpgrade25to26/tests/TestVersionUpgrade25to26.py +++ b/plugins/VersionUpgrade/VersionUpgrade25to26/tests/TestVersionUpgrade25to26.py @@ -1,5 +1,8 @@ # Copyright (c) 2017 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. +import os.path +import sys +sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..")) import configparser #To check whether the appropriate exceptions are raised. import pytest #To register tests with. diff --git a/plugins/VersionUpgrade/VersionUpgrade26to27/tests/TestVersionUpgrade26to27.py b/plugins/VersionUpgrade/VersionUpgrade26to27/tests/TestVersionUpgrade26to27.py index eebaca23c6..6235578238 100644 --- a/plugins/VersionUpgrade/VersionUpgrade26to27/tests/TestVersionUpgrade26to27.py +++ b/plugins/VersionUpgrade/VersionUpgrade26to27/tests/TestVersionUpgrade26to27.py @@ -3,7 +3,9 @@ import configparser #To check whether the appropriate exceptions are raised. import pytest #To register tests with. - +import os.path +import sys +sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..")) import VersionUpgrade26to27 #The module we're testing. ## Creates an instance of the upgrader to test with. diff --git a/plugins/VersionUpgrade/VersionUpgrade27to30/tests/TestVersionUpgrade27to30.py b/plugins/VersionUpgrade/VersionUpgrade27to30/tests/TestVersionUpgrade27to30.py index cae08ebcfd..8ac6616511 100644 --- a/plugins/VersionUpgrade/VersionUpgrade27to30/tests/TestVersionUpgrade27to30.py +++ b/plugins/VersionUpgrade/VersionUpgrade27to30/tests/TestVersionUpgrade27to30.py @@ -1,6 +1,8 @@ # Copyright (c) 2017 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. - +import os.path +import sys +sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..")) import configparser #To parse the resulting config files. import pytest #To register tests with. diff --git a/plugins/VersionUpgrade/VersionUpgrade34to35/tests/TestVersionUpgrade34to35.py b/plugins/VersionUpgrade/VersionUpgrade34to35/tests/TestVersionUpgrade34to35.py index b74e6f35ac..9f306e74fa 100644 --- a/plugins/VersionUpgrade/VersionUpgrade34to35/tests/TestVersionUpgrade34to35.py +++ b/plugins/VersionUpgrade/VersionUpgrade34to35/tests/TestVersionUpgrade34to35.py @@ -1,6 +1,8 @@ # Copyright (c) 2018 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. - +import os.path +import sys +sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..")) import configparser #To parse the resulting config files. import pytest #To register tests with. diff --git a/run_coverage.py b/run_coverage.py new file mode 100644 index 0000000000..2fd60f9342 --- /dev/null +++ b/run_coverage.py @@ -0,0 +1,22 @@ +import pytest +from pathlib import Path + +# Small helper script to run the coverage of main code & all plugins + +path = Path("plugins") +args = ["--cov" ,"cura" , "--cov-report", "html"] +all_paths = [] +for p in path.glob('**/*'): + if p.is_dir(): + if p.name in ["__pycache__", "tests"]: + continue + args.append("--cov") + args.append(str(p)) + all_paths.append(str(p)) + +for path in all_paths: + args.append(path) +args.append(".") +args.append("-x") +pytest.main(args) + |