From patchwork Fri Nov 2 04:12:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Martincoski X-Patchwork-Id: 992175 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.138; helo=whitealder.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="EMu9UEMS"; dkim-atps=neutral Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42mTGG2SCPzB4R2 for ; Fri, 2 Nov 2018 15:13:42 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 7B6CC86D76; Fri, 2 Nov 2018 04:13:36 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id sUnx66P4MS7V; Fri, 2 Nov 2018 04:13:33 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id CDBEF85BA3; Fri, 2 Nov 2018 04:13:33 +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 41F931BF4DA for ; Fri, 2 Nov 2018 04:13:32 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 3AEAD8550C for ; Fri, 2 Nov 2018 04:13:32 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uxiVbNb0TH3U for ; Fri, 2 Nov 2018 04:13:31 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-qk1-f195.google.com (mail-qk1-f195.google.com [209.85.222.195]) by hemlock.osuosl.org (Postfix) with ESMTPS id 2D9B6820AA for ; Fri, 2 Nov 2018 04:13:31 +0000 (UTC) Received: by mail-qk1-f195.google.com with SMTP id 131so1153645qkd.4 for ; Thu, 01 Nov 2018 21:13:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=YW1Ytu7zcotwaRyO3Ijum5SMS5xH30VMxhot5i+6BsY=; b=EMu9UEMSV+Hc+jAdDDsXavl0WsXkTxZo6KX6mqj3zRtCTLpLDhA05VZNQ9z7vITHch 3eQ7nLokLKm8AADdOCZS7eJ0XymFhBmXjUG0sV+Wrfhq7g6lV2OBG7vBPpXaWrbpgQLa 4BhCMU8g28zLUzFYu3mb7AbTSlSkgSDS92VaQySi/Dk5Kpq2pSXwBMUFvf1+HYKsgVFb BtGJ+G+2co1kr3mvGqQyBr9OqzBWjlw01Xy7kOZRuNa3wifo3TeRUQ/A9hgi6aZEJR08 U97WCf+FRRJ31DPSEbKWF9M62zMp8CeVYqVsVG30rlZCpZT9laZ5Sxwn5r8V6QxtS6ug dKcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=YW1Ytu7zcotwaRyO3Ijum5SMS5xH30VMxhot5i+6BsY=; b=ikYN+cKhYlB30UPFbEUT3ZBtjuDnctTUTWPQceREGBCbDuaJ9ECsd+ehJi0Xbmb3bM RY/QfOO+eHGLhJ0TKFJVWe0Y+9KYnoWP5NoXyVqXDn2lsWKgud/Fv/Hb+BBRP7T2mLcj ab0YUipKLccaBS0sD1TZtJKUU8Uj3raeiggrCYj12vu0eot5jiZZt8lzR79BwBDYnZMd D+GcbQHOha2mlVre2JbjcH7xNOe1dD4mQpwWuKfkgXqoGrZeEXZAo/IH5XyTdykGbDmH 0vPvQdq+jDgtqqJpAcvgApEyJ+3SvIDFY19cmPsVWvLn/vmbBTfQfSFRpzU0ZCNynWad 2OGw== X-Gm-Message-State: AGRZ1gISWd4+g89jOmVMFT+6FfyjDCOATJ0SX+QuIQab5BKoszuG/ubX Dk8KeTsCOt/Pk7ISQ/MkRe6Vw2sp X-Google-Smtp-Source: AJdET5dtXF+Uo2M5OSR8Uwvwdo6AawV1boqmF5zEs5bBINPwWXTJBO0egMtOrSfjD5+aNMOVUwvInA== X-Received: by 2002:aed:3bbc:: with SMTP id r57mr3961397qte.77.1541132010134; Thu, 01 Nov 2018 21:13:30 -0700 (PDT) Received: from ultri5.home ([179.181.159.8]) by smtp.gmail.com with ESMTPSA id 83sm32849688qkz.73.2018.11.01.21.13.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Nov 2018 21:13:29 -0700 (PDT) From: Ricardo Martincoski To: buildroot@buildroot.org Date: Fri, 2 Nov 2018 01:12:31 -0300 Message-Id: <20181102041241.28910-3-ricardo.martincoski@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181102041241.28910-1-ricardo.martincoski@gmail.com> References: <20181102041241.28910-1-ricardo.martincoski@gmail.com> In-Reply-To: <20181016004230.10393-1-ricardo.martincoski@gmail.com> References: <20181016004230.10393-1-ricardo.martincoski@gmail.com> Subject: [Buildroot] [PATCH v2 02/12] support/testing: use helper class in Python 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: Thomas Petazzoni , Asaf Kahlon , Ricardo Martincoski MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" Test cases for Python 2 and Python 3 are very similar. Create a helper class named TestPythonInterpreter to hold all commonalities. This new class is not a subclass of unittest.TestCase and therefore nose2 ignores it, avoiding to create a bogus test case. Signed-off-by: Ricardo Martincoski Cc: Arnout Vandecappelle Cc: Asaf Kahlon Cc: Thomas Petazzoni Cc: Yegor Yefremov --- Changes v1 -> v2: - new patch to gradually prepare the current python test cases to receive the new class TestPythonPackageBase (see review of http://patchwork.ozlabs.org/patch/984425/); --- support/testing/tests/package/test_ipython.py | 4 +-- support/testing/tests/package/test_python.py | 31 +++++++++---------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/support/testing/tests/package/test_ipython.py b/support/testing/tests/package/test_ipython.py index 19aa33242d..da2b7f4682 100644 --- a/support/testing/tests/package/test_ipython.py +++ b/support/testing/tests/package/test_ipython.py @@ -1,4 +1,4 @@ -from tests.package.test_python import TestPythonBase +from tests.package.test_python import TestPythonInterpreter, TestPythonBase # # The following pythong tests are not being used here: # @@ -8,7 +8,7 @@ from tests.package.test_python import TestPythonBase # does, so this test ends up being a false-negative -class TestIPython(): +class TestIPython(TestPythonInterpreter): interpreter = "ipython" def test_run(self): diff --git a/support/testing/tests/package/test_python.py b/support/testing/tests/package/test_python.py index 26cf49947b..f9237f719d 100644 --- a/support/testing/tests/package/test_python.py +++ b/support/testing/tests/package/test_python.py @@ -18,6 +18,10 @@ class TestPythonBase(infra.basetest.BRTest): options=["-initrd", cpio_file]) self.emulator.login() + +class TestPythonInterpreter(): + version_string = None + def version_test(self, version, timeout=-1): cmd = self.interpreter + " --version 2>&1 | grep '^{}'".format(version) _, exit_code = self.emulator.run(cmd, timeout) @@ -41,30 +45,25 @@ class TestPythonBase(infra.basetest.BRTest): _, exit_code = self.emulator.run(cmd, timeout) self.assertEqual(exit_code, 1) - -class TestPython2(TestPythonBase): - config = TestPythonBase.config + \ - """ - BR2_PACKAGE_PYTHON=y - """ - def test_run(self): self.login() - self.version_test("Python 2") + self.version_test(self.version_string) self.math_floor_test() self.libc_time_test() self.zlib_test() -class TestPython3(TestPythonBase): +class TestPython2(TestPythonInterpreter, TestPythonBase): config = TestPythonBase.config + \ """ - BR2_PACKAGE_PYTHON3=y + BR2_PACKAGE_PYTHON=y """ + version_string = "Python 2" - def test_run(self): - self.login() - self.version_test("Python 3") - self.math_floor_test() - self.libc_time_test() - self.zlib_test() + +class TestPython3(TestPythonInterpreter, TestPythonBase): + config = TestPythonBase.config + \ + """ + BR2_PACKAGE_PYTHON3=y + """ + version_string = "Python 3"