support/testing: add python-attrs tests
authorRicardo Martincoski <ricardo.martincoski@gmail.com>
Fri, 16 Nov 2018 03:57:22 +0000 (01:57 -0200)
committerThomas Petazzoni <thomas.petazzoni@bootlin.com>
Fri, 23 Nov 2018 21:05:46 +0000 (22:05 +0100)
Use a minimal script to check the basic usage creating a class with 2
attributes.

Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
.gitlab-ci.yml
support/testing/tests/package/sample_python_attrs.py [new file with mode: 0644]
support/testing/tests/package/test_python_attrs.py [new file with mode: 0644]

index 62f3768d3d6fea579b338db67eea0d9d9450914e..494894a782d7514f3d3c503ad3a66b21c7b617c6 100644 (file)
@@ -318,6 +318,8 @@ tests.package.test_python.TestPython2: *runtime_test
 tests.package.test_python.TestPython3: *runtime_test
 tests.package.test_python_argh.TestPythonPy2Argh: *runtime_test
 tests.package.test_python_argh.TestPythonPy3Argh: *runtime_test
+tests.package.test_python_attrs.TestPythonPy2Attrs: *runtime_test
+tests.package.test_python_attrs.TestPythonPy3Attrs: *runtime_test
 tests.package.test_python_autobahn.TestPythonPy2Autobahn: *runtime_test
 tests.package.test_python_autobahn.TestPythonPy3Autobahn: *runtime_test
 tests.package.test_python_crossbar.TestPythonPy3Crossbar: *runtime_test
diff --git a/support/testing/tests/package/sample_python_attrs.py b/support/testing/tests/package/sample_python_attrs.py
new file mode 100644 (file)
index 0000000..f224944
--- /dev/null
@@ -0,0 +1,15 @@
+import attr
+
+
+@attr.s
+class Obj(object):
+    x = attr.ib()
+    y = attr.ib(default=1)
+
+
+obj1 = Obj(2)
+assert(obj1.x == 2)
+assert(obj1.y == 1)
+obj2 = Obj(3, 4)
+assert(obj2.x == 3)
+assert(obj2.y == 4)
diff --git a/support/testing/tests/package/test_python_attrs.py b/support/testing/tests/package/test_python_attrs.py
new file mode 100644 (file)
index 0000000..9f59703
--- /dev/null
@@ -0,0 +1,21 @@
+from tests.package.test_python import TestPythonPackageBase
+
+
+class TestPythonPy2Attrs(TestPythonPackageBase):
+    __test__ = True
+    config = TestPythonPackageBase.config + \
+        """
+        BR2_PACKAGE_PYTHON=y
+        BR2_PACKAGE_PYTHON_ATTRS=y
+        """
+    sample_scripts = ["tests/package/sample_python_attrs.py"]
+
+
+class TestPythonPy3Attrs(TestPythonPackageBase):
+    __test__ = True
+    config = TestPythonPackageBase.config + \
+        """
+        BR2_PACKAGE_PYTHON3=y
+        BR2_PACKAGE_PYTHON_ATTRS=y
+        """
+    sample_scripts = ["tests/package/sample_python_attrs.py"]