diff --git a/.github/workflows/bindings_python.yml b/.github/workflows/bindings_python.yml index 6abf6cd4e75c..a93a72eb3a1a 100644 --- a/.github/workflows/bindings_python.yml +++ b/.github/workflows/bindings_python.yml @@ -54,8 +54,10 @@ jobs: python -m pip install -e .[test] - name: Run behave working-directory: "bindings/python" + env: + OPENDAL_MEMORY_TEST: on run: | - python -m behave tests + pytest -vk TestMemory linux: runs-on: ubuntu-latest diff --git a/bindings/python/CONTRIBUTING.md b/bindings/python/CONTRIBUTING.md index f01735f088af..9b428b10c65b 100644 --- a/bindings/python/CONTRIBUTING.md +++ b/bindings/python/CONTRIBUTING.md @@ -67,11 +67,11 @@ Note: `maturin develop` will be faster, but doesn't support all the features. In ## Test -OpenDAL adopts `behave` for behavior tests: +OpenDAL adopts `pytest` for behavior tests: ```shell maturin develop -E test -behave tests +OPENDAL_MEMORY_TEST=on pytest -vk TestMemory ``` ## Docs diff --git a/bindings/python/README.md b/bindings/python/README.md index 0baf1ae0114e..871a0744263b 100644 --- a/bindings/python/README.md +++ b/bindings/python/README.md @@ -66,7 +66,7 @@ Run some tests: ```shell maturin develop -E test -behave tests +OPENDAL_MEMORY_TEST=on pytest -vk TestMemory ``` Build API docs: diff --git a/bindings/python/pyproject.toml b/bindings/python/pyproject.toml index 34ae83a24cfa..d096ef35ba4c 100644 --- a/bindings/python/pyproject.toml +++ b/bindings/python/pyproject.toml @@ -41,7 +41,7 @@ benchmark = [ "boto3-stubs[essential]", ] docs = ["pdoc"] -test = ["behave", "pytest", "python-dotenv"] +test = ["pytest", "python-dotenv"] [project.urls] Documentation = "https://opendal.apache.org/docs/python/opendal.html" diff --git a/bindings/python/tests/binding.feature b/bindings/python/tests/binding.feature deleted file mode 120000 index fcb71d3890cd..000000000000 --- a/bindings/python/tests/binding.feature +++ /dev/null @@ -1 +0,0 @@ -../../tests/features/binding.feature \ No newline at end of file diff --git a/bindings/python/tests/steps/binding.py b/bindings/python/tests/steps/binding.py deleted file mode 100644 index 06edb9f7ffc2..000000000000 --- a/bindings/python/tests/steps/binding.py +++ /dev/null @@ -1,100 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from behave import given, when, then -from behave.api.async_step import async_run_until_complete -import opendal - - -@given("A new OpenDAL Blocking Operator") -def step_impl(context): - context.op = opendal.Operator("memory") - - -@when('Blocking write path "{filename}" with content "{content}"') -def step_impl(context, filename, content): - context.op.write(filename, content.encode()) - - -@then('The blocking file "{filename}" should exist') -def step_impl(context, filename): - context.op.stat(filename) - - -@then('The blocking file "{filename}" entry mode must be file') -def step_impl(context, filename): - assert context.op.stat(filename).mode.is_file() - - -@then('The blocking file "{filename}" content length must be {size:d}') -def step_impl(context, filename, size): - assert context.op.stat(filename).content_length == size - - -@then('The blocking file "{filename}" must have content "{content}"') -def step_impl(context, filename, content): - bs = context.op.read(filename) - assert bs == content.encode() - - -@given("A new OpenDAL Async Operator") -@async_run_until_complete -async def step_impl(context): - context.op = opendal.AsyncOperator("memory") - - -@when('Async write path "{filename}" with content "{content}"') -@async_run_until_complete -async def step_impl(context, filename, content): - await context.op.write(filename, content.encode()) - - -@then('The async file "{filename}" should exist') -@async_run_until_complete -async def step_impl(context, filename): - await context.op.stat(filename) - - -@then('The async file "{filename}" entry mode must be file') -@async_run_until_complete -async def step_impl(context, filename): - meta = await context.op.stat(filename) - assert meta.mode.is_file() - - -@then('The async file "{filename}" content length must be {size:d}') -@async_run_until_complete -async def step_impl(context, filename, size): - meta = await context.op.stat(filename) - assert meta.content_length == size - - -@then('The async file "{filename}" must have content "{content}"') -@async_run_until_complete -async def step_impl(context, filename, content): - bs = await context.op.read(filename) - assert bs == content.encode() - -@then("The presign operation should success or raise exception Unsupported") -@async_run_until_complete -async def step_impl(context): - try: - await context.op.presign_stat("test.txt", 10) - await context.op.presign_read("test.txt", 10) - await context.op.presign_write("test.txt", 10) - except NotImplementedError: - pass \ No newline at end of file