From 9d8583a3b67682442d0ab4383bdf748770105af2 Mon Sep 17 00:00:00 2001 From: ChrisTerBeke Date: Mon, 19 Nov 2018 15:10:35 +0100 Subject: [PATCH] Revert "Fix running tests in plugin using pytest" This reverts commit f8f133d2ef92dfabb636eac70b09e681bd4b4d63. --- .../tests/TestLegacyProfileReader.py | 9 ++++----- .../tests/TestVersionUpgrade25to26.py | 11 +++-------- .../tests/TestVersionUpgrade26to27.py | 9 ++++----- .../tests/TestVersionUpgrade27to30.py | 8 ++++---- .../tests/TestVersionUpgrade34to35.py | 10 ++++------ 5 files changed, 19 insertions(+), 28 deletions(-) diff --git a/plugins/LegacyProfileReader/tests/TestLegacyProfileReader.py b/plugins/LegacyProfileReader/tests/TestLegacyProfileReader.py index 3c9e46b6d8..480a61f301 100644 --- a/plugins/LegacyProfileReader/tests/TestLegacyProfileReader.py +++ b/plugins/LegacyProfileReader/tests/TestLegacyProfileReader.py @@ -1,7 +1,8 @@ # Copyright (c) 2018 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. + import configparser # An input for some functions we're testing. -import os # To find the integration test .ini files. +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. @@ -10,15 +11,13 @@ import UM.PluginRegistry # To mock the plug-in registry out. import UM.Settings.ContainerRegistry # To mock the container registry out. import UM.Settings.InstanceContainer # To intercept the serialised data from the read() function. -import plugins.LegacyProfileReader.LegacyProfileReader as LegacyProfileReaderModule -from plugins.LegacyProfileReader.LegacyProfileReader import LegacyProfileReader - +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() - test_prepareDefaultsData = [ { "defaults": diff --git a/plugins/VersionUpgrade/VersionUpgrade25to26/tests/TestVersionUpgrade25to26.py b/plugins/VersionUpgrade/VersionUpgrade25to26/tests/TestVersionUpgrade25to26.py index 588c0cb3db..9d7c7646cc 100644 --- a/plugins/VersionUpgrade/VersionUpgrade25to26/tests/TestVersionUpgrade25to26.py +++ b/plugins/VersionUpgrade/VersionUpgrade25to26/tests/TestVersionUpgrade25to26.py @@ -1,17 +1,16 @@ # Copyright (c) 2017 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. -import configparser -import pytest -from plugins.VersionUpgrade.VersionUpgrade25to26 import VersionUpgrade25to26 +import configparser #To check whether the appropriate exceptions are raised. +import pytest #To register tests with. +import VersionUpgrade25to26 #The module we're testing. ## Creates an instance of the upgrader to test with. @pytest.fixture def upgrader(): return VersionUpgrade25to26.VersionUpgrade25to26() - test_cfg_version_good_data = [ { "test_name": "Simple", @@ -61,7 +60,6 @@ setting_version = -3 } ] - ## Tests the technique that gets the version number from CFG files. # # \param data The parametrised data to test with. It contains a test name @@ -118,7 +116,6 @@ version = 1.2 } ] - ## Tests whether getting a version number from bad CFG files gives an # exception. # @@ -158,7 +155,6 @@ foo = bar } ] - ## Tests whether the settings that should be removed are removed for the 2.6 # version of preferences. @pytest.mark.parametrize("data", test_upgrade_preferences_removed_settings_data) @@ -204,7 +200,6 @@ type = instance_container } ] - ## Tests whether the settings that should be removed are removed for the 2.6 # version of instance containers. @pytest.mark.parametrize("data", test_upgrade_instance_container_removed_settings_data) diff --git a/plugins/VersionUpgrade/VersionUpgrade26to27/tests/TestVersionUpgrade26to27.py b/plugins/VersionUpgrade/VersionUpgrade26to27/tests/TestVersionUpgrade26to27.py index 45d41e7a1b..eebaca23c6 100644 --- a/plugins/VersionUpgrade/VersionUpgrade26to27/tests/TestVersionUpgrade26to27.py +++ b/plugins/VersionUpgrade/VersionUpgrade26to27/tests/TestVersionUpgrade26to27.py @@ -1,16 +1,15 @@ # Copyright (c) 2017 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. -import configparser -import pytest -from plugins.VersionUpgrade.VersionUpgrade26to27.VersionUpgrade26to27 import VersionUpgrade26to27 +import configparser #To check whether the appropriate exceptions are raised. +import pytest #To register tests with. +import VersionUpgrade26to27 #The module we're testing. ## Creates an instance of the upgrader to test with. @pytest.fixture def upgrader(): - return VersionUpgrade26to27() - + return VersionUpgrade26to27.VersionUpgrade26to27() test_cfg_version_good_data = [ { diff --git a/plugins/VersionUpgrade/VersionUpgrade27to30/tests/TestVersionUpgrade27to30.py b/plugins/VersionUpgrade/VersionUpgrade27to30/tests/TestVersionUpgrade27to30.py index 7b77b85993..cae08ebcfd 100644 --- a/plugins/VersionUpgrade/VersionUpgrade27to30/tests/TestVersionUpgrade27to30.py +++ b/plugins/VersionUpgrade/VersionUpgrade27to30/tests/TestVersionUpgrade27to30.py @@ -1,15 +1,15 @@ # Copyright (c) 2017 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. -import configparser -import pytest -from plugins.VersionUpgrade.VersionUpgrade27to30.VersionUpgrade27to30 import VersionUpgrade27to30 +import configparser #To parse the resulting config files. +import pytest #To register tests with. +import VersionUpgrade27to30 #The module we're testing. ## Creates an instance of the upgrader to test with. @pytest.fixture def upgrader(): - return VersionUpgrade27to30() + return VersionUpgrade27to30.VersionUpgrade27to30() test_cfg_version_good_data = [ { diff --git a/plugins/VersionUpgrade/VersionUpgrade34to35/tests/TestVersionUpgrade34to35.py b/plugins/VersionUpgrade/VersionUpgrade34to35/tests/TestVersionUpgrade34to35.py index 4f77fcd093..b74e6f35ac 100644 --- a/plugins/VersionUpgrade/VersionUpgrade34to35/tests/TestVersionUpgrade34to35.py +++ b/plugins/VersionUpgrade/VersionUpgrade34to35/tests/TestVersionUpgrade34to35.py @@ -1,16 +1,15 @@ # Copyright (c) 2018 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. -import configparser -import pytest -from plugins.VersionUpgrade.VersionUpgrade34to35.VersionUpgrade34to35 import VersionUpgrade34to35 +import configparser #To parse the resulting config files. +import pytest #To register tests with. +import VersionUpgrade34to35 #The module we're testing. ## Creates an instance of the upgrader to test with. @pytest.fixture def upgrader(): - return VersionUpgrade34to35() - + return VersionUpgrade34to35.VersionUpgrade34to35() test_upgrade_version_nr_data = [ ("Empty config file", @@ -26,7 +25,6 @@ test_upgrade_version_nr_data = [ ) ] - ## Tests whether the version numbers are updated. @pytest.mark.parametrize("test_name, file_data", test_upgrade_version_nr_data) def test_upgradeVersionNr(test_name, file_data, upgrader):