From 4e408ac1683f9392a88bbc24e6d7ec0a70c3872c Mon Sep 17 00:00:00 2001 From: Rafael de Lucena Valle Date: Sat, 10 Aug 2024 23:50:25 -0300 Subject: [PATCH 01/18] Executing nose2pytest command --- client/funq/tests/test_aliases.py | 22 +++++++++++----------- client/funq/tests/test_client.py | 24 ++++++++++++------------ client/funq/tests/test_models.py | 22 +++++++++++----------- client/funq/tests/test_noseplugin.py | 8 ++++---- client/funq/tests/test_screenshoter.py | 12 ++++++------ client/funq/tests/test_tools.py | 12 ++++++------ 6 files changed, 50 insertions(+), 50 deletions(-) diff --git a/client/funq/tests/test_aliases.py b/client/funq/tests/test_aliases.py index 6ce9772..5a5719f 100644 --- a/client/funq/tests/test_aliases.py +++ b/client/funq/tests/test_aliases.py @@ -46,7 +46,7 @@ def setup(self): def test_add_one(self): self.aliases['1'] = '2' - assert_equals(self.aliases['1'], '2') + assert self.aliases['1'] == '2' @raises(HooqAliasesKeyError) def test_no_doublons(self): @@ -56,13 +56,13 @@ def test_no_doublons(self): def test_substitution(self): self.aliases['a'] = '1' self.aliases['b'] = '{a}2' - assert_equals(self.aliases['b'], '12') + assert self.aliases['b'] == '12' @raises(HooqAliasesKeyError) def test_bad_substitution(self): self.aliases['b'] = '{a}2' self.aliases['a'] = '1' - assert_equals(self.aliases['b'], '12') + assert self.aliases['b'] == '12' @raises(HooqAliasesKeyError) def test_alias_inexistant(self): @@ -97,7 +97,7 @@ def test_simple_parse(self): a = 1 b = 2 """) - assert_equals(aliases, {'a': '1', 'b': '2'}) + assert aliases == {'a': '1', 'b': '2'} def test_parse_with_comment(self): aliases = self._parse(""" @@ -105,7 +105,7 @@ def test_parse_with_comment(self): # toto = 1 b = 2 """) - assert_equals(aliases, {'a': '1', 'b': '2'}) + assert aliases == {'a': '1', 'b': '2'} def test_parse_with_empty_line(self): aliases = self._parse(""" @@ -113,7 +113,7 @@ def test_parse_with_empty_line(self): b = 2 """) - assert_equals(aliases, {'a': '1', 'b': '2'}) + assert aliases == {'a': '1', 'b': '2'} @raises(HooqAliasesInvalidLineError) def test_parse_with_syntax_error(self): @@ -130,7 +130,7 @@ def test_with_gkit(self): a = {MY_DEFINE}::1 b = 2 """, gkit_data) - assert_equals(aliases, {'MY_DEFINE': '33', 'a': '33::1', 'b': '2'}) + assert aliases == {'MY_DEFINE': '33', 'a': '33::1', 'b': '2'} def test_with_gkit_interpolation(self): gkit_data = """ @@ -142,8 +142,8 @@ def test_with_gkit_interpolation(self): a = {MY_DEFINE}::1 b = {OTHER_DEFINE} """, gkit_data) - assert_equals(aliases, {'MY_DEFINE': '33', 'a': '33::1', - 'OTHER_DEFINE': '33::66', 'b': '33::66'}) + assert aliases == {'MY_DEFINE': '33', 'a': '33::1', + 'OTHER_DEFINE': '33::66', 'b': '33::66'} def test_with_gkit_custom(self): gkit_data = """ @@ -157,7 +157,7 @@ def test_with_gkit_custom(self): b = 2 """ aliases = self._parse(aliases_data, gkit_data) - assert_equals(aliases, {'MY_DEFINE': '33', 'a': '33::1', 'b': '2'}) + assert aliases == {'MY_DEFINE': '33', 'a': '33::1', 'b': '2'} aliases = self._parse(aliases_data, gkit_data, 'kde') - assert_equals(aliases, {'MY_DEFINE': '66', 'a': '66::1', 'b': '2'}) + assert aliases == {'MY_DEFINE': '66', 'a': '66::1', 'b': '2'} diff --git a/client/funq/tests/test_client.py b/client/funq/tests/test_client.py index b527f98..da8fad6 100644 --- a/client/funq/tests/test_client.py +++ b/client/funq/tests/test_client.py @@ -73,48 +73,48 @@ def test_require_executable(self): def test_abs_executable(self): self.set_opt('executable', os.getcwd()) appconf = self.createApplicationConfig() - assert_equals(appconf.executable, os.getcwd()) + assert appconf.executable == os.getcwd() def test_nonabs_executable(self): self.set_opt('executable', 'toto') appconf = self.createApplicationConfig() - assert_equals(appconf.executable, os.path.join(os.getcwd(), 'toto')) + assert appconf.executable == os.path.join(os.getcwd(), 'toto') def test_args(self): self.set_opt('executable', 'toto') self.set_opt('args', 'toto "titi 1" 2') appconf = self.createApplicationConfig() - assert_equals(appconf.args, ['toto', 'titi 1', '2']) + assert appconf.args == ['toto', 'titi 1', '2'] def test_port(self): self.set_opt('executable', 'toto') self.set_opt('funq_port', '12000') appconf = self.createApplicationConfig() - assert_equals(appconf.funq_port, 12000) + assert appconf.funq_port == 12000 def test_timeout_connection(self): self.set_opt('executable', 'toto') self.set_opt('timeout_connection', '5') appconf = self.createApplicationConfig() - assert_equals(appconf.timeout_connection, 5) + assert appconf.timeout_connection == 5 def test_abs_aliases(self): self.set_opt('executable', 'toto') self.set_opt('aliases', os.getcwd()) appconf = self.createApplicationConfig() - assert_equals(appconf.aliases, os.getcwd()) + assert appconf.aliases == os.getcwd() def test_nonabs_aliases(self): self.set_opt('executable', 'toto') self.set_opt('aliases', 'titi') appconf = self.createApplicationConfig() - assert_equals(appconf.aliases, os.path.join(os.getcwd(), 'titi')) + assert appconf.aliases == os.path.join(os.getcwd(), 'titi') def test_stdout_null(self): self.set_opt('executable', 'toto') self.set_opt('executable_stdout', 'NULL') appconf = self.createApplicationConfig() - assert_equals(appconf.executable_stdout, os.devnull) + assert appconf.executable_stdout == os.devnull class TestApplicationRegistry: @@ -130,9 +130,9 @@ def test_register_from_conf(self): self.reg.register_from_conf(conf, GlobalOptions(funq_conf='.')) - assert_equals(len(self.reg.confs), 1) + assert len(self.reg.confs) == 1 - assert_equals(self.reg.config('example').executable, exe) + assert self.reg.config('example').executable == exe class FakePopen(object): @@ -174,7 +174,7 @@ class OptionsDefault: ctx = client.ApplicationContext( appconf, client_class=lambda *a, **kwa: None) - assert_equals(ctx._process.command, ['funq', 'command']) + assert ctx._process.command == ['funq', 'command'] @FakePopen.patch_subprocess_popen def test_start_with_valgrind(self): @@ -189,4 +189,4 @@ class OptionsWithValgrind: ctx = client.ApplicationContext( appconf, client_class=lambda *a, **kwa: None) - assert_equals(ctx._process.command, ['funq', 'valgrind', 'command']) + assert ctx._process.command == ['funq', 'valgrind', 'command'] diff --git a/client/funq/tests/test_models.py b/client/funq/tests/test_models.py index df744d3..8a36df7 100644 --- a/client/funq/tests/test_models.py +++ b/client/funq/tests/test_models.py @@ -43,7 +43,7 @@ class MyWidget(models.Widget): CPP_CLASS = 'TOTO' instance = models.Widget.create(None, {'classes': ['TOTO']}) - assert_is_instance(instance, MyWidget) + assert isinstance(instance, MyWidget) def test_multi_inheritance_priority(self): class MyWidget(models.Widget): @@ -53,7 +53,7 @@ class SomethingFirst(models.Widget): CPP_CLASS = 'TITI' instance = models.Widget.create(None, {'classes': ['TITI', 'TOTO']}) - assert_is_instance(instance, SomethingFirst) + assert isinstance(instance, SomethingFirst) def test_multi_inheritance(self): class MyWidget(models.Widget): @@ -61,7 +61,7 @@ class MyWidget(models.Widget): instance = models.Widget.create( None, {'classes': ['NotDefined', 'TOTO']}) - assert_is_instance(instance, MyWidget) + assert isinstance(instance, MyWidget) class TestModelItems: @@ -98,33 +98,33 @@ def setup(self): def test_row_by_named_path(self): items = self.model_items.row_by_named_path(['0-0', '0-0']) - assert_equals(items, self.model_items.items[0].items[0:2]) + assert items == self.model_items.items[0].items[0:2] def test_row_by_named_path_match_column(self): items = self.model_items.row_by_named_path( ['0-1', '0-1'], match_column=1) - assert_equals(items, self.model_items.items[1].items[0:2]) + assert items == self.model_items.items[1].items[0:2] def test_row_by_named_path_str_path(self): items = self.model_items.row_by_named_path('0-0/0-0') - assert_equals(items, self.model_items.items[0].items[0:2]) + assert items == self.model_items.items[0].items[0:2] def test_row_by_named_path_str_custom_path(self): items = self.model_items.row_by_named_path('0-0::0-0', sep='::') - assert_equals(items, self.model_items.items[0].items[0:2]) + assert items == self.model_items.items[0].items[0:2] def test_row_by_named_path_missing(self): items = self.model_items.row_by_named_path('blah/bluh') - assert_equals(items, None) + assert items == None def test_item_by_named_path(self): item = self.model_items.item_by_named_path(['0-0', '0-0']) - assert_equals(item, self.model_items.items[0].items[0]) + assert item == self.model_items.items[0].items[0] def test_item_by_named_path_column(self): item = self.model_items.item_by_named_path(['0-0', '0-0'], column=1) - assert_equals(item, self.model_items.items[0].items[1]) + assert item == self.model_items.items[0].items[1] def test_item_by_named_path_missing(self): item = self.model_items.item_by_named_path('blah/bluh') - assert_equals(item, None) + assert item == None diff --git a/client/funq/tests/test_noseplugin.py b/client/funq/tests/test_noseplugin.py index 31f89ac..c4ea19d 100644 --- a/client/funq/tests/test_noseplugin.py +++ b/client/funq/tests/test_noseplugin.py @@ -64,9 +64,9 @@ def test_simple_configure(): funqconf = tempfile.NamedTemporaryFile() plugin = configured_plugin(["--funq-conf", funqconf.name]) - assert_equals(1.0, tools.SNOOZE_FACTOR) - assert_true(plugin.screenshoter is not None) - assert_equals(plugin.trace_tests, None) + assert 1.0 == tools.SNOOZE_FACTOR + assert plugin.screenshoter is not None + assert plugin.trace_tests == None def test_snooze_factor_configure(): @@ -77,7 +77,7 @@ def test_snooze_factor_configure(): ["--funq-conf", funqconf.name, '--funq-snooze-factor', '3.2'] ) - assert_equals(3.2, tools.SNOOZE_FACTOR) + assert 3.2 == tools.SNOOZE_FACTOR def test_before_after(): diff --git a/client/funq/tests/test_screenshoter.py b/client/funq/tests/test_screenshoter.py index e09253c..9396d6b 100644 --- a/client/funq/tests/test_screenshoter.py +++ b/client/funq/tests/test_screenshoter.py @@ -64,9 +64,9 @@ def test_take_one_screenshot(): funq = FakeFunqClient() with ScreenShoterCtx() as ctx: ctx.take_screenshot(funq, "hello") - assert_equals(list(map(os.path.basename, funq.screens)), ["0.png"]) - assert_true("0.png: hello" in open( - os.path.join(ctx.working_folder, 'images.txt')).read()) + assert list(map(os.path.basename, funq.screens)) == ["0.png"] + assert "0.png: hello" in open( + os.path.join(ctx.working_folder, 'images.txt')).read() def test_take_screenshots(): @@ -76,8 +76,8 @@ def test_take_screenshots(): ctx.take_screenshot(funq, "thisisit") - assert_equals(list(map(os.path.basename, funq.screens)), + assert (list(map(os.path.basename, funq.screens)) == ["0.png", "1.png"]) content = open(os.path.join(ctx.working_folder, 'images.txt')).read() - assert_true("0.png: hello" in content) - assert_true("1.png: thisisit" in content) + assert "0.png: hello" in content + assert "1.png: thisisit" in content diff --git a/client/funq/tests/test_tools.py b/client/funq/tests/test_tools.py index 2836a7b..ab15123 100644 --- a/client/funq/tests/test_tools.py +++ b/client/funq/tests/test_tools.py @@ -42,7 +42,7 @@ def test_wait_for(): def func(): return True - assert_true(tools.wait_for(func, 0.0)) + assert tools.wait_for(func, 0.0) @raises(tools.TimeOutError) @@ -64,11 +64,11 @@ def test_wait_for_some_time(): def func(): return t + 0.05 < time.time() - assert_true(tools.wait_for(func, 0.1)) + assert tools.wait_for(func, 0.1) def test_which(): - assert_equals(sys.executable, tools.which(sys.executable)) + assert sys.executable == tools.which(sys.executable) def test_which_with_pass(): @@ -77,14 +77,14 @@ def test_which_with_pass(): env = dict(PATH=path) os.environ = env try: - assert_equals(sys.executable, tools.which(fname)) + assert sys.executable == tools.which(fname) finally: os.environ = old_env def test_apply_snooze_factor(): tools.SNOOZE_FACTOR = 3.2 - assert_equals(6.4, tools.apply_snooze_factor(2)) + assert 6.4 == tools.apply_snooze_factor(2) tools.SNOOZE_FACTOR = 1.0 @@ -94,5 +94,5 @@ def test_wait_for_some_time_with_snooze_factor(): def func(): return t + 0.05 < time.time() - assert_true(tools.wait_for(func, 0.025)) + assert tools.wait_for(func, 0.025) tools.SNOOZE_FACTOR = 1.0 From 19c39be5efd0e94f84bea783cc6831d5ab9b2249 Mon Sep 17 00:00:00 2001 From: Rafael de Lucena Valle Date: Wed, 14 Aug 2024 22:56:51 -0300 Subject: [PATCH 02/18] Moving tests to pytest part 1 --- client/funq/tests/__init__.py | 9 --- client/funq/tests/test_aliases.py | 28 +++++---- client/funq/tests/test_client.py | 18 +++++- client/funq/tests/test_models.py | 1 - client/funq/tests/test_noseplugin.py | 93 ---------------------------- 5 files changed, 32 insertions(+), 117 deletions(-) delete mode 100644 client/funq/tests/test_noseplugin.py diff --git a/client/funq/tests/__init__.py b/client/funq/tests/__init__.py index bc1862b..e69de29 100644 --- a/client/funq/tests/__init__.py +++ b/client/funq/tests/__init__.py @@ -1,9 +0,0 @@ -import os -from nose.loader import TestLoader -from nose.suite import LazySuite - - -def create_test_suite(): - this_dir = os.path.dirname(os.path.abspath(__file__)) - - return LazySuite(TestLoader().loadTestsFromDir(this_dir)) diff --git a/client/funq/tests/test_aliases.py b/client/funq/tests/test_aliases.py index 5a5719f..1ea622f 100644 --- a/client/funq/tests/test_aliases.py +++ b/client/funq/tests/test_aliases.py @@ -32,7 +32,7 @@ # The fact that you are presently reading this means that you have had # knowledge of the CeCILL v2.1 license and that you accept its terms. -from nose.tools import assert_equals, raises +import pytest from funq.aliases import HooqAliases, HooqAliasesInvalidLineError, \ HooqAliasesKeyError from tempfile import NamedTemporaryFile @@ -41,32 +41,38 @@ class TestAliases: + @pytest.fixture def setup(self): self.aliases = HooqAliases() + @pytest.mark.usefixtures('setup') def test_add_one(self): self.aliases['1'] = '2' assert self.aliases['1'] == '2' - @raises(HooqAliasesKeyError) + @pytest.mark.usefixtures('setup') def test_no_doublons(self): self.aliases['1'] = '2' - self.aliases['1'] = '2' + with pytest.raises(HooqAliasesKeyError): + self.aliases['1'] = '2' + @pytest.mark.usefixtures('setup') def test_substitution(self): self.aliases['a'] = '1' self.aliases['b'] = '{a}2' assert self.aliases['b'] == '12' - @raises(HooqAliasesKeyError) + @pytest.mark.usefixtures('setup') def test_bad_substitution(self): - self.aliases['b'] = '{a}2' - self.aliases['a'] = '1' - assert self.aliases['b'] == '12' + with pytest.raises(HooqAliasesKeyError): + self.aliases['b'] = '{a}2' + self.aliases['a'] = '1' + assert self.aliases['b'] == '12' - @raises(HooqAliasesKeyError) + @pytest.mark.usefixtures('setup') def test_alias_inexistant(self): - self.aliases['b'] + with pytest.raises(HooqAliasesKeyError): + self.aliases['b'] class TestAliasesFromFile: @@ -115,9 +121,9 @@ def test_parse_with_empty_line(self): """) assert aliases == {'a': '1', 'b': '2'} - @raises(HooqAliasesInvalidLineError) def test_parse_with_syntax_error(self): - self._parse(""" + with pytest.raises(HooqAliasesInvalidLineError): + self._parse(""" a 1 """) diff --git a/client/funq/tests/test_client.py b/client/funq/tests/test_client.py index da8fad6..4eb2e37 100644 --- a/client/funq/tests/test_client.py +++ b/client/funq/tests/test_client.py @@ -32,7 +32,7 @@ # The fact that you are presently reading this means that you have had # knowledge of the CeCILL v2.1 license and that you accept its terms. -from nose.tools import assert_equals, raises +import pytest from funq import client import os import subprocess @@ -53,6 +53,7 @@ def __init__(self, **kwds): class TestApplicationConfigFromConf: + @pytest.fixture def setup(self): self.conf = ConfigParser() self.conf.add_section('my') @@ -66,50 +67,59 @@ def createApplicationConfig(self): GlobalOptions(funq_conf=os.path.join(os.getcwd(), 'my.conf')) ) - @raises(NoOptionError) + @pytest.mark.usefixtures('setup') def test_require_executable(self): - self.createApplicationConfig() + with pytest.raises(NoOptionError): + self.createApplicationConfig() + @pytest.mark.usefixtures('setup') def test_abs_executable(self): self.set_opt('executable', os.getcwd()) appconf = self.createApplicationConfig() assert appconf.executable == os.getcwd() + @pytest.mark.usefixtures('setup') def test_nonabs_executable(self): self.set_opt('executable', 'toto') appconf = self.createApplicationConfig() assert appconf.executable == os.path.join(os.getcwd(), 'toto') + @pytest.mark.usefixtures('setup') def test_args(self): self.set_opt('executable', 'toto') self.set_opt('args', 'toto "titi 1" 2') appconf = self.createApplicationConfig() assert appconf.args == ['toto', 'titi 1', '2'] + @pytest.mark.usefixtures('setup') def test_port(self): self.set_opt('executable', 'toto') self.set_opt('funq_port', '12000') appconf = self.createApplicationConfig() assert appconf.funq_port == 12000 + @pytest.mark.usefixtures('setup') def test_timeout_connection(self): self.set_opt('executable', 'toto') self.set_opt('timeout_connection', '5') appconf = self.createApplicationConfig() assert appconf.timeout_connection == 5 + @pytest.mark.usefixtures('setup') def test_abs_aliases(self): self.set_opt('executable', 'toto') self.set_opt('aliases', os.getcwd()) appconf = self.createApplicationConfig() assert appconf.aliases == os.getcwd() + @pytest.mark.usefixtures('setup') def test_nonabs_aliases(self): self.set_opt('executable', 'toto') self.set_opt('aliases', 'titi') appconf = self.createApplicationConfig() assert appconf.aliases == os.path.join(os.getcwd(), 'titi') + @pytest.mark.usefixtures('setup') def test_stdout_null(self): self.set_opt('executable', 'toto') self.set_opt('executable_stdout', 'NULL') @@ -119,9 +129,11 @@ def test_stdout_null(self): class TestApplicationRegistry: + @pytest.fixture def setup(self): self.reg = client.ApplicationRegistry() + @pytest.mark.usefixtures('setup') def test_register_from_conf(self): conf = ConfigParser() conf.add_section('example') diff --git a/client/funq/tests/test_models.py b/client/funq/tests/test_models.py index 8a36df7..35d7ae7 100644 --- a/client/funq/tests/test_models.py +++ b/client/funq/tests/test_models.py @@ -32,7 +32,6 @@ # The fact that you are presently reading this means that you have had # knowledge of the CeCILL v2.1 license and that you accept its terms. -from nose.tools import assert_is_instance, assert_equals from funq import models diff --git a/client/funq/tests/test_noseplugin.py b/client/funq/tests/test_noseplugin.py deleted file mode 100644 index c4ea19d..0000000 --- a/client/funq/tests/test_noseplugin.py +++ /dev/null @@ -1,93 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright: SCLE SFE -# Contributor: Julien Pagès -# -# This software is a computer program whose purpose is to test graphical -# applications written with the QT framework (http://qt.digia.com/). -# -# This software is governed by the CeCILL v2.1 license under French law and -# abiding by the rules of distribution of free software. You can use, -# modify and/ or redistribute the software under the terms of the CeCILL -# license as circulated by CEA, CNRS and INRIA at the following URL -# "http://www.cecill.info". -# -# As a counterpart to the access to the source code and rights to copy, -# modify and redistribute granted by the license, users are provided only -# with a limited warranty and the software's author, the holder of the -# economic rights, and the successive licensors have only limited -# liability. -# -# In this respect, the user's attention is drawn to the risks associated -# with loading, using, modifying and/or developing or reproducing the -# software by the user in light of its specific status of free software, -# that may mean that it is complicated to manipulate, and that also -# therefore means that it is reserved for developers and experienced -# professionals having in-depth computer knowledge. Users are therefore -# encouraged to load and test the software's suitability as regards their -# requirements in conditions enabling the security of their systems and/or -# data to be ensured and, more generally, to use and operate it in the -# same conditions as regards security. -# -# The fact that you are presently reading this means that you have had -# knowledge of the CeCILL v2.1 license and that you accept its terms. - -from nose.tools import assert_equals, assert_true -from funq import noseplugin, tools -from optparse import OptionParser -import tempfile - - -def configured_plugin(argv=[], env={}): - plugin = noseplugin.FunqPlugin() - plugin.enabled = True - parser = OptionParser() - - plugin.options(parser) - options = parser.parse_args(argv)[0] - plugin.configure(options, None) - return plugin - - -class FakeTest(object): - - def __init__(self, test_id): - self.test_id = test_id - - def id(self): - return self.test_id - - -def test_simple_configure(): - tools.SNOOZE_FACTOR = 1.0 - - funqconf = tempfile.NamedTemporaryFile() - plugin = configured_plugin(["--funq-conf", funqconf.name]) - - assert 1.0 == tools.SNOOZE_FACTOR - assert plugin.screenshoter is not None - assert plugin.trace_tests == None - - -def test_snooze_factor_configure(): - tools.SNOOZE_FACTOR = 1.0 - - funqconf = tempfile.NamedTemporaryFile() - configured_plugin( - ["--funq-conf", funqconf.name, '--funq-snooze-factor', '3.2'] - ) - - assert 3.2 == tools.SNOOZE_FACTOR - - -def test_before_after(): - noseplugin.FunqPlugin._current_test_name = None - - funqconf = tempfile.NamedTemporaryFile() - plugin = configured_plugin(["--funq-conf", funqconf.name]) - - test = FakeTest("id of test") - - plugin.beforeTest(test) - - plugin.afterTest(test) From 74c1eb76e22f77fd7323602bf7e0fe4bdea6e52c Mon Sep 17 00:00:00 2001 From: Rafael de Lucena Valle Date: Wed, 14 Aug 2024 23:28:55 -0300 Subject: [PATCH 03/18] Remove references for nosetests --- README.rst | 6 +- client/doc/gkit_aliases.rst | 4 +- client/doc/launching_tests.rst | 48 ++---- client/doc/qml_tutorial.rst | 2 +- client/doc/tutorial.rst | 16 +- client/funq/noseplugin.py | 202 ------------------------- client/funq/tests/test_models.py | 2 + client/funq/tests/test_screenshoter.py | 1 - client/funq/tests/test_tools.py | 10 +- doc-dev/general.rst | 12 +- tests-functionnal/setup.cfg | 2 +- 11 files changed, 44 insertions(+), 261 deletions(-) delete mode 100644 client/funq/noseplugin.py diff --git a/README.rst b/README.rst index 67c2194..ec05c18 100644 --- a/README.rst +++ b/README.rst @@ -103,12 +103,12 @@ How does *funq* works - **funq** is a python package that offers an API to interact with a **libFunq** TCP server. It is the client side of the project, and uses - nosetests to launch FUNctional Qt tests. + pytest to launch FUNctional Qt tests. Compatibility ============= -Funq currently works with Python >= 3.5, Qt4 and Qt5 on GNU/Linux, macOS and +Funq currently works with Python >= 3.5, Qt5 and Qt6 on GNU/Linux, macOS and Windows. Documentation @@ -125,4 +125,6 @@ functional tests with **funq**. Thanks also to Jean-Luc Rouzoul, Dominique Constant and Mickaël Guérin for having supported this project. +Thanks to all the contributors for their patches, bug reports, and feedback. + Without them, **funq** would never have become a free software ! diff --git a/client/doc/gkit_aliases.rst b/client/doc/gkit_aliases.rst index c36f32b..90be410 100644 --- a/client/doc/gkit_aliases.rst +++ b/client/doc/gkit_aliases.rst @@ -23,8 +23,8 @@ You can use these aliases in the aliases file in a standard way (between {}). manager is used - **default** is always used. To use another graphical kit, you have to specify it with the *funq-gkit* - nose option. Example: + pytest option. Example: .. code-block:: bash - nosetests --with-funq --funq-gkit kde + pytest --with-funq --funq-gkit kde diff --git a/client/doc/launching_tests.rst b/client/doc/launching_tests.rst index 7f4c1c5..a9c224c 100644 --- a/client/doc/launching_tests.rst +++ b/client/doc/launching_tests.rst @@ -1,7 +1,7 @@ Launching tests (nose) ====================== -Tests are launched by `nose `_, +Tests are launched by `pytest `_, and you have to tell it to use the **funq** plugin. Manual launching @@ -9,82 +9,66 @@ Manual launching Basically:: - nosetests --with-funq + pytest --with-funq The command must be started from the folder containing tests files and the **funq.conf** configuration file. .. note:: - There are many options for nose, and some specifics to the **funq** - plugin. See ``nosetests --help`` for an exhaustive list. + There are many options for pytest, and some specifics to the **funq** + plugin. See ``pytest --help`` for an exhaustive list. Example:: # launch tests with all stdout/stderr output and stop on the first error - nosetests --with-funq -s -x + pytest --with-funq -s -x Defining default options ------------------------ -Every nose option may be specified by default in a file named **setup.cfg**. -You can look at the nose documentation for more informations. +Every pytest option may be specified by default in a file named **setup.cfg**. +You can look at the pytest documentation for more informations. Example: .. code-block:: ini - [nosetests] + [pytest] verbosity=2 with-funq=1 .. note:: - This configuration is very useful, and allow to type only **nosetests** - on the command line instead of ``nosetests --with-funq -vv``. I highly + This configuration is very useful, and allow to type only **pytest** + on the command line instead of ``pytest --with-funq -vv``. I highly recommend this configuration and I will use it in the following documentation. Selecting tests to launch ------------------------- -It s possible to select tests to launch using nose. +It s possible to select tests to launch using pytest. Example:: # every tests in a given file - nosetests test_export.py + pytest test_export.py # every tests of a given class in a test file - nosetests test_export.py:TestExportElectre + pytest test_export.py:TestExportElectre # just one test (one method) - nosetests test_export.py:TestExportElectre.test_export_b6 + pytest test_export.py:TestExportElectre.test_export_b6 .. note:: - See the nose documeation fo more information. + See the pytest documeation fo more information. If the verbosity option is equal to 2, the tests execution will show test names with the same format. This means that you can then copy/paste a test name to restart it. -Going further -------------- - -**nose** got plenty of usefuls plugins ! - -Some are integrated in nose, others are third-party plugins and need a -proper installation. - -Som of the interesting nose plugins are listed here: - -- **xunit**: format tests output using xunit -- **attributeselector**: select tests given their attributes -- **collect-only**: allow to only list tests without really execute them - -See the nose documentation, and google to find others usefuls plugins ! - .. note:: - It is also easy to write your own `nose plugins `_. + It is also easy to write your own `pytest plugins `_. diff --git a/client/doc/qml_tutorial.rst b/client/doc/qml_tutorial.rst index 47fca67..5126a3c 100644 --- a/client/doc/qml_tutorial.rst +++ b/client/doc/qml_tutorial.rst @@ -104,7 +104,7 @@ Run the test Just run:: - nosetests --with-funq + pytest --with-funq In the `qmltest` folder and watch it pass. diff --git a/client/doc/tutorial.rst b/client/doc/tutorial.rst index d31f60f..5644a59 100644 --- a/client/doc/tutorial.rst +++ b/client/doc/tutorial.rst @@ -32,7 +32,7 @@ And that funq is installed with: .. code-block:: bash - nosetests -h | grep 'with-funq' + pytest -h | grep 'with-funq' .. important:: @@ -90,7 +90,7 @@ Well done ! Let's run this first test. Type the following command: .. code-block:: bash - nosetests --with-funq + pytest --with-funq One window must appear, and close after a few seconds. The output on the terminal must look like this:: @@ -103,13 +103,13 @@ terminal must look like this:: .. note:: - The option ``--with-funq`` given to nosetests allow to use the funq plugin + The option ``--with-funq`` given to pytest allow to use the funq plugin that will read the configuration file and execute your tests. .. note:: - **nosetests** has multiples options to allow for example the generation - of an xml file to format tests result. See **nosetests -h**. + **pytest** has multiples options to allow for example the generation + of an xml file to format tests result. See **pytest -h**. And voilà! You have written and launched your first funq test. Now let's go a bit further by adding two tests and use an aliases file. @@ -159,7 +159,7 @@ Now you can start tests again: .. code-block:: bash - nosetests --with-funq + pytest --with-funq .. note:: @@ -170,7 +170,7 @@ Now you can start tests again: .. code-block:: bash - nosetests --with-funq test_widgets.py + pytest --with-funq test_widgets.py .. important:: @@ -178,7 +178,7 @@ Now you can start tests again: that depends on others tests. In other words, the *order of test execution must not be important*. This allow to limit side effects and to find quickly why a test failed. This being said, - **nosetests** does not assure any order in test execution. + **pytest** does not assure any order in test execution. Going further ------------- diff --git a/client/funq/noseplugin.py b/client/funq/noseplugin.py deleted file mode 100644 index e3690bd..0000000 --- a/client/funq/noseplugin.py +++ /dev/null @@ -1,202 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright: SCLE SFE -# Contributor: Julien Pagès -# -# This software is a computer program whose purpose is to test graphical -# applications written with the QT framework (http://qt.digia.com/). -# -# This software is governed by the CeCILL v2.1 license under French law and -# abiding by the rules of distribution of free software. You can use, -# modify and/ or redistribute the software under the terms of the CeCILL -# license as circulated by CEA, CNRS and INRIA at the following URL -# "http://www.cecill.info". -# -# As a counterpart to the access to the source code and rights to copy, -# modify and redistribute granted by the license, users are provided only -# with a limited warranty and the software's author, the holder of the -# economic rights, and the successive licensors have only limited -# liability. -# -# In this respect, the user's attention is drawn to the risks associated -# with loading, using, modifying and/or developing or reproducing the -# software by the user in light of its specific status of free software, -# that may mean that it is complicated to manipulate, and that also -# therefore means that it is reserved for developers and experienced -# professionals having in-depth computer knowledge. Users are therefore -# encouraged to load and test the software's suitability as regards their -# requirements in conditions enabling the security of their systems and/or -# data to be ensured and, more generally, to use and operate it in the -# same conditions as regards security. -# -# The fact that you are presently reading this means that you have had -# knowledge of the CeCILL v2.1 license and that you accept its terms. - -""" -Module that integrates funq with nosetests. -""" - -from funq.client import ApplicationRegistry -from funq.testcase import MultiFunqTestCase, FunqTestCase, \ - register_funq_app_registry -from funq.screenshoter import ScreenShoter -from funq import tools -from nose.plugins import Plugin -from configparser import ConfigParser -import os -import codecs -import logging - -LOG = logging.getLogger('nose.plugins.funq') - - -def message_with_sep(message): - """Returns a message with a separator.""" - sep = '-' * 70 - return (sep, message, sep) - - -def locate_funq(): - """find the funq executable""" - return tools.which('funq') - - -class FunqPlugin(Plugin): - - """ - Nosetests plugin to integrate funq. - """ - name = 'funq' - - _instance = None - - @classmethod - def instance(cls): - return cls._instance - - def options(self, parser, env=None): - env = env or os.environ - super(FunqPlugin, self).options(parser, env=env) - parser.add_option('--funq-conf', - dest='funq_conf', - default=env.get('NOSE_FUNQ_CONF') or 'funq.conf', - help="funq configuration file, defaults to" - " `funq.conf` [NOSE_FUNQ_CONF].") - parser.add_option('--funq-gkit', - dest='funq_gkit', - default=env.get('NOSE_FUNQ_GKIT') or 'default', - help="Choose a specific graphic toolkit. This allows" - " to define default different aliases" - " Default: `default` [NOSE_FUNQ_GKIT]`") - gkit_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), - 'aliases-gkits.conf') - parser.add_option('--funq-gkit-file', - dest='funq_gkit_file', - default=env.get('NOSE_FUNQ_GKIT_FILE') or gkit_file, - help="Override the file that defines graphic" - " toolkits. Default: `%s` [NOSE_FUNQ_GKIT_FILE]" - % gkit_file) - parser.add_option('--funq-attach-exe', - dest='funq_attach_exe', - default=env.get('NOSE_FUNQ_ATTACH_EXE') - or locate_funq(), - help="Complete path to the funq executable." - " [NOSE_FUNQ_ATTACH_EXE]") - parser.add_option('--funq-trace-tests', - dest='funq_trace_tests', - default=env.get('NOSE_FUNQ_TRACE_TESTS'), - help="A file in which start and end of tests will be" - " logged. [NOSE_FUNQ_TRACE_TESTS]") - parser.add_option('--funq-trace-tests-encoding', - dest='funq_trace_tests_encoding', - default=env.get('NOSE_FUNQ_TRACE_TESTS_ENCODING') - or 'utf-8', - help="encoding of the file used in" - " --funq-trace-tests." - " [NOSE_FUNQ_TRACE_TESTS_ENCODING]") - parser.add_option('--funq-screenshot-folder', - dest="funq_screenshot_folder", - default=env.get("NOSE_FUNQ_SCREENSHOT_FOLDER") - or os.path.realpath("screenshot-errors"), - help="Folder to saves screenshots on error." - " Default: screenshot-errors." - " [NOSE_FUNQ_SCREENSHOT_FOLDER]") - parser.add_option('--funq-snooze-factor', - dest="funq_snooze_factor", - default=env.get("NOSE_FUNQ_SNOOZE_FACTOR") - or 1.0, - help="Allow to specify a factor on every timeout." - " Default: 1.0. [NOSE_FUNQ_SNOOZE_FACTOR]") - - def configure(self, options, cfg): - Plugin.configure(self, options, cfg) - if not self.enabled: - return - conf_file = options.funq_conf = os.path.realpath(options.funq_conf) - if not os.path.isfile(conf_file): - raise Exception( - "Missing configuration file of funq: `%s`" % conf_file) - conf = ConfigParser() - conf.read([conf_file]) - self.app_registry = ApplicationRegistry() - self.app_registry.register_from_conf(conf, options) - register_funq_app_registry(self.app_registry) - self.trace_tests = options.funq_trace_tests - self.trace_tests_encoding = \ - options.funq_trace_tests_encoding - self.screenshoter = ScreenShoter(options.funq_screenshot_folder) - tools.SNOOZE_FACTOR = float(options.funq_snooze_factor) - FunqPlugin._instance = self - - def beforeTest(self, test): - message = "Starting test `%s`" % test.id() - lines = message_with_sep(message) - for line in lines: - LOG.info(line) - if self.trace_tests: - with codecs.open(self.trace_tests, 'a', - self.trace_tests_encoding) as f: - f.write('\n'.join(lines)) - f.write('\n') - - def afterTest(self, test): - message = "Ending test `%s`" % test.id() - lines = message_with_sep(message) - for line in lines: - LOG.info(line) - if self.trace_tests: - with codecs.open(self.trace_tests, 'a', - self.trace_tests_encoding) as f: - f.write('\n'.join(lines)) - f.write('\n') - - def describeTest(self, test): - return u'%s' % test.id() - - def take_screenshot(self, test): - if isinstance(test, MultiFunqTestCase): - if test.__app_config__: - for k, v in test.__app_config__.items(): - if v.screenshot_on_error: - self.screenshoter.take_screenshot( - test.funq[k], - '%s [%s]' % (test.id(), k) - ) - elif isinstance(test, FunqTestCase): - if test.__app_config__: - if test.__app_config__.screenshot_on_error: - self.screenshoter.take_screenshot(test.funq, test.id()) - - def prepareTestResult(self, result): - _addError = result.addError - _addFailure = result.addFailure - - def addError(test, err): - self.take_screenshot(test.test) - _addError(test, err) - - def addFailure(test, err): - self.take_screenshot(test.test) - _addFailure(test, err) - result.addError = addError - result.addFailure = addFailure diff --git a/client/funq/tests/test_models.py b/client/funq/tests/test_models.py index 35d7ae7..54ed655 100644 --- a/client/funq/tests/test_models.py +++ b/client/funq/tests/test_models.py @@ -32,6 +32,7 @@ # The fact that you are presently reading this means that you have had # knowledge of the CeCILL v2.1 license and that you accept its terms. +import pytest from funq import models @@ -65,6 +66,7 @@ class MyWidget(models.Widget): class TestModelItems: + @pytest.fixture(autouse=True) def setup(self): data = { 'items': [ diff --git a/client/funq/tests/test_screenshoter.py b/client/funq/tests/test_screenshoter.py index 9396d6b..a4a118f 100644 --- a/client/funq/tests/test_screenshoter.py +++ b/client/funq/tests/test_screenshoter.py @@ -32,7 +32,6 @@ # The fact that you are presently reading this means that you have had # knowledge of the CeCILL v2.1 license and that you accept its terms. -from nose.tools import assert_equals, assert_true from funq import screenshoter import tempfile import shutil diff --git a/client/funq/tests/test_tools.py b/client/funq/tests/test_tools.py index ab15123..6992801 100644 --- a/client/funq/tests/test_tools.py +++ b/client/funq/tests/test_tools.py @@ -32,7 +32,7 @@ # The fact that you are presently reading this means that you have had # knowledge of the CeCILL v2.1 license and that you accept its terms. -from nose.tools import assert_equals, assert_true, raises +import pytest from funq import tools import time import sys @@ -45,18 +45,18 @@ def func(): assert tools.wait_for(func, 0.0) -@raises(tools.TimeOutError) def test_wait_for_timeout(): def func(): return False - tools.wait_for(func, 0.0) + with pytest.raises(tools.TimeOutError): + tools.wait_for(func, 0.0) -@raises(Exception) def test_wait_for_custom_exc(): def func(): return Exception() - tools.wait_for(func, 0.0) + with pytest.raises(Exception): + tools.wait_for(func, 0.0) def test_wait_for_some_time(): diff --git a/doc-dev/general.rst b/doc-dev/general.rst index 33aec38..7091c29 100644 --- a/doc-dev/general.rst +++ b/doc-dev/general.rst @@ -47,7 +47,7 @@ Choix d'implémentation - partie client Le client est implémenté en Python - et c'est ainsi que les tests doivent être écrits. -Pour lancer les tests, la librairie **nosetests** est utilisée - c'est une +Pour lancer les tests, la librairie **pytest** est utilisée - c'est une dépendance du client. Tests unitaires @@ -83,7 +83,7 @@ Pour la partie client: .. code-block:: bash cd client - nosetests + pytest .. note:: @@ -92,13 +92,11 @@ Pour la partie client: .. code-block:: bash cd client - nosetests --with-coverage --cover-package funq + pytest --with-coverage --cover-package funq -La partie client requiert le framework Python **nose** [1] pour lancer les tests, -et **coverage.py** [2] pour la couverture. +La partie client requiert le framework Python **pytest** [1] pour lancer les tests. -* [1] https://nose.readthedocs.org/en/latest/ -* [2] http://nedbatchelder.com/code/coverage/ +* [1] https://pytest.readthedocs.org/en/latest/ Documentation ------------- diff --git a/tests-functionnal/setup.cfg b/tests-functionnal/setup.cfg index 2cc16aa..f111a55 100644 --- a/tests-functionnal/setup.cfg +++ b/tests-functionnal/setup.cfg @@ -1,3 +1,3 @@ -[nosetests] +[pytest] verbosity=2 with-funq=1 From e8b1fd0d39c91f124020bdaf378a9142b930744e Mon Sep 17 00:00:00 2001 From: Rafael de Lucena Valle Date: Wed, 14 Aug 2024 23:47:50 -0300 Subject: [PATCH 04/18] Fix flake8 issues --- client/funq/tests/test_aliases.py | 2 +- client/funq/tests/test_models.py | 4 ++-- client/funq/tests/test_screenshoter.py | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/client/funq/tests/test_aliases.py b/client/funq/tests/test_aliases.py index 1ea622f..7261c38 100644 --- a/client/funq/tests/test_aliases.py +++ b/client/funq/tests/test_aliases.py @@ -149,7 +149,7 @@ def test_with_gkit_interpolation(self): b = {OTHER_DEFINE} """, gkit_data) assert aliases == {'MY_DEFINE': '33', 'a': '33::1', - 'OTHER_DEFINE': '33::66', 'b': '33::66'} + 'OTHER_DEFINE': '33::66', 'b': '33::66'} def test_with_gkit_custom(self): gkit_data = """ diff --git a/client/funq/tests/test_models.py b/client/funq/tests/test_models.py index 54ed655..9082bce 100644 --- a/client/funq/tests/test_models.py +++ b/client/funq/tests/test_models.py @@ -116,7 +116,7 @@ def test_row_by_named_path_str_custom_path(self): def test_row_by_named_path_missing(self): items = self.model_items.row_by_named_path('blah/bluh') - assert items == None + assert items is None def test_item_by_named_path(self): item = self.model_items.item_by_named_path(['0-0', '0-0']) @@ -128,4 +128,4 @@ def test_item_by_named_path_column(self): def test_item_by_named_path_missing(self): item = self.model_items.item_by_named_path('blah/bluh') - assert item == None + assert item is None diff --git a/client/funq/tests/test_screenshoter.py b/client/funq/tests/test_screenshoter.py index a4a118f..9788894 100644 --- a/client/funq/tests/test_screenshoter.py +++ b/client/funq/tests/test_screenshoter.py @@ -75,8 +75,7 @@ def test_take_screenshots(): ctx.take_screenshot(funq, "thisisit") - assert (list(map(os.path.basename, funq.screens)) == - ["0.png", "1.png"]) + assert list(map(os.path.basename, funq.screens)) == ["0.png", "1.png"] content = open(os.path.join(ctx.working_folder, 'images.txt')).read() assert "0.png: hello" in content assert "1.png: thisisit" in content From 391b1d6aacb95e09701fbae8cacd74a5943ec4d8 Mon Sep 17 00:00:00 2001 From: Rafael de Lucena Valle Date: Sat, 17 Aug 2024 15:58:57 -0300 Subject: [PATCH 05/18] remove nose in setup.py --- client/setup.py | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/client/setup.py b/client/setup.py index 24c1399..e610b5f 100644 --- a/client/setup.py +++ b/client/setup.py @@ -16,10 +16,6 @@ def read(*paths): version = re.search("__version__ = '(.+)'", read('funq/__init__.py')).group(1) -# nose n'est actuellement pas requis pour ce module -# mais tres utile pour cadrer les tests. -install_requires = ['nose'] - setup( name="funq", author="Julien Pagès", @@ -30,10 +26,5 @@ def read(*paths): version=version, packages=find_packages(), zip_safe=False, - test_suite='funq.tests.create_test_suite', - install_requires=install_requires, - package_data={'funq': ['aliases-gkits.conf']}, - entry_points={ - 'nose.plugins.0.10': ['funq = funq.noseplugin:FunqPlugin'] - }, + test_suite="tests", ) From a601349ff25ab4ee41fd4f30b050089b1c5d5832 Mon Sep 17 00:00:00 2001 From: Rafael de Lucena Valle Date: Sat, 17 Aug 2024 16:08:19 -0300 Subject: [PATCH 06/18] Add pytest as requirement in setup.py --- client/setup.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/setup.py b/client/setup.py index e610b5f..2162c86 100644 --- a/client/setup.py +++ b/client/setup.py @@ -26,5 +26,7 @@ def read(*paths): version=version, packages=find_packages(), zip_safe=False, - test_suite="tests", + test_suite="funq/tests", + tests_require=["pytest"], + setup_requires=["pytest-runner"], ) From 9146187fc79234ecd976d2b4af6f350007cea7af Mon Sep 17 00:00:00 2001 From: Rafael de Lucena Valle Date: Sat, 17 Aug 2024 16:13:00 -0300 Subject: [PATCH 07/18] Fix tests path --- client/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/setup.py b/client/setup.py index 2162c86..00253ca 100644 --- a/client/setup.py +++ b/client/setup.py @@ -26,7 +26,7 @@ def read(*paths): version=version, packages=find_packages(), zip_safe=False, - test_suite="funq/tests", + test_suite="tests", tests_require=["pytest"], setup_requires=["pytest-runner"], ) From 1357989a9e5eca5cca2a6f683b61e3c312a189ca Mon Sep 17 00:00:00 2001 From: Rafael de Lucena Valle Date: Sat, 17 Aug 2024 16:27:30 -0300 Subject: [PATCH 08/18] Change nosetests to pytest in Github actions --- .github/workflows/main.yml | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5c4de5c..4c7c029 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,22 +17,18 @@ jobs: py: "3.8" container: "ubuntu:20.04" packages: "qt5-default qttools5-dev-tools qtdeclarative5-dev qml-module-qtquick2" - nosetests: 1 - qt: 5 # 5.15 py: "3.10" container: "ubuntu:22.04" packages: "qtbase5-dev qttools5-dev-tools qtdeclarative5-dev qml-module-qtquick2" - nosetests: 0 # Nosetest not working anymore - qt: 6 # 6.2 py: "3.10" container: "ubuntu:22.04" packages: "qt6-base-dev qt6-tools-dev qt6-tools-dev-tools qt6-declarative-dev libqt6opengl6-dev qml6-module-*" - nosetests: 0 # Nosetest not working anymore - qt: 6 # 6.4 py: "3.12" container: "ubuntu:24.04" packages: "qt6-base-dev qt6-tools-dev qt6-tools-dev-tools qt6-declarative-dev libqt6opengl6-dev qml6-module-*" - nosetests: 0 # Nosetest not working anymore env: DEBIAN_FRONTEND: noninteractive FUNQ_QT_MAJOR_VERSION: "${{ matrix.qt }}" @@ -46,6 +42,10 @@ jobs: python3 python3-pip python3-flake8 \ ${{ matrix.packages }} + - name: Install Python requirements + run: | + pip install pytest + # Stylecheck - name: Flake8 run: python3 -m flake8 client/funq server/funq_server @@ -71,7 +71,6 @@ jobs: run: cd client && python3 setup.py develop - name: Test client run: cd client && python3 setup.py test - if: ${{ matrix.nosetests != 0 }} # Functional tests - name: Build test app @@ -79,8 +78,7 @@ jobs: - name: Test injection run: xvfb-run -a funq tests-functionnal/funq-test-app/funq-test-app --exit-after-startup - name: Test functional - run: cd tests-functionnal && xvfb-run -a nosetests - if: ${{ matrix.nosetests != 0}} + run: cd tests-functionnal && xvfb-run -a pytest macos: name: "qt:${{ matrix.qt }} on ${{ matrix.runner }}" @@ -88,9 +86,8 @@ jobs: strategy: matrix: include: - # Note: Nosetest doesn't work anymore with recent Python versions! - - {qt: "5", runner: "macos-12", nosetests: 0} - - {qt: "6", runner: "macos-14", nosetests: 0} + - {qt: "5", runner: "macos-12"} + - {qt: "6", runner: "macos-14"} env: FUNQ_QT_MAJOR_VERSION: "${{ matrix.qt }}" PIP_BREAK_SYSTEM_PACKAGES: 1 @@ -128,7 +125,6 @@ jobs: run: cd client && python3 setup.py develop - name: Test client run: cd client && python3 setup.py test - if: ${{ matrix.nosetests != 0 }} # Functional tests - name: Build test app @@ -136,8 +132,7 @@ jobs: - name: Test injection run: funq tests-functionnal/funq-test-app/funq-test-app --exit-after-startup - name: Test functional - run: cd tests-functionnal && xvfb-run -a nosetests - if: ${{ matrix.nosetests != 0}} + run: cd tests-functionnal && xvfb-run -a pytest windows: name: "qt:${{ matrix.qt }} py:${{ matrix.py }} ${{ matrix.arch }} on windows" @@ -152,7 +147,6 @@ jobs: qt_arch: "win32_mingw81" qt_tools: "tools_mingw,qt.tools.win32_mingw810" compiler_path: "D:/a/funq/Qt/Tools/mingw810_32/bin" - nosetests: 1 - py: "3.8" arch: "x64" qt: 6 @@ -160,7 +154,6 @@ jobs: qt_arch: "win64_mingw" qt_tools: "tools_mingw1310" compiler_path: "D:/a/funq/Qt/Tools/mingw1310_64/bin" - nosetests: 1 - py: "3.11" arch: "x64" qt: 6 @@ -168,7 +161,6 @@ jobs: qt_arch: "win64_mingw" qt_tools: "tools_mingw1310" compiler_path: "D:/a/funq/Qt/Tools/mingw1310_64/bin" - nosetests: 0 # Nosetest not working anymore env: CMAKE_GENERATOR: "MinGW Makefiles" CC: "${{ matrix.compiler_path }}/gcc.exe" @@ -213,7 +205,6 @@ jobs: run: cd client && python3 setup.py develop - name: Test client run: cd client && python3 setup.py test - if: ${{ matrix.nosetests != 0 }} # Functional tests - name: Build test app @@ -221,5 +212,4 @@ jobs: - name: Test injection run: funq tests-functionnal/funq-test-app/funq-test-app.exe --exit-after-startup - name: Test functional - run: cd tests-functionnal && nosetests - if: ${{ matrix.nosetests != 0}} + run: cd tests-functionnal && pytest From 4592fa4f232be479e4aef67df0884dbe228ac98e Mon Sep 17 00:00:00 2001 From: Rafael de Lucena Valle Date: Sat, 17 Aug 2024 16:33:05 -0300 Subject: [PATCH 09/18] Add verbosity for steps --- .github/workflows/main.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4c7c029..098db9e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -70,7 +70,7 @@ jobs: - name: Install client run: cd client && python3 setup.py develop - name: Test client - run: cd client && python3 setup.py test + run: cd client && python3 setup.py test -v # Functional tests - name: Build test app @@ -78,7 +78,7 @@ jobs: - name: Test injection run: xvfb-run -a funq tests-functionnal/funq-test-app/funq-test-app --exit-after-startup - name: Test functional - run: cd tests-functionnal && xvfb-run -a pytest + run: cd tests-functionnal && xvfb-run -a pytest -v macos: name: "qt:${{ matrix.qt }} on ${{ matrix.runner }}" @@ -124,7 +124,7 @@ jobs: - name: Install client run: cd client && python3 setup.py develop - name: Test client - run: cd client && python3 setup.py test + run: cd client && python3 setup.py test -v # Functional tests - name: Build test app @@ -204,7 +204,7 @@ jobs: - name: Install client run: cd client && python3 setup.py develop - name: Test client - run: cd client && python3 setup.py test + run: cd client && python3 setup.py test -v # Functional tests - name: Build test app From 9d92795ca74ea9c9d8027b93b5bd26cd114d817a Mon Sep 17 00:00:00 2001 From: Rafael de Lucena Valle Date: Sat, 17 Aug 2024 16:54:32 -0300 Subject: [PATCH 10/18] Add wheel --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 098db9e..32b438c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -44,7 +44,7 @@ jobs: - name: Install Python requirements run: | - pip install pytest + pip install pytest wheel # Stylecheck - name: Flake8 From aac9681f308155e74391c15e09aeaadfdc74837a Mon Sep 17 00:00:00 2001 From: Rafael de Lucena Valle Date: Sat, 17 Aug 2024 17:05:55 -0300 Subject: [PATCH 11/18] Running pytest directly instead of setup.py test --- .github/workflows/main.yml | 8 ++++---- client/setup.py | 3 --- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 32b438c..c6889ef 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -44,7 +44,7 @@ jobs: - name: Install Python requirements run: | - pip install pytest wheel + pip install pytest # Stylecheck - name: Flake8 @@ -70,7 +70,7 @@ jobs: - name: Install client run: cd client && python3 setup.py develop - name: Test client - run: cd client && python3 setup.py test -v + run: cd client && pytest -v # Functional tests - name: Build test app @@ -124,7 +124,7 @@ jobs: - name: Install client run: cd client && python3 setup.py develop - name: Test client - run: cd client && python3 setup.py test -v + run: cd client && pytest -v # Functional tests - name: Build test app @@ -204,7 +204,7 @@ jobs: - name: Install client run: cd client && python3 setup.py develop - name: Test client - run: cd client && python3 setup.py test -v + run: cd client && pytest -v # Functional tests - name: Build test app diff --git a/client/setup.py b/client/setup.py index 00253ca..0c3d587 100644 --- a/client/setup.py +++ b/client/setup.py @@ -26,7 +26,4 @@ def read(*paths): version=version, packages=find_packages(), zip_safe=False, - test_suite="tests", - tests_require=["pytest"], - setup_requires=["pytest-runner"], ) From 9232aa32f13c0a7205ab941c77f5879d9da2a4f0 Mon Sep 17 00:00:00 2001 From: Rafael de Lucena Valle Date: Sat, 17 Aug 2024 17:24:06 -0300 Subject: [PATCH 12/18] Add pytest in setup.py again --- .github/workflows/main.yml | 12 ++++++------ client/setup.py | 7 +++++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c6889ef..26be861 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -44,7 +44,7 @@ jobs: - name: Install Python requirements run: | - pip install pytest + pip install wheel pytest pytest-runner # Stylecheck - name: Flake8 @@ -70,7 +70,7 @@ jobs: - name: Install client run: cd client && python3 setup.py develop - name: Test client - run: cd client && pytest -v + run: cd client && python3 setup.py test -v # Functional tests - name: Build test app @@ -124,7 +124,7 @@ jobs: - name: Install client run: cd client && python3 setup.py develop - name: Test client - run: cd client && pytest -v + run: cd client && python3 setup.py test -v # Functional tests - name: Build test app @@ -132,7 +132,7 @@ jobs: - name: Test injection run: funq tests-functionnal/funq-test-app/funq-test-app --exit-after-startup - name: Test functional - run: cd tests-functionnal && xvfb-run -a pytest + run: cd tests-functionnal && xvfb-run -a pytest -v windows: name: "qt:${{ matrix.qt }} py:${{ matrix.py }} ${{ matrix.arch }} on windows" @@ -204,7 +204,7 @@ jobs: - name: Install client run: cd client && python3 setup.py develop - name: Test client - run: cd client && pytest -v + run: cd client && python3 setup.py test -v # Functional tests - name: Build test app @@ -212,4 +212,4 @@ jobs: - name: Test injection run: funq tests-functionnal/funq-test-app/funq-test-app.exe --exit-after-startup - name: Test functional - run: cd tests-functionnal && pytest + run: cd tests-functionnal && pytest -v diff --git a/client/setup.py b/client/setup.py index 0c3d587..5ab5440 100644 --- a/client/setup.py +++ b/client/setup.py @@ -26,4 +26,11 @@ def read(*paths): version=version, packages=find_packages(), zip_safe=False, + setup_requires=[ + "pytest-runner", + ], + tests_require=[ + "pytest", + ], + test_suite="tests", ) From 43a470f86738acdc4d2e69092d3f1c3f7e26a271 Mon Sep 17 00:00:00 2001 From: Rafael de Lucena Valle Date: Sat, 17 Aug 2024 17:31:38 -0300 Subject: [PATCH 13/18] Add pip install for all archs --- .github/workflows/main.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 26be861..eab5939 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -98,7 +98,8 @@ jobs: brew install cmake qt@${{ matrix.qt }} brew link --force qt@${{ matrix.qt }} echo "$(brew --prefix qt${{ matrix.qt }})/bin" >> $GITHUB_PATH - pip3 install setuptools flake8 + pip3 install setuptools flake8 wheel pytest pytest-runner + # Stylecheck - name: Flake8 @@ -201,6 +202,8 @@ jobs: run: cd server && python3 setup.py develop # Client + - name: Install test requirements + run: pip install wheel pytest pytest-runner - name: Install client run: cd client && python3 setup.py develop - name: Test client From 812f1dc0ae24c3a4a98cedb9c460b1078e579f73 Mon Sep 17 00:00:00 2001 From: Rafael de Lucena Valle Date: Thu, 3 Oct 2024 23:55:30 -0300 Subject: [PATCH 14/18] Remove test dependencies from setup.py --- client/setup.py | 13 ++++--------- server/setup.py | 5 +++-- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/client/setup.py b/client/setup.py index 5ab5440..5652dcc 100644 --- a/client/setup.py +++ b/client/setup.py @@ -14,7 +14,9 @@ def read(*paths): return content.decode("utf-8") -version = re.search("__version__ = '(.+)'", read('funq/__init__.py')).group(1) + +def get_version(): + return re.search("__version__ = '(.+)'", read('funq/__init__.py')).group(1) setup( name="funq", @@ -23,14 +25,7 @@ def read(*paths): url="https://github.com/parkouss/funq", description="write FUNctional tests for Qt applications (client)", long_description=read("README"), - version=version, + version=get_version(), packages=find_packages(), - zip_safe=False, - setup_requires=[ - "pytest-runner", - ], - tests_require=[ - "pytest", - ], test_suite="tests", ) diff --git a/server/setup.py b/server/setup.py index e927dd6..600cf26 100644 --- a/server/setup.py +++ b/server/setup.py @@ -23,7 +23,8 @@ def read(*paths): return content.decode("utf-8") -version = re.search("__version__ = '(.+)'", read('funq_server/__init__.py')).group(1) +def get_version(): + return re.search("__version__ = '(.+)'", read('funq_server/__init__.py')).group(1) class build_libfunq(Command): @@ -127,7 +128,7 @@ def run(self): url="https://github.com/parkouss/funq", description="write FUNctional tests for Qt applications (server)", long_description=read("README"), - version=version, + version=get_version(), packages=['funq_server'], entry_points={ 'console_scripts': [ From 99276a611150a10e9d5d0391ee5ee6483ed765df Mon Sep 17 00:00:00 2001 From: Rafael de Lucena Valle Date: Thu, 3 Oct 2024 23:56:11 -0300 Subject: [PATCH 15/18] Updating setup for installs and tests --- .github/workflows/main.yml | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index eab5939..ed33164 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -64,13 +64,15 @@ jobs: # Server - name: Install server - run: cd server && python3 setup.py develop + run: cd server && python -m pip install --editable . # Client - name: Install client - run: cd client && python3 setup.py develop + run: cd client && python -m pip install --editable . - name: Test client - run: cd client && python3 setup.py test -v + run: | + python -m pip install -r requirements-dev.txt + cd client && pytest -v tests/ # Functional tests - name: Build test app @@ -119,13 +121,15 @@ jobs: # Server - name: Install server - run: cd server && python3 setup.py develop + run: cd server && python -m pip install --editable / # Client - name: Install client - run: cd client && python3 setup.py develop + run: cd client && python -m pip install --editable . - name: Test client - run: cd client && python3 setup.py test -v + run: | + python -m pip install -r requirements-dev.txt + cd client && pytest -v tests/ # Functional tests - name: Build test app @@ -199,15 +203,17 @@ jobs: # Server - name: Install server - run: cd server && python3 setup.py develop + run: cd server && python -m pip install --editable . # Client - name: Install test requirements run: pip install wheel pytest pytest-runner - name: Install client - run: cd client && python3 setup.py develop + run: cd client && python -m pip install --editable . - name: Test client - run: cd client && python3 setup.py test -v + run: | + python -m pip install -r requirements-dev.txt + cd client && pytest -v tests/ # Functional tests - name: Build test app From 0e670ca0945a6bc43318037b443a77dab486060c Mon Sep 17 00:00:00 2001 From: Rafael de Lucena Valle Date: Thu, 3 Oct 2024 23:59:50 -0300 Subject: [PATCH 16/18] Add requirements dev --- client/requirements-dev.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 client/requirements-dev.txt diff --git a/client/requirements-dev.txt b/client/requirements-dev.txt new file mode 100644 index 0000000..e079f8a --- /dev/null +++ b/client/requirements-dev.txt @@ -0,0 +1 @@ +pytest From a13a58eadaac88fffa6d48827d2841e1f4ab172c Mon Sep 17 00:00:00 2001 From: Rafael de Lucena Valle Date: Fri, 4 Oct 2024 00:05:06 -0300 Subject: [PATCH 17/18] Fix install server command --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ed33164..0f449a1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -121,7 +121,7 @@ jobs: # Server - name: Install server - run: cd server && python -m pip install --editable / + run: cd server && python -m pip install --editable . # Client - name: Install client From a4ffd56c12a0b5ce02d1656831e405466b991d43 Mon Sep 17 00:00:00 2001 From: Rafael de Lucena Valle Date: Fri, 4 Oct 2024 00:18:15 -0300 Subject: [PATCH 18/18] Not using requirements on the workflow yet --- .github/workflows/main.yml | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0f449a1..a7c8cd5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -70,9 +70,7 @@ jobs: - name: Install client run: cd client && python -m pip install --editable . - name: Test client - run: | - python -m pip install -r requirements-dev.txt - cd client && pytest -v tests/ + run: cd client && pytest -v tests # Functional tests - name: Build test app @@ -127,9 +125,7 @@ jobs: - name: Install client run: cd client && python -m pip install --editable . - name: Test client - run: | - python -m pip install -r requirements-dev.txt - cd client && pytest -v tests/ + run: cd client && pytest -v tests # Functional tests - name: Build test app @@ -211,9 +207,7 @@ jobs: - name: Install client run: cd client && python -m pip install --editable . - name: Test client - run: | - python -m pip install -r requirements-dev.txt - cd client && pytest -v tests/ + run: cd client && pytest -v tests # Functional tests - name: Build test app