From patchwork Wed Apr 29 22:42:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcin Niestroj X-Patchwork-Id: 1279761 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=busybox.net (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=grinn-global.com Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49CD793s6nz9sSd for ; Thu, 30 Apr 2020 08:43:01 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id ADB63234B3; Wed, 29 Apr 2020 22:42:56 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NPY4mp8XZvpm; Wed, 29 Apr 2020 22:42:54 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id A7C5423724; Wed, 29 Apr 2020 22:42:53 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id E61DD1BF354 for ; Wed, 29 Apr 2020 22:42:44 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id E3032874F3 for ; Wed, 29 Apr 2020 22:42:44 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hQ6qhR+JdX87 for ; Wed, 29 Apr 2020 22:42:43 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from smtp.megiteam.pl (smtp.megiteam.pl [31.186.83.105]) by hemlock.osuosl.org (Postfix) with ESMTPS id 2CC3B874AB for ; Wed, 29 Apr 2020 22:42:42 +0000 (UTC) Received: from [95.143.241.142] (helo=localhost.localdomain) by smtp.megiteam.pl with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86.2_XX) (envelope-from ) id 1jTvPb-0000fv-B9; Thu, 30 Apr 2020 00:42:39 +0200 From: Marcin Niestroj To: buildroot@buildroot.org Date: Thu, 30 Apr 2020 00:42:25 +0200 Message-Id: <20200429224225.2454330-5-m.niestroj@grinn-global.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200429224225.2454330-1-m.niestroj@grinn-global.com> References: <20200429224225.2454330-1-m.niestroj@grinn-global.com> MIME-Version: 1.0 Subject: [Buildroot] [PATCH 4/4] support/testing: add pytest test X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marcin Niestroj Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" Signed-off-by: Marcin Niestroj --- .gitlab-ci.yml | 1 + DEVELOPERS | 2 ++ .../tests/package/sample_python_pytest.py | 25 +++++++++++++++++++ .../tests/package/test_python_pytest.py | 19 ++++++++++++++ 4 files changed, 47 insertions(+) create mode 100644 support/testing/tests/package/sample_python_pytest.py create mode 100644 support/testing/tests/package/test_python_pytest.py diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fa8e077a07..12930dd849 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -497,6 +497,7 @@ tests.package.test_python_pexpect.TestPythonPy2Pexpect: { extends: .runtime_test tests.package.test_python_pexpect.TestPythonPy3Pexpect: { extends: .runtime_test } tests.package.test_python_pynacl.TestPythonPy2Pynacl: { extends: .runtime_test } tests.package.test_python_pynacl.TestPythonPy3Pynacl: { extends: .runtime_test } +tests.package.test_python_pytest.TestPythonPy3Pytest: { extends: .runtime_test } tests.package.test_python_pyyaml.TestPythonPy2Pyyaml: { extends: .runtime_test } tests.package.test_python_pyyaml.TestPythonPy3Pyyaml: { extends: .runtime_test } tests.package.test_python_service_identity.TestPythonPy2ServiceIdentity: { extends: .runtime_test } diff --git a/DEVELOPERS b/DEVELOPERS index 2e14053559..5175798e76 100644 --- a/DEVELOPERS +++ b/DEVELOPERS @@ -1603,7 +1603,9 @@ F: package/python-pluggy/ F: package/python-pytest/ F: package/rs485conf/ F: package/turbolua/ +F: support/testing/tests/package/sample_python_pytest.py F: support/testing/tests/package/test_netdata.py +F: support/testing/tests/package/test_python_pytest.py N: Marcus Folkesson F: package/libostree/ diff --git a/support/testing/tests/package/sample_python_pytest.py b/support/testing/tests/package/sample_python_pytest.py new file mode 100644 index 0000000000..870cc8512b --- /dev/null +++ b/support/testing/tests/package/sample_python_pytest.py @@ -0,0 +1,25 @@ +import pytest + + +x = 1 + + +@pytest.fixture() +def f1(): + global x + x = 2 + yield 15 + x = 3 + + +def test_1(): + assert x == 1 + + +def test_2(f1): + assert x == 2 + assert f1 == 15 + + +def test_3(): + assert x == 3 diff --git a/support/testing/tests/package/test_python_pytest.py b/support/testing/tests/package/test_python_pytest.py new file mode 100644 index 0000000000..7fa7e44018 --- /dev/null +++ b/support/testing/tests/package/test_python_pytest.py @@ -0,0 +1,19 @@ +import os + +from tests.package.test_python import TestPythonPackageBase + + +class TestPythonPy3Pytest(TestPythonPackageBase): + __test__ = True + config = TestPythonPackageBase.config + \ + """ + BR2_PACKAGE_PYTHON3=y + BR2_PACKAGE_PYTHON_PYTEST=y + """ + sample_scripts = ["tests/package/sample_python_pytest.py"] + + def run_sample_scripts(self): + for script in self.sample_scripts: + cmd = self.interpreter + " -m pytest " + os.path.basename(script) + _, exit_code = self.emulator.run(cmd, timeout=self.timeout) + self.assertEqual(exit_code, 0)