aboutsummaryrefslogtreecommitdiff
path: root/support
diff options
context:
space:
mode:
authorGravatar Marcin Niestroj <m.niestroj@grinn-global.com>2020-12-22 17:39:16 +0100
committerGravatar Thomas Petazzoni <thomas.petazzoni@bootlin.com>2020-12-31 15:10:16 +0100
commit55a6ff34babe64ef2baae758d537bf992c9ae086 (patch)
tree3c0e1fc3a0102b121ad33eb9a3550663937846e8 /support
parent2c4ad5ba2476b552698eaeb12a9f99e445478958 (diff)
downloadbuildroot-55a6ff34babe64ef2baae758d537bf992c9ae086.tar.gz
buildroot-55a6ff34babe64ef2baae758d537bf992c9ae086.tar.bz2
support/testing: add pytest-asyncio test
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Diffstat (limited to 'support')
-rw-r--r--support/testing/tests/package/sample_python_pytest_asyncio.py31
-rw-r--r--support/testing/tests/package/test_python_pytest_asyncio.py20
2 files changed, 51 insertions, 0 deletions
diff --git a/support/testing/tests/package/sample_python_pytest_asyncio.py b/support/testing/tests/package/sample_python_pytest_asyncio.py
new file mode 100644
index 0000000000..cdb8cd9fb9
--- /dev/null
+++ b/support/testing/tests/package/sample_python_pytest_asyncio.py
@@ -0,0 +1,31 @@
+import asyncio
+import pytest
+
+
+x = 1
+
+
+@pytest.fixture()
+def f1():
+ global x
+ x = 2
+ yield 15
+ x = 3
+
+
+@pytest.mark.asyncio
+async def test_1():
+ assert x == 1
+
+
+@pytest.mark.asyncio
+async def test_2(f1):
+ assert x == 2
+ assert f1 == 15
+
+
+@pytest.mark.asyncio
+async def test_3():
+ assert x == 3
+ await asyncio.sleep(0.1)
+ assert x == 3
diff --git a/support/testing/tests/package/test_python_pytest_asyncio.py b/support/testing/tests/package/test_python_pytest_asyncio.py
new file mode 100644
index 0000000000..caf034be7b
--- /dev/null
+++ b/support/testing/tests/package/test_python_pytest_asyncio.py
@@ -0,0 +1,20 @@
+import os
+
+from tests.package.test_python import TestPythonPackageBase
+
+
+class TestPythonPy3PytestAsyncio(TestPythonPackageBase):
+ __test__ = True
+ config = TestPythonPackageBase.config + \
+ """
+ BR2_PACKAGE_PYTHON3=y
+ BR2_PACKAGE_PYTHON_PYTEST=y
+ BR2_PACKAGE_PYTHON_PYTEST_ASYNCIO=y
+ """
+ sample_scripts = ["tests/package/sample_python_pytest_asyncio.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)