Add convenience script for running complete coverage

This commit is contained in:
Jaime van Kessel 2019-08-30 16:32:11 +02:00
parent 9b45b56e61
commit 87e0b8629a
6 changed files with 41 additions and 5 deletions

View File

@ -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 = [
{

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

22
run_coverage.py Normal file
View File

@ -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)