forked from pytest-dev/pytest-bdd
-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix some spelling in the README and add some info. #103
Closed
Closed
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
bfd6014
Fix some spelling in the README and add some info.
blaisep 36d60e7
Add stub of Leslie's tutorial with sample code files
blaisep 2c5a446
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 1a0bd4b
Adjust tutorial to be executed during e2e test launch
elchupanebrej bcc1408
Slightly simplify examples
elchupanebrej 7ef30de
Slightly simplify examples
elchupanebrej 1ad7881
Merge pull request #3 from elchupanebrej/doc-e2e
blaisep 3c73d95
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 9c01d6e
WIP: add some diagrams to show sequence of events.
blaisep f2f78ca
WIP: switch to sketchy theme to emphasize immaturity
blaisep 6956956
WIP: tidy up the description of the examples.
blaisep 9029d8b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 1be3ad5
Add a developer guide
blaisep 9b42237
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Feature: Tutorial examples could be executed successfully | ||
|
||
Scenario: Catalog example with simplest steps | ||
Given Copy path from "docs\tutorial" to "tutorial" | ||
When run pytest | ||
|cli_args| --rootdir=tutorial| tutorial/tests | | ||
|
||
Then pytest outcome must contain tests with statuses: | ||
|passed| | ||
| 1| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import sys | ||
|
||
import anyio | ||
import dagger | ||
|
||
""" | ||
Copy files to the build container and list them. | ||
""" | ||
|
||
|
||
async def main(): | ||
async with dagger.Connection(dagger.Config(log_output=sys.stderr)) as client: | ||
out = await ( | ||
client.container() | ||
.from_("python:3.11-slim") | ||
.with_directory("/host", client.host().directory(".")) | ||
.with_exec(["ls", "-al", "/host"]) | ||
.stdout() | ||
) | ||
|
||
print(out) | ||
|
||
|
||
anyio.run(main) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
################# | ||
Developer Guide | ||
################# | ||
|
||
.. _quickstart: https://docs.dagger.io/quickstart/729236/cli | ||
|
||
This section is introduced specifically for ``pytest-bdd-ng`` to help developers maintain and enhance the source code. | ||
|
||
|
||
Reduce dependence on Github Actions | ||
=================================== | ||
|
||
Currently the Github action can take as much as 29 minutes and it has pinned [dependencies in other repos](https://github.com/blaisep/pytest-bdd-ng/blob/default/.github/workflows/main.yml#L33). | ||
|
||
I intend to implement local CI so that: | ||
- We can easily rotate external dependencies | ||
- We can iterate faster (by caching intermediate artifacts) | ||
- Developers can follow the dependency tree more easily. (gitmodules don't get cloned locally) | ||
|
||
|
||
Building the project locally | ||
############################ | ||
|
||
Prepare your virtual environment | ||
================================ | ||
|
||
To build the project locally, these instructions assume that you already have a working: | ||
- installed a docker runtime (eg. Docker, Rancher, Orbstack, etc) | ||
- dagger CLI (eg ``brew install dagger/tap/dagger``) | ||
- dagger Python SDK in your virtualenv (eg. ``pip install -U dagger-io``) | ||
You can refer to the dagger quickstart_ docs for help installing dagger. | ||
|
||
|
||
Explore dagger | ||
============== | ||
|
||
Let's have a bit of fun exploring dagger. Create ``ci/main.py`` and paste the following code. | ||
|
||
.. code-block::python | ||
|
||
import sys | ||
import anyio | ||
import dagger | ||
|
||
""" | ||
Run directory listing of the files in the build container | ||
""" | ||
|
||
async def main(): | ||
async with dagger.Connection(dagger.Config(log_output=sys.stderr)) as client: | ||
out = await ( | ||
client.container() | ||
.from_("python:3.11-slim") | ||
.with_directory("/host", client.host().directory(".")) | ||
.with_exec(["ls", "-al", "."]) | ||
.stdout() | ||
) | ||
print(out) | ||
anyio.run(main) | ||
|
||
Now run ``dagger run python ci/main.py`` | ||
Note the total time on the last line of the console input. | ||
|
||
Run the command again and note the total time. It should be much faster. | ||
|
||
Next, change the line ``.with_exec(["ls", "-al", "/host"])`` to ``.with_exec(["ls", "-al", "/host/tests"])`` | ||
and run ``dagger run python ci/main.py`` | ||
|
||
Is the directory listing different? How about the total time? |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
@startuml | ||
!theme sketchy-outline | ||
actor "Action" as test | ||
collections "Source" as repo | ||
control "Behave" as runner | ||
database "Artifact" as out | ||
participant "Console" as log | ||
|
||
'autonumber | ||
test -> runner: run pytest | ||
runner <--> repo: read | ||
runner -> runner: run tests | ||
runner -> out: write | ||
runner --> log: Log | ||
@enduml |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
@startuml | ||
!theme sketchy-outline | ||
actor "Action" as test | ||
collections "Source" as repo | ||
control "Pytest" as runner | ||
database "Artifact" as out | ||
participant "Console" as log | ||
|
||
'autonumber | ||
test -> runner: run pytest | ||
runner <--> repo: read | ||
runner -> out: write | ||
runner --> log: Log | ||
@enduml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,21 @@ | ||
.. NOTE:: Features below are part of end-to-end test suite; You always could find most specific | ||
use cases of **pytest-bdd-ng** by investigation of its regression | ||
test suite https://github.com/elchupanebrej/pytest-bdd-ng/tree/default/tests | ||
|
||
Gherkin feature launch by pytest.feature | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
||
.. include:: ../Features/Gherkin feature launch by pytest.feature | ||
:code: gherkin | ||
|
||
Tags for Scenario Outlines examples.feature | ||
########################################### | ||
|
||
.. include:: ../Features/Scenario/Outline/Tags for Scenario Outlines examples.feature | ||
:code: gherkin | ||
.. NOTE:: Features below are part of end-to-end test suite; You always could find most specific | ||
use cases of **pytest-bdd-ng** by investigation of its regression | ||
test suite https://github.com/elchupanebrej/pytest-bdd-ng/tree/default/tests | ||
|
||
Tutorial launch.feature | ||
!!!!!!!!!!!!!!!!!!!!!!! | ||
|
||
.. include:: ../Features/Tutorial launch.feature | ||
:code: gherkin | ||
|
||
Gherkin feature launch by pytest.feature | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
||
.. include:: ../Features/Gherkin feature launch by pytest.feature | ||
:code: gherkin | ||
|
||
Tags for Scenario Outlines examples.feature | ||
########################################### | ||
|
||
.. include:: ../Features/Scenario/Outline/Tags for Scenario Outlines examples.feature | ||
:code: gherkin |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Feature files represent `Application under test` functional capabilities | ||
# in form of acceptance test with representative examples | ||
Feature: Library book searches and book delivery | ||
Scenario: The catalog can be searched by author name. | ||
Given these books in the catalog | ||
| Author | Title | | ||
| Stephen King | The Shining | | ||
| James Baldwin | If Beale Street Could Talk | | ||
When a name search is performed for Stephen | ||
Then only these books will be returned | ||
| Author | Title | | ||
| Stephen King | The Shining | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
Tutorial for Behave/Cucumber users | ||
================================== | ||
|
||
If you have experience with Behave or Cucumber, this tutorial is for you. | ||
|
||
.. _tutorial: https://thebddcoach.com/post/a-quick-introduction-to-pytest-bdd-ng-for-people-who-are-already-familiar-with-cucumber-or-behave/ | ||
|
||
Leslie's tutorial_ ... | ||
|
||
.. toctree:: | ||
:glob: | ||
|
||
tests/features/*.feature | ||
src/*.py | ||
tests/*.py | ||
tests/*.desktop | ||
tests/steps/*.py | ||
|
||
|
||
Set up the tutorial | ||
------------------- | ||
|
||
From the project root, activate a virtual environment and run: | ||
``pip install -r docs/tutorial/requirements.txt`` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[pytest] | ||
; Defines default rootpath and a lot of pytest configs | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pytest | ||
pytest_bdd_ng |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
"""This files represents simple `Application under test`""" | ||
from dataclasses import dataclass, field | ||
from typing import Iterable, List | ||
|
||
|
||
@dataclass # Easy way to not write redundant __init__ https://docs.python.org/3/library/dataclasses.html | ||
class Book: | ||
author: str | ||
title: str | ||
|
||
|
||
@dataclass | ||
class Catalog: | ||
storage: List[Book] = field(default_factory=list) | ||
|
||
def add_books_to_catalog(self, books: Iterable[Book]): | ||
self.storage.extend(books) | ||
|
||
def search_by_author(self, term: str): | ||
for book in self.storage: | ||
if term in book.author: | ||
yield book | ||
|
||
def search_by_title(self, term: str): | ||
for book in self.storage: | ||
if term in book.title: | ||
yield book |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[Desktop Entry] | ||
Type=Link | ||
URL=features/books.feature | ||
; Feature files are gathered as usual test modules, but also could be linked into | ||
; directory hierarchy by symlinks. | ||
; Some operation systems do not provide symlinks, so such files could replace them. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
""" | ||
conftest.py is local per-directory plugin of pytest. | ||
Its mission is to define fixtures, steps, and hooks which will be used | ||
by tests gathered by pytest from directory structure below | ||
|
||
https://docs.pytest.org/en/latest/how-to/writing_plugins.html#conftest-py-local-per-directory-plugins | ||
https://docs.pytest.org/en/latest/explanation/goodpractices.html#test-discovery | ||
""" | ||
|
||
from pytest import fixture | ||
|
||
from .steps.library_steps import ( | ||
a_search_type_is_performed_for_search_term, | ||
only_these_books_will_be_returned, | ||
these_books_in_the_catalog, | ||
) | ||
|
||
|
||
@fixture | ||
def search_results() -> list: | ||
return [] |
Empty file.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A better idea is to rewrite the tutorial inside a project and make it updatable by the repository owner. If we have a tutorial as part of the e2e suite - it won't become outdated.